Skip to content
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
3 changes: 3 additions & 0 deletions pkg/cli/admin/nodeimage/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@ func (o *CreateOptions) createPod(ctx context.Context) error {
Labels: map[string]string{
"app": "node-joiner",
},
Annotations: map[string]string{
"openshift.io/required-scc": "restricted-v2",
},
},
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyNever,
Expand Down
12 changes: 12 additions & 0 deletions pkg/cli/admin/nodeimage/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ func TestRun(t *testing.T) {
objects: ClusterVersion_4_17_ObjectFn,
remoteExecOutput: "0",
},
{
name: "node-joiner pod has required-scc annotation",
nodesConfig: defaultNodesConfigYaml,
objects: defaultClusterVersionObjectFn,
expectedPod: func(t *testing.T, pod *corev1.Pod) {
expected := "restricted-v2"
got := pod.Annotations["openshift.io/required-scc"]
if got != expected {
t.Errorf("annotation openshift.io/required-scc = %q, want %q", got, expected)
}
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/admin/nodeimage/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ func (o *MonitorOptions) createPod(ctx context.Context) error {
Labels: map[string]string{
"app": "node-joiner-monitor",
},
Annotations: map[string]string{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if a similar test for monitor can be created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added missing test , and test is verified

"openshift.io/required-scc": "restricted-v2",
},
},
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyNever,
Expand Down
17 changes: 17 additions & 0 deletions pkg/cli/admin/nodeimage/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nodeimage
import (
"bytes"
fakeoperatorconfig "github.com/openshift/client-go/operator/clientset/versioned/fake"
corev1 "k8s.io/api/core/v1"
"strings"
"testing"

Expand Down Expand Up @@ -73,6 +74,7 @@ func TestMonitorRun(t *testing.T) {
remoteExecOutput string

expectedError string
expectedPod func(t *testing.T, pod *corev1.Pod)
}{
{
name: "default",
Expand All @@ -82,6 +84,17 @@ func TestMonitorRun(t *testing.T) {
name: "missing cluster connection",
expectedError: `command expects a connection to an OpenShift 4.x server`,
},
{
name: "node-joiner monitor pod has required-scc annotation",
objects: defaultClusterVersionObjectFn,
expectedPod: func(t *testing.T, pod *corev1.Pod) {
expected := "restricted-v2"
got := pod.Annotations["openshift.io/required-scc"]
if got != expected {
t.Errorf("annotation openshift.io/required-scc = %q, want %q", got, expected)
}
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -134,6 +147,10 @@ func TestMonitorRun(t *testing.T) {
t.Errorf("expected %v, actual %v", fakeLogContent, logContents.String())
}
}
if tc.expectedPod != nil {
pod := getTestPod(fakeClient, nodeJoinerMonitorContainer)
tc.expectedPod(t, pod)
}
})
}
}