cluster-autoscaler: fix NPE when UI not found
@@ -582,17 +582,20 @@ func (sc *SettingController) updateKubernetesClusterAutoscalerEnabled() error {
evictKey := types.KubernetesClusterAutoscalerSafeToEvictKey
+ deploymentList, err := sc.ds.ListDeploymentWithLabels(types.GetBaseLabelsForSystemManagedComponent())
+ if err != nil {
+ return errors.Wrapf(err, "failed to list Longhorn deployments for %v annotation update", types.KubernetesClusterAutoscalerSafeToEvictKey)
+ }
+
longhornUI, err := sc.ds.GetDeployment(types.LonghornUIDeploymentName)
if err != nil && !apierrors.IsNotFound(err) {
return errors.Wrapf(err, "failed to get %v deployment", types.LonghornUIDeploymentName)
}
- deploymentList, err := sc.ds.ListDeploymentWithLabels(types.GetBaseLabelsForSystemManagedComponent())
- if err != nil {
- return errors.Wrapf(err, "failed to list Longhorn deployments for %v annotation update", types.KubernetesClusterAutoscalerSafeToEvictKey)
+ if longhornUI != nil {
+ deploymentList = append(deploymentList, longhornUI)
}
- deploymentList = append(deploymentList, longhornUI)
for _, dp := range deploymentList {
if !util.HasLocalStorageInDeployment(dp) {
continue
