Skip to content

Commit

Permalink
Review 4 changes
Browse files Browse the repository at this point in the history
Signed-off-by: Kanha gupta <[email protected]>
  • Loading branch information
kanha-gupta committed May 9, 2024
1 parent 3087388 commit 0a0801f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
18 changes: 10 additions & 8 deletions pkg/antctl/raw/check/cluster/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (t *testContext) setup(ctx context.Context) error {
}
deployment := check.NewDeployment(check.DeploymentParameters{
Name: deploymentName,
Image: getImageVersion(),
Image: getAntreaAgentImage(),
Replicas: 1,
Command: []string{"bash", "-c"},
Args: []string{"trap 'exit 0' SIGTERM; sleep infinity & pid=$!; wait $pid"},
Expand Down Expand Up @@ -150,6 +150,9 @@ func (t *testContext) setup(ctx context.Context) error {
},
},
},
NodeSelector: map[string]string{
"kubernetes.io/os": "linux",
},
})

t.Log("Creating Deployment")
Expand All @@ -167,19 +170,18 @@ func (t *testContext) setup(ctx context.Context) error {
if err != nil {
return fmt.Errorf("unable to list test Pod: %s", err)
}
if len(testPods.Items) > 0 {
t.testPod = &testPods.Items[0]
if len(testPods.Items) == 0 {
return fmt.Errorf("unable to list pods")
}
t.testPod = &testPods.Items[0]
return nil
}

func getImageVersion() string {
if version.ReleaseStatus == "unreleased" {
return "antrea/antrea-agent-ubuntu:latest"
} else if version.ReleaseStatus == "released" {
func getAntreaAgentImage() string {
if version.ReleaseStatus == "released" {
return fmt.Sprintf("antrea/antrea-agent-ubuntu:%s", version.GetVersion())
}
return ""
return "antrea/antrea-agent-ubuntu:latest"
}

func NewTestContext(client kubernetes.Interface, config *rest.Config, clusterName string) *testContext {
Expand Down
25 changes: 12 additions & 13 deletions pkg/antctl/raw/check/cluster/test_checkcniexistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ func (t *checkCNIExistence) Run(ctx context.Context, testContext *testContext) e
if err != nil {
return fmt.Errorf("Failed to execute command in Pod %s, error: %v", testContext.testPod.Name, err)
}
outputStr := strings.TrimSpace(output)
if outputStr == "" {
files := strings.Fields(output)
if len(files) == 0 {
testContext.Log("No files present in /etc/cni/net.d in Node %s", testContext.testPod.Spec.NodeName)
} else {
files := strings.Split(outputStr, "\n")
sort.Strings(files)
if len(files) > 0 {
if files[0] < "10-antrea.conflist" {
return fmt.Errorf("Another CNI configuration file with higher priority than Antrea's CNI configuration file found: %s. Ignore this if PolicyOnly mode is enabled.", files[0])
} else if files[0] != "10-antrea.conflist" {
testContext.Log("Another CNI configuration file found: %s with Antrea having higher precedence", files[0])
} else {
testContext.Log("Antrea's CNI configuration file already present: %s", files[0])
}
return nil
}
sort.Strings(files)
if len(files) > 0 {
if files[0] < "10-antrea.conflist" {
return fmt.Errorf("Another CNI configuration file with higher priority than Antrea's CNI configuration file found: %s; this may be expected if networkPolicyOnly mode is enabled", files[0])
} else if files[0] != "10-antrea.conflist" {
testContext.Log("Another CNI configuration file found: %s with Antrea having higher precedence", files[0])
} else {
testContext.Log("Antrea's CNI configuration file already present: %s", files[0])
}
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/antctl/raw/check/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func NewDeployment(p DeploymentParameters) *appsv1.Deployment {
Labels: p.Labels,
},
Spec: corev1.PodSpec{
HostNetwork: p.HostNetwork,
HostNetwork: p.HostNetwork,
NodeSelector: p.NodeSelector,
Containers: []corev1.Container{
{
Name: p.Name,
Expand Down Expand Up @@ -176,6 +177,7 @@ type DeploymentParameters struct {
VolumeMounts []corev1.VolumeMount
Volumes []corev1.Volume
HostNetwork bool
NodeSelector map[string]string
}

func WaitForDeploymentsReady(ctx context.Context,
Expand Down

0 comments on commit 0a0801f

Please sign in to comment.