invoke getTypedVersion() instead of direct runtime call

This commit is contained in:
ianlang 2019-10-22 23:49:22 +08:00
parent c981bce007
commit babdcd0d14

View File

@ -188,7 +188,7 @@ func NewKubeGenericRuntimeManager(
logReduction: logreduction.NewLogReduction(identicalErrorDelay), logReduction: logreduction.NewLogReduction(identicalErrorDelay),
} }
typedVersion, err := kubeRuntimeManager.runtimeService.Version(kubeRuntimeAPIVersion) typedVersion, err := kubeRuntimeManager.getTypedVersion()
if err != nil { if err != nil {
klog.Errorf("Get runtime version failed: %v", err) klog.Errorf("Get runtime version failed: %v", err)
return nil, err return nil, err
@ -253,17 +253,15 @@ func newRuntimeVersion(version string) (*utilversion.Version, error) {
func (m *kubeGenericRuntimeManager) getTypedVersion() (*runtimeapi.VersionResponse, error) { func (m *kubeGenericRuntimeManager) getTypedVersion() (*runtimeapi.VersionResponse, error) {
typedVersion, err := m.runtimeService.Version(kubeRuntimeAPIVersion) typedVersion, err := m.runtimeService.Version(kubeRuntimeAPIVersion)
if err != nil { if err != nil {
klog.Errorf("Get remote runtime typed version failed: %v", err) return nil, fmt.Errorf("get remote runtime typed version failed: %v", err)
return nil, err
} }
return typedVersion, nil return typedVersion, nil
} }
// Version returns the version information of the container runtime. // Version returns the version information of the container runtime.
func (m *kubeGenericRuntimeManager) Version() (kubecontainer.Version, error) { func (m *kubeGenericRuntimeManager) Version() (kubecontainer.Version, error) {
typedVersion, err := m.runtimeService.Version(kubeRuntimeAPIVersion) typedVersion, err := m.getTypedVersion()
if err != nil { if err != nil {
klog.Errorf("Get remote runtime version failed: %v", err)
return nil, err return nil, err
} }