diff --git a/kubectl-fdb/cmd/buggify_crash_loop.go b/kubectl-fdb/cmd/buggify_crash_loop.go index 3f699fe03..87df8251e 100644 --- a/kubectl-fdb/cmd/buggify_crash_loop.go +++ b/kubectl-fdb/cmd/buggify_crash_loop.go @@ -108,7 +108,7 @@ func updateCrashLoopList(kubeClient client.Client, clusterName string, pods []st return err } - processGroups, err := getProcessGroupIDsFromPodName(cluster, pods) + processGroupIDs, err := getProcessGroupIDsFromPodName(cluster, pods) if err != nil { return err } @@ -124,26 +124,26 @@ func updateCrashLoopList(kubeClient client.Client, clusterName string, pods []st return kubeClient.Patch(ctx.TODO(), cluster, patch) } - if len(processGroups) == 0 { + if len(processGroupIDs) == 0 { return fmt.Errorf("please provide atleast one pod") } if wait { if clear { - if !confirmAction(fmt.Sprintf("Removing %v to crash-loop from cluster %s/%s", processGroups, namespace, clusterName)) { + if !confirmAction(fmt.Sprintf("Removing %v to crash-loop from cluster %s/%s", processGroupIDs, namespace, clusterName)) { return fmt.Errorf("user aborted the removal") } } else { - if !confirmAction(fmt.Sprintf("Adding %v to crash-loop from cluster %s/%s", processGroups, namespace, clusterName)) { + if !confirmAction(fmt.Sprintf("Adding %v to crash-loop from cluster %s/%s", processGroupIDs, namespace, clusterName)) { return fmt.Errorf("user aborted the removal") } } } if clear { - cluster.RemoveProcessGroupsFromCrashLoopList(processGroups) + cluster.RemoveProcessGroupsFromCrashLoopList(processGroupIDs) } else { - cluster.AddProcessGroupsToCrashLoopList(processGroups) + cluster.AddProcessGroupsToCrashLoopList(processGroupIDs) } return kubeClient.Patch(ctx.TODO(), cluster, patch) diff --git a/kubectl-fdb/cmd/buggify_no_schedule.go b/kubectl-fdb/cmd/buggify_no_schedule.go index be07d1bb4..486565215 100644 --- a/kubectl-fdb/cmd/buggify_no_schedule.go +++ b/kubectl-fdb/cmd/buggify_no_schedule.go @@ -109,7 +109,7 @@ func updateNoScheduleList(kubeClient client.Client, clusterName string, pods []s return err } - processGroups, err := getProcessGroupIDsFromPodName(cluster, pods) + processGroupIDs, err := getProcessGroupIDsFromPodName(cluster, pods) if err != nil { return err } @@ -125,26 +125,26 @@ func updateNoScheduleList(kubeClient client.Client, clusterName string, pods []s return kubeClient.Patch(ctx.TODO(), cluster, patch) } - if len(processGroups) == 0 { + if len(processGroupIDs) == 0 { return fmt.Errorf("please provide atleast one pod") } if wait { if clear { - if !confirmAction(fmt.Sprintf("Removing %v from no-schedule from cluster %s/%s", processGroups, namespace, clusterName)) { + if !confirmAction(fmt.Sprintf("Removing %v from no-schedule from cluster %s/%s", processGroupIDs, namespace, clusterName)) { return fmt.Errorf("user aborted the removal") } } else { - if !confirmAction(fmt.Sprintf("Adding %v from no-schedule from cluster %s/%s", processGroups, namespace, clusterName)) { + if !confirmAction(fmt.Sprintf("Adding %v from no-schedule from cluster %s/%s", processGroupIDs, namespace, clusterName)) { return fmt.Errorf("user aborted the removal") } } } if clear { - cluster.RemoveProcessGroupsFromNoScheduleList(processGroups) + cluster.RemoveProcessGroupsFromNoScheduleList(processGroupIDs) } else { - cluster.AddProcessGroupsToNoScheduleList(processGroups) + cluster.AddProcessGroupsToNoScheduleList(processGroupIDs) } return kubeClient.Patch(ctx.TODO(), cluster, patch) diff --git a/kubectl-fdb/cmd/k8s_client.go b/kubectl-fdb/cmd/k8s_client.go index d2300588f..35b874b95 100644 --- a/kubectl-fdb/cmd/k8s_client.go +++ b/kubectl-fdb/cmd/k8s_client.go @@ -203,7 +203,7 @@ func getAllPodsFromClusterWithCondition(kubeClient client.Client, clusterName st // getProcessGroupIDsFromPodName returns the process group IDs based on the cluster configuration. func getProcessGroupIDsFromPodName(cluster *fdbv1beta2.FoundationDBCluster, podNames []string) ([]string, error) { - processGroups := make([]string, 0, len(podNames)) + processGroupIDs := make([]string, 0, len(podNames)) // TODO(johscheuer): We could validate if the provided process group is actually part of the cluster for _, podName := range podNames { @@ -215,8 +215,8 @@ func getProcessGroupIDsFromPodName(cluster *fdbv1beta2.FoundationDBCluster, podN return nil, fmt.Errorf("cluster name %s is not set as prefix for Pod name %s, please ensure the specified Pod is part of the cluster", cluster.Name, podName) } - processGroups = append(processGroups, internal.GetProcessGroupIDFromPodName(cluster, podName)) + processGroupIDs = append(processGroupIDs, internal.GetProcessGroupIDFromPodName(cluster, podName)) } - return processGroups, nil + return processGroupIDs, nil } diff --git a/kubectl-fdb/cmd/remove_process_group.go b/kubectl-fdb/cmd/remove_process_group.go index 63fa1b880..41ec570c3 100644 --- a/kubectl-fdb/cmd/remove_process_group.go +++ b/kubectl-fdb/cmd/remove_process_group.go @@ -107,8 +107,8 @@ kubectl fdb -n default remove process-group -c cluster --remove-all-failed } // replaceProcessGroups adds process groups to the removal list of the cluster -func replaceProcessGroups(kubeClient client.Client, clusterName string, processGroups []string, namespace string, withExclusion bool, wait bool, removeAllFailed bool, useProcessGroupID bool) error { - if len(processGroups) == 0 && !removeAllFailed { +func replaceProcessGroups(kubeClient client.Client, clusterName string, processGroupIDs []string, namespace string, withExclusion bool, wait bool, removeAllFailed bool, useProcessGroupID bool) error { + if len(processGroupIDs) == 0 && !removeAllFailed { return nil } @@ -123,7 +123,7 @@ func replaceProcessGroups(kubeClient client.Client, clusterName string, processG // In this case the user has Pod name specified if !useProcessGroupID { - processGroups, err = getProcessGroupIDsFromPodName(cluster, processGroups) + processGroupIDs, err = getProcessGroupIDsFromPodName(cluster, processGroupIDs) if err != nil { return err } @@ -132,7 +132,7 @@ func replaceProcessGroups(kubeClient client.Client, clusterName string, processG patch := client.MergeFrom(cluster.DeepCopy()) processGroupSet := map[string]fdbv1beta2.None{} - for _, processGroup := range processGroups { + for _, processGroup := range processGroupIDs { processGroupSet[processGroup] = fdbv1beta2.None{} } @@ -145,22 +145,21 @@ func replaceProcessGroups(kubeClient client.Client, clusterName string, processG needsReplacement, _ := processGroupStatus.NeedsReplacement(0) if needsReplacement { - processGroups = append(processGroups, processGroupStatus.ProcessGroupID) + processGroupIDs = append(processGroupIDs, processGroupStatus.ProcessGroupID) } } } if wait { - confirmed := confirmAction(fmt.Sprintf("Remove %v from cluster %s/%s with exclude: %t", processGroups, namespace, clusterName, withExclusion)) - if !confirmed { + if !confirmAction(fmt.Sprintf("Remove %v from cluster %s/%s with exclude: %t", processGroupIDs, namespace, clusterName, withExclusion)) { return fmt.Errorf("user aborted the removal") } } if withExclusion { - cluster.AddProcessGroupsToRemovalList(processGroups) + cluster.AddProcessGroupsToRemovalList(processGroupIDs) } else { - cluster.AddProcessGroupsToRemovalWithoutExclusionList(processGroups) + cluster.AddProcessGroupsToRemovalWithoutExclusionList(processGroupIDs) } return kubeClient.Patch(ctx.TODO(), cluster, patch)