Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add podName selection functions #1944

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions kubectl-fdb/cmd/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ func getPodList(clusterName string, namespace string, status corev1.PodStatus, d
Items: []corev1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "instance-1",
Name: "storage-1",
Namespace: namespace,
Labels: map[string]string{
fdbv1beta2.FDBProcessClassLabel: string(fdbv1beta2.ProcessClassStorage),
fdbv1beta2.FDBClusterLabel: clusterName,
fdbv1beta2.FDBProcessGroupIDLabel: "instance-1",
fdbv1beta2.FDBProcessGroupIDLabel: "storage-1",
},
DeletionTimestamp: deletionTimestamp,
},
Expand Down Expand Up @@ -119,7 +119,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Cluster is fine",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -138,7 +138,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Cluster is unavailable",
testCase{
cluster: getCluster(clusterName, namespace, false, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -156,7 +156,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Cluster is unhealthy",
testCase{
cluster: getCluster(clusterName, namespace, true, false, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -175,7 +175,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Cluster is not fully replicated",
testCase{
cluster: getCluster(clusterName, namespace, true, true, false, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -193,7 +193,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Cluster is not reconciled",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 0, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -212,7 +212,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{
ProcessGroupID: "instance-1",
ProcessGroupID: "storage-1",
ProcessGroupConditions: []*fdbv1beta2.ProcessGroupCondition{
fdbv1beta2.NewProcessGroupCondition(fdbv1beta2.MissingProcesses),
},
Expand All @@ -221,7 +221,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
}, nil),
ExpectedErrMsg: fmt.Sprintf("✖ ProcessGroup: instance-1 has the following condition: MissingProcesses since %s", time.Unix(time.Now().Unix(), 0).String()),
ExpectedErrMsg: fmt.Sprintf("✖ ProcessGroup: storage-1 has the following condition: MissingProcesses since %s", time.Unix(time.Now().Unix(), 0).String()),
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -235,7 +235,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{
ProcessGroupID: "instance-1",
ProcessGroupID: "storage-1",
ProcessGroupConditions: []*fdbv1beta2.ProcessGroupCondition{
fdbv1beta2.NewProcessGroupCondition(fdbv1beta2.MissingProcesses),
},
Expand All @@ -245,7 +245,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
}, nil),
ExpectedErrMsg: "⚠ ProcessGroup: instance-1 is marked for removal, excluded state: false",
ExpectedErrMsg: "⚠ ProcessGroup: storage-1 is marked for removal, excluded state: false",
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -259,12 +259,12 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Pod is in Pending phase",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodPending,
}, nil),
ExpectedErrMsg: "✖ Pod test/instance-1 has unexpected Phase Pending with Reason:",
ExpectedErrMsg: "✖ Pod test/storage-1 has unexpected Phase Pending with Reason:",
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -277,7 +277,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Container is in terminated state",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -294,7 +294,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
},
},
}, nil),
ExpectedErrMsg: "✖ Pod test/instance-1 has an unready container: foundationdb",
ExpectedErrMsg: "✖ Pod test/storage-1 has an unready container: foundationdb",
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -307,7 +307,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Container is in ready state",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
Expand All @@ -332,13 +332,13 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Pod is stuck in terminating",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
ContainerStatuses: []corev1.ContainerStatus{},
}, &metav1.Time{Time: time.Now().Add(-1 * time.Hour)}),
ExpectedErrMsg: fmt.Sprintf("✖ Pod test/instance-1 has been stuck in terminating since %s", time.Unix(time.Now().Add(-1*time.Hour).Unix(), 0).String()),
ExpectedErrMsg: fmt.Sprintf("✖ Pod test/storage-1 has been stuck in terminating since %s", time.Unix(time.Now().Add(-1*time.Hour).Unix(), 0).String()),
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -352,7 +352,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{
ProcessGroupID: "instance-1",
ProcessGroupID: "storage-1",
RemovalTimestamp: &metav1.Time{Time: time.Now()},
ExclusionTimestamp: &metav1.Time{Time: time.Now()},
},
Expand All @@ -372,7 +372,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
},
},
}, &metav1.Time{Time: time.Now().Add(-1 * time.Hour)}),
ExpectedErrMsg: "⚠ ProcessGroup: instance-1 is marked for removal, excluded state: true",
ExpectedErrMsg: "⚠ ProcessGroup: storage-1 is marked for removal, excluded state: true",
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -387,7 +387,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{
ProcessGroupID: "instance-1",
ProcessGroupID: "storage-1",
RemovalTimestamp: &metav1.Time{Time: time.Now()},
ExclusionTimestamp: &metav1.Time{Time: time.Now()},
},
Expand Down Expand Up @@ -421,7 +421,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
Entry("Missing Pods",
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{ProcessGroupID: "instance-1"},
{ProcessGroupID: "storage-1"},
}),
podList: &corev1.PodList{},
ExpectedErrMsg: "✖ Found no Pods for this cluster",
Expand All @@ -441,7 +441,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
}, nil),
ExpectedErrMsg: "✖ Pod test/instance-1 with the ID instance-1 is not part of the cluster spec status",
ExpectedErrMsg: "✖ Pod test/storage-1 with the ID storage-1 is not part of the cluster spec status",
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand All @@ -455,7 +455,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
testCase{
cluster: getCluster(clusterName, namespace, true, true, true, 1, []*fdbv1beta2.ProcessGroupStatus{
{
ProcessGroupID: "instance-1",
ProcessGroupID: "storage-1",
ProcessGroupConditions: []*fdbv1beta2.ProcessGroupCondition{
fdbv1beta2.NewProcessGroupCondition(fdbv1beta2.MissingProcesses),
fdbv1beta2.NewProcessGroupCondition(fdbv1beta2.IncorrectPodSpec),
Expand All @@ -465,7 +465,7 @@ var _ = Describe("[plugin] analyze cluster", func() {
podList: getPodList(clusterName, namespace, corev1.PodStatus{
Phase: corev1.PodRunning,
}, nil),
ExpectedErrMsg: fmt.Sprintf("✖ ProcessGroup: instance-1 has the following condition: MissingProcesses since %s\n⚠ Ignored 1 conditions", time.Unix(time.Now().Unix(), 0).String()),
ExpectedErrMsg: fmt.Sprintf("✖ ProcessGroup: storage-1 has the following condition: MissingProcesses since %s\n⚠ Ignored 1 conditions", time.Unix(time.Now().Unix(), 0).String()),
ExpectedStdoutMsg: `Checking cluster: test/test
✔ Cluster is available
✔ Cluster is fully replicated
Expand Down
18 changes: 9 additions & 9 deletions kubectl-fdb/cmd/buggify_crash_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ var _ = Describe("[plugin] buggify crash-loop process groups command", func() {
ProcessGroupOpts: processGroupSelectionOptions{
ids: []string{
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fmt.Sprintf("%s-instance-1", clusterName),
fmt.Sprintf("%s-instance-2", clusterName),
fmt.Sprintf("%s-instance-2", secondClusterName),
fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage),
fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage),
fmt.Sprintf("%s-%s-2", secondClusterName, fdbv1beta2.ProcessClassStorage),
},
clusterLabel: fdbv1beta2.FDBClusterLabel,
},
ExpectedProcessGroupsInCrashLoop: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-1", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
secondClusterName: {
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", secondClusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", secondClusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand All @@ -133,8 +133,8 @@ var _ = Describe("[plugin] buggify crash-loop process groups command", func() {
ExpectedProcessGroupsInCrashLoop: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-1", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand All @@ -147,7 +147,7 @@ var _ = Describe("[plugin] buggify crash-loop process groups command", func() {
ExpectedProcessGroupsInCrashLoop: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand Down
18 changes: 9 additions & 9 deletions kubectl-fdb/cmd/buggify_no_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ var _ = Describe("[plugin] buggify no-schedule instances command", func() {
ProcessGroupOpts: processGroupSelectionOptions{
ids: []string{
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fmt.Sprintf("%s-instance-1", clusterName),
fmt.Sprintf("%s-instance-2", clusterName),
fmt.Sprintf("%s-instance-2", secondClusterName),
fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage),
fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage),
fmt.Sprintf("%s-%s-2", secondClusterName, fdbv1beta2.ProcessClassStorage),
},
clusterLabel: fdbv1beta2.FDBClusterLabel,
},
ExpectedProcessGroupsInNoSchedule: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-1", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
secondClusterName: {
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", secondClusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", secondClusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand All @@ -116,8 +116,8 @@ var _ = Describe("[plugin] buggify no-schedule instances command", func() {
ExpectedProcessGroupsInNoSchedule: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-1", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-1", clusterName, fdbv1beta2.ProcessClassStorage)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand All @@ -130,7 +130,7 @@ var _ = Describe("[plugin] buggify no-schedule instances command", func() {
ExpectedProcessGroupsInNoSchedule: map[string][]fdbv1beta2.ProcessGroupID{
clusterName: {
// the helper function to create pods for the k8s client uses "instance" not "storage" processGroup names
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-instance-2", clusterName)),
fdbv1beta2.ProcessGroupID(fmt.Sprintf("%s-%s-2", clusterName, fdbv1beta2.ProcessClassStorage)),
},
},
}),
Expand Down
Loading
Loading