Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a PriorityClass #148

Merged
merged 8 commits into from
Sep 26, 2023
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
1 change: 1 addition & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

resources:
- manager.yaml
- priority-class.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
Expand Down
7 changes: 7 additions & 0 deletions config/manager/priority-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: manager-priority-class
value: 2000000
globalDefault: false
description: "Scheduling priority of the NATS-Manager module. Must not be blocked by unschedulable user workloads."
1 change: 1 addition & 0 deletions e2e/common/fixtures/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
FileStorageSize = "1Gi"
MemStorageSize = "1Gi"
True = "true"
PriorityClassName = "nats-manager-priority-class"
)

func NATSCR() *natsv1alpha1.NATS {
Expand Down
32 changes: 30 additions & 2 deletions e2e/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (

// Constants for retries.
const (
interval = 2 * time.Second
attempts = 60
interval = 3 * time.Second
attempts = 120
)

// clientSet is what is used to access K8s build-in resources like Pods, Namespaces and so on.
Expand Down Expand Up @@ -128,6 +128,34 @@ func Test_CR(t *testing.T) {
)
}

// Test_PriorityClass will get the PriorityClass name from the StatefulSet and checks if a PriorityClass with that
// name exists in the cluster.
func Test_PriorityClass(t *testing.T) {
ctx := context.TODO()

err := Retry(attempts, interval, func() error {
sts, stsErr := clientSet.AppsV1().StatefulSets(NamespaceName).Get(ctx, STSName, metav1.GetOptions{})
if stsErr != nil {
return stsErr
}

pcName := sts.Spec.Template.Spec.PriorityClassName
// todo remove this check after the next release.
if len(pcName) < 1 {
mfaizanse marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

if pcName != PriorityClassName {
return fmt.Errorf("PriorityClassName was expected to be %s but was %s", PriorityClassName, pcName)
}

_, pcErr := clientSet.SchedulingV1().PriorityClasses().Get(ctx, pcName, metav1.GetOptions{})
return pcErr
})

require.NoError(t, err)
}

// Test_ConfigMap tests the ConfigMap that the NATS-Manger creates when we define a CR.
func Test_ConfigMap(t *testing.T) {
ctx := context.TODO()
Expand Down
2 changes: 2 additions & 0 deletions resources/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ global:
# when replacing pods on nodes, or when scaling down.
podManagementPolicy: Parallel

priorityClassName: "nats-manager-priority-class"

####################################
# #
# Security Context Configuration #
Expand Down