Skip to content

Commit

Permalink
Add 'transient' label to pods deployed during diagnose test
Browse files Browse the repository at this point in the history
Subctl diagnose has a test that looks up for the pod's status
Thus, transient pods should be labeled and ignored from this test

Signed-off-by: Tomer Shefler <[email protected]>
  • Loading branch information
tomer-shefler authored and tpantelis committed Aug 30, 2022
1 parent c7b1908 commit 5122d9b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ const (
SubmarinerNamespace = "submariner-operator"
SubmarinerNotInstalled = "Submariner is not installed"
ServiceDiscoveryNotInstalled = "Service discovery is not installed"
TransientLabel = "submariner.io/transient"
TrueLabel = "true"
)
3 changes: 2 additions & 1 deletion internal/pods/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ func (np *Scheduled) schedule() error {
ObjectMeta: metav1.ObjectMeta{
GenerateName: np.Config.Name,
Labels: map[string]string{
"app": np.Config.Name,
"app": np.Config.Name,
constants.TransientLabel: constants.TrueLabel,
},
},
Spec: v1.PodSpec{
Expand Down
5 changes: 4 additions & 1 deletion pkg/diagnose/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package diagnose

import (
"context"
"fmt"

"github.com/submariner-io/admiral/pkg/reporter"
"github.com/submariner-io/subctl/internal/constants"
Expand Down Expand Up @@ -173,7 +174,9 @@ func checkDaemonset(k8sClient kubernetes.Interface, namespace, daemonSetName str
}

func checkPodsStatus(k8sClient kubernetes.Interface, namespace string, status reporter.Interface) {
pods, err := k8sClient.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{})
pods, err := k8sClient.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s!=%s", constants.TransientLabel, constants.TrueLabel),
})
if err != nil {
status.Failure("Error obtaining Pods list: %v", err)
return
Expand Down

0 comments on commit 5122d9b

Please sign in to comment.