Skip to content

Commit

Permalink
Merge pull request kubernetes#116746 from AxeZhan/csi_translate
Browse files Browse the repository at this point in the history
Return name instead whole volume when error occurred in csi-translation
  • Loading branch information
k8s-ci-robot authored Jun 15, 2023
2 parents c984d53 + 81a0ea3 commit 1193ab6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions staging/src/k8s.io/csi-translation-lib/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ func (CSITranslator) GetInTreePluginNameFromSpec(pv *v1.PersistentVolume, vol *v
return curPlugin.GetInTreePluginName(), nil
}
}
return "", fmt.Errorf("could not find in-tree plugin name from persistent volume %v", pv)
return "", fmt.Errorf("could not find in-tree plugin name from persistent volume %s", pv.Name)
} else if vol != nil {
for _, curPlugin := range inTreePlugins {
if curPlugin.CanSupportInline(vol) {
return curPlugin.GetInTreePluginName(), nil
}
}
return "", fmt.Errorf("could not find in-tree plugin name from volume %v", vol)
return "", fmt.Errorf("could not find in-tree plugin name from volume %s", vol.Name)
} else {
return "", errors.New("both persistent volume and volume are nil")
}
Expand All @@ -171,7 +171,7 @@ func (CSITranslator) GetCSINameFromInTreeName(pluginName string) (string, error)
return csiDriverName, nil
}
}
return "", fmt.Errorf("could not find CSI Driver name for plugin %v", pluginName)
return "", fmt.Errorf("could not find CSI Driver name for plugin %s", pluginName)
}

// GetInTreeNameFromCSIName returns the name of the in-tree plugin superseded by
Expand All @@ -180,7 +180,7 @@ func (CSITranslator) GetInTreeNameFromCSIName(pluginName string) (string, error)
if plugin, ok := inTreePlugins[pluginName]; ok {
return plugin.GetInTreePluginName(), nil
}
return "", fmt.Errorf("could not find In-Tree driver name for CSI plugin %v", pluginName)
return "", fmt.Errorf("could not find In-Tree driver name for CSI plugin %s", pluginName)
}

// IsPVMigratable tests whether there is migration logic for the given Persistent Volume
Expand Down Expand Up @@ -208,5 +208,5 @@ func (CSITranslator) RepairVolumeHandle(driverName, volumeHandle, nodeID string)
if plugin, ok := inTreePlugins[driverName]; ok {
return plugin.RepairVolumeHandle(volumeHandle, nodeID)
}
return "", fmt.Errorf("could not find In-Tree driver name for CSI plugin %v", driverName)
return "", fmt.Errorf("could not find In-Tree driver name for CSI plugin %s", driverName)
}

0 comments on commit 1193ab6

Please sign in to comment.