Skip to content

Commit

Permalink
Improve labels for antctl check framework (#6341)
Browse files Browse the repository at this point in the history
Signed-off-by: Kanha gupta <[email protected]>
  • Loading branch information
kanha-gupta authored May 22, 2024
1 parent 68cb92f commit ee6fd52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/antctl/raw/check/cluster/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func Run() error {

func (t *testContext) setup(ctx context.Context) error {
t.Log("Creating Namespace %s for pre installation tests...", t.namespace)
_, err := t.client.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: t.namespace}}, metav1.CreateOptions{})
_, err := t.client.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: t.namespace, Labels: map[string]string{"app": "antrea", "component": "cluster-checker"}}}, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("unable to create Namespace %s: %s", t.namespace, err)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/antctl/raw/check/installation/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (t *testContext) setup(ctx context.Context) error {
return fmt.Errorf("unable to determine status of Antrea DaemonSet: %w", err)
}
t.Log("Creating Namespace %s for post installation tests...", t.namespace)
_, err = t.client.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: t.namespace}}, metav1.CreateOptions{})
_, err = t.client.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: t.namespace, Labels: map[string]string{"app": "antrea", "component": "installation-checker"}}}, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("unable to create Namespace %s: %s", t.namespace, err)
}
Expand All @@ -211,7 +211,7 @@ func (t *testContext) setup(ctx context.Context) error {
Effect: "NoSchedule",
},
}
echoDeployment := check.NewDeployment(check.DeploymentParameters{
echoSameNodeDeployment := check.NewDeployment(check.DeploymentParameters{
Name: echoSameNodeDeploymentName,
Role: kindEchoName,
Port: 80,
Expand All @@ -236,9 +236,9 @@ func (t *testContext) setup(ctx context.Context) error {
},
},
Tolerations: commonToleration,
Labels: map[string]string{"app": echoSameNodeDeploymentName},
Labels: map[string]string{"app": "antrea", "component": "installation-checker", "name": echoSameNodeDeploymentName},
})
_, err = t.client.AppsV1().Deployments(t.namespace).Create(ctx, echoDeployment, metav1.CreateOptions{})
_, err = t.client.AppsV1().Deployments(t.namespace).Create(ctx, echoSameNodeDeployment, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("unable to create Deployment %s: %s", echoSameNodeDeploymentName, err)
}
Expand All @@ -250,7 +250,7 @@ func (t *testContext) setup(ctx context.Context) error {
Command: []string{"/agnhost", "pause"},
Port: 80,
Tolerations: commonToleration,
Labels: map[string]string{"app": clientDeploymentName},
Labels: map[string]string{"app": "antrea", "component": "installation-checker", "name": clientDeploymentName},
})
_, err = t.client.AppsV1().Deployments(t.namespace).Create(ctx, clientDeployment, metav1.CreateOptions{})
if err != nil {
Expand All @@ -277,7 +277,7 @@ func (t *testContext) setup(ctx context.Context) error {
},
},
Tolerations: commonToleration,
Labels: map[string]string{"app": echoOtherNodeDeploymentName},
Labels: map[string]string{"app": "antrea", "component": "installation-checker", "name": echoOtherNodeDeploymentName},
})
nodes, err := t.client.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
Expand Down Expand Up @@ -310,7 +310,7 @@ func (t *testContext) setup(ctx context.Context) error {
return err
}
}
podList, err := t.client.CoreV1().Pods(t.namespace).List(ctx, metav1.ListOptions{LabelSelector: "kind=" + kindClientName})
podList, err := t.client.CoreV1().Pods(t.namespace).List(ctx, metav1.ListOptions{LabelSelector: "name=" + clientDeploymentName})
if err != nil {
return fmt.Errorf("unable to list client Pods: %s", err)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/antctl/raw/check/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ func NewDeployment(p DeploymentParameters) *appsv1.Deployment {
if p.Labels == nil {
p.Labels = make(map[string]string)
}
p.Labels["name"] = p.Name
p.Labels["kind"] = p.Role
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: p.Name,
Expand Down

0 comments on commit ee6fd52

Please sign in to comment.