-
Notifications
You must be signed in to change notification settings - Fork 19
Add 3 labels to all resources, add e2e test that validate the existence of the three labels #142
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
base: main
Are you sure you want to change the base?
Changes from all commits
9788816
52d10cf
3a3fa91
aaf05ab
ee4f3bc
37e41e9
807c5f9
1827784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| creationTimestamp: null | ||
| labels: | ||
| app.kubernetes.io/component: controller-manager | ||
| app.kubernetes.io/name: node-maintenance-operator | ||
| node-maintenance-operator: "" | ||
| name: node-maintenance-controller-manager-metrics-service | ||
| spec: | ||
| ports: | ||
| - name: https | ||
| port: 8443 | ||
| protocol: TCP | ||
| targetPort: https | ||
| selector: | ||
| app.kubernetes.io/component: controller-manager | ||
| app.kubernetes.io/name: node-maintenance-operator | ||
| node-maintenance-operator: "" | ||
| status: | ||
| loadBalancer: {} |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,9 @@ var _ = Describe("Starting Maintenance", func() { | |
| // it should be caused by the test deployment's termination graceperiod > drain timeout | ||
| Expect(getOperatorLogs()).To(ContainSubstring(nodemaintenance.FixedDurationReconcileLog)) | ||
|
|
||
| //validate that operator controller pod have app.kubernetes.io/name label | ||
| Expect(validateOperatorCustomLabels()).To(BeTrue(), "operator custom label validation failed") | ||
|
|
||
| By("node should be unschedulable and tainted node") | ||
| node := &corev1.Node{} | ||
| err = Client.Get(context.TODO(), types.NamespacedName{Namespace: "", Name: maintenanceNodeName}, node) | ||
|
|
@@ -419,6 +422,31 @@ func getOperatorPod() *corev1.Pod { | |
| return &pods.Items[0] | ||
| } | ||
|
|
||
| func validateOperatorCustomLabels() bool { | ||
|
|
||
| podOperator := getOperatorPod() | ||
| podName := podOperator.ObjectMeta.Name | ||
|
|
||
| // Get the Pod | ||
| pod, err := KubeClient.CoreV1().Pods(operatorNsName).Get(context.TODO(), podName, metav1.GetOptions{}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have the pod already, why getting it here again? |
||
| //pod, err := KubeClient.CoreV1().Pods(operatorNsName).List(context.Background(), metav1.ListOptions{LabelSelector: "app.kubernetes.io/name="}) | ||
|
|
||
| ExpectWithOffset(1, err).ToNot(HaveOccurred(), fmt.Sprintf("Failed to get pod '%s'", podName)) | ||
|
|
||
| // Labels to check for | ||
| requiredKeys := []string{"app.kubernetes.io/name", | ||
| "app.kubernetes.io/component", | ||
| "kubectl.kubernetes.io/default-container"} | ||
|
|
||
| // Check if each label is present | ||
| for _, key := range requiredKeys { | ||
| _, exists := pod.Labels[key] | ||
| ExpectWithOffset(1, exists).Should(BeTrue(), fmt.Sprintf("Missing required label '%s' in pod '%s'", key, podName)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a) you don't check label values anymore |
||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func isTainted(node *corev1.Node) bool { | ||
| medik8sDrainTaint := corev1.Taint{ | ||
| Key: "medik8s.io/drain", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the return value and checking it isn't needed IMHO, everything is checked inside the function already?