Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Remove priorityclass from helper pods (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
croomes committed Mar 23, 2021
1 parent 08bd9f0 commit f66ae8b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
1 change: 0 additions & 1 deletion pkg/storageos/csi_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (s Deployment) createCSIHelperDeployment(replicas int32) error {
// common pod properties are common for all the pods that are part of storageos
// deployment, including the CSI helpers pod.
func (s Deployment) addCommonPodProperties(podSpec *corev1.PodSpec) error {
s.addPodPriorityClass(podSpec)
s.addNodeAffinity(podSpec)

// Add helper tolerations.
Expand Down
48 changes: 30 additions & 18 deletions pkg/storageos/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1582,31 +1582,37 @@ func TestDeployTLSEtcdCerts(t *testing.T) {
}

// TestDeployPodPriorityClass tests that the pod priority class is set properly
// for the daemonset and statefulset pods when deployed in kube-system
// namespace.
// for the daemonset when deployed in kube-system namespace.
func TestDeployPodPriorityClass(t *testing.T) {
testCases := []struct {
name string
resourceNS string
csiDeploymentStrategy string
wantPriorityClass bool
}{
{
name: "have priority class set | CSI Deployment",
resourceNS: "kube-system",
csiDeploymentStrategy: "deployment",
wantPriorityClass: true,
},
{
name: "have priority class set | CSI StatefulSet",
resourceNS: "kube-system",
csiDeploymentStrategy: "statefulset",
wantPriorityClass: true,
},
{
name: "have priority class set | CSI Deployment",
resourceNS: "kube-system",
name: "no priority class set | CSI Deployment",
resourceNS: "storageos",
csiDeploymentStrategy: "deployment",
wantPriorityClass: true,
wantPriorityClass: false,
},
{
name: "no priority class set",
resourceNS: "storageos",
wantPriorityClass: false,
name: "no priority class set | CSI StatefulSet",
resourceNS: "storageos",
csiDeploymentStrategy: "statefulset",
wantPriorityClass: false,
},
}

Expand Down Expand Up @@ -1694,12 +1700,8 @@ func TestDeployPodPriorityClass(t *testing.T) {
csiHelperPC = createdStatefulset.Spec.Template.Spec.PriorityClassName
}

if tc.wantPriorityClass && csiHelperPC != criticalPriorityClass {
t.Errorf("unexpected CSI helper pod priority class:\n\t(GOT) %v \n\t(WNT) %v", daemonsetPC, criticalPriorityClass)
}

if !tc.wantPriorityClass && csiHelperPC != "" {
t.Errorf("expected CSI helper priority class to be not set")
if csiHelperPC != "" {
t.Errorf("unexpected CSI helper pod priority class:\n\t(GOT) %v \n\t(WNT) %v", csiHelperPC, "")
}

// Check pod priority class for the api-manager.
Expand All @@ -1712,12 +1714,22 @@ func TestDeployPodPriorityClass(t *testing.T) {
t.Fatal("failed to get the created api-manager deployment", err)
}
apiManagerPC := createdAPIManagerDeployment.Spec.Template.Spec.PriorityClassName
if tc.wantPriorityClass && apiManagerPC != criticalPriorityClass {
t.Errorf("unexpected api-manager pod priority class:\n\t(GOT) %v \n\t(WNT) %v", apiManagerPC, criticalPriorityClass)
if apiManagerPC != "" {
t.Errorf("unexpected api-manager pod priority class:\n\t(GOT) %v \n\t(WNT) %v", apiManagerPC, "")
}

if !tc.wantPriorityClass && apiManagerPC != "" {
t.Errorf("expected api-manager priority class to be not set")
// Check pod priority class for the scheduler.
createdSchedulerDeployment := &appsv1.Deployment{}
nsNameSchedulerDeployment := types.NamespacedName{
Name: SchedulerExtenderName,
Namespace: stosCluster.Spec.GetResourceNS(),
}
if err := c.Get(context.Background(), nsNameSchedulerDeployment, createdSchedulerDeployment); err != nil {
t.Fatal("failed to get the created scheduler deployment", err)
}
schedulerPC := createdSchedulerDeployment.Spec.Template.Spec.PriorityClassName
if schedulerPC != "" {
t.Errorf("unexpected scheduler pod priority class:\n\t(GOT) %v \n\t(WNT) %v", schedulerPC, "")
}
})
}
Expand Down

0 comments on commit f66ae8b

Please sign in to comment.