-
Notifications
You must be signed in to change notification settings - Fork 551
Add PriorityClass setting to registry pods for CatalogSource via annotations #2304
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,6 +339,74 @@ func TestGrpcRegistryReconciler(t *testing.T) { | |
} | ||
} | ||
|
||
func TestRegistryPodPriorityClass(t *testing.T) { | ||
now := func() metav1.Time { return metav1.Date(2018, time.January, 26, 20, 40, 0, 0, time.UTC) } | ||
|
||
type cluster struct { | ||
k8sObjs []runtime.Object | ||
} | ||
type in struct { | ||
cluster cluster | ||
catsrc *v1alpha1.CatalogSource | ||
} | ||
tests := []struct { | ||
testName string | ||
in in | ||
priorityclass string | ||
}{ | ||
{ | ||
testName: "Grpc/WithValidPriorityClassAnnotation", | ||
in: in{ | ||
catsrc: grpcCatalogSourceWithAnnotations(map[string]string{ | ||
"operatorframework.io/priorityclass": "system-cluster-critical", | ||
}), | ||
}, | ||
priorityclass: "system-cluster-critical", | ||
}, | ||
{ | ||
testName: "Grpc/WithInvalidPriorityClassAnnotation", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (not blocking) Technically not invalid but we won't propagate any empty key value to the priorityclass default. |
||
in: in{ | ||
catsrc: grpcCatalogSourceWithAnnotations(map[string]string{ | ||
"operatorframework.io/priorityclass": "", | ||
}), | ||
}, | ||
priorityclass: "", | ||
}, | ||
{ | ||
testName: "Grpc/WithNoPriorityClassAnnotation", | ||
in: in{ | ||
catsrc: grpcCatalogSourceWithAnnotations(map[string]string{ | ||
"annotationkey": "annotationvalue", | ||
}), | ||
}, | ||
priorityclass: "", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.testName, func(t *testing.T) { | ||
stopc := make(chan struct{}) | ||
defer close(stopc) | ||
timflannagan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
factory, client := fakeReconcilerFactory(t, stopc, withNow(now), withK8sObjs(tt.in.cluster.k8sObjs...), withK8sClientOptions(clientfake.WithNameGeneration(t))) | ||
rec := factory.ReconcilerForSource(tt.in.catsrc) | ||
|
||
err := rec.EnsureRegistryServer(tt.in.catsrc) | ||
require.NoError(t, err) | ||
|
||
// Check for resource existence | ||
decorated := grpcCatalogSourceDecorator{tt.in.catsrc} | ||
pod := decorated.Pod(tt.in.catsrc.GetName()) | ||
listOptions := metav1.ListOptions{LabelSelector: labels.SelectorFromSet(labels.Set{CatalogSourceLabelKey: tt.in.catsrc.GetName()}).String()} | ||
outPods, podErr := client.KubernetesInterface().CoreV1().Pods(pod.GetNamespace()).List(context.TODO(), listOptions) | ||
require.NoError(t, podErr) | ||
require.Len(t, outPods.Items, 1) | ||
outPod := outPods.Items[0] | ||
require.Equal(t, tt.priorityclass, outPod.Spec.PriorityClassName) | ||
require.Equal(t, pod.GetLabels()[PodHashLabelKey], outPod.GetLabels()[PodHashLabelKey]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not super concerned with blindingly indexing like this, but it might produce test flakes down the line. |
||
}) | ||
} | ||
} | ||
|
||
func TestGrpcRegistryChecker(t *testing.T) { | ||
type cluster struct { | ||
k8sObjs []runtime.Object | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not technically what I had in mind but works for now 😆