Skip to content
Open
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
4 changes: 3 additions & 1 deletion pkg/canary/scaled_object_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ func setPrimaryScaledObjectQueries(cd *flaggerv1.Canary, triggers []keda.ScaleTr
}

func makeObjectMetaSo(name string, labels map[string]string, annotations map[string]string, cd *flaggerv1.Canary) metav1.ObjectMeta {
filteredAnnotations := filterMetadata(annotations)
delete(filteredAnnotations, keda.PausedReplicasAnnotation)
return metav1.ObjectMeta{
Name: name,
Namespace: cd.Namespace,
Labels: filterMetadata(labels),
Annotations: filterMetadata(annotations),
Annotations: filteredAnnotations,
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(cd, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down
4 changes: 4 additions & 0 deletions pkg/canary/scaled_object_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ func Test_reconcilePrimaryScaledObject(t *testing.T) {

so, err := mocks.flaggerClient.KedaV1alpha1().ScaledObjects("default").Get(context.TODO(), "podinfo", metav1.GetOptions{})
require.NoError(t, err)
so.Annotations[keda.PausedReplicasAnnotation] = "0"
_, err = mocks.flaggerClient.KedaV1alpha1().ScaledObjects("default").Update(context.TODO(), so, metav1.UpdateOptions{})
require.NoError(t, err)

err = soReconciler.reconcilePrimaryScaler(mocks.canary, true)
require.NoError(t, err)

primarySO, err := mocks.flaggerClient.KedaV1alpha1().ScaledObjects("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{})
require.NoError(t, err)
assert.NotContains(t, primarySO.Annotations, keda.PausedReplicasAnnotation)
// test that the hpa ownership annotation is added to the primarySO
assert.Equal(t, primarySO.ObjectMeta.Annotations["scaledobject.keda.sh/transfer-hpa-ownership"], "true")
// test that the horizontalpodautoscalerconfig is set to 'podinfo-primary', so that it takes over ownership of the HPA
Expand Down