Skip to content

Commit

Permalink
OCPBUGS-6701: ingressclass: Avoid spurious updates for scope
Browse files Browse the repository at this point in the history
Specify spec.parameters.scope on ingressclasses that the operator creates.

Before this commit, the update logic would try to revert the default value
that the API set for an ingressclass's scope field.

* pkg/operator/controller/ingressclass/ingressclass.go
(desiredIngressClass): Specify spec.parameters.scope with the default
value: "Cluster".
* pkg/operator/controller/ingressclass/ingressclass_test.go
(Test_desiredIngressClass): Update test to expect spec.parameters.scope
to be set.
  • Loading branch information
Miciah authored and gcs278 committed Jan 27, 2023
1 parent b086fd1 commit 739e3ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/operator/controller/ingressclass/ingressclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func desiredIngressClass(haveIngressController bool, ingressControllerName strin
}

name := controller.IngressClassName(ingressControllerName)
scope := networkingv1.IngressClassParametersReferenceScopeCluster
class := &networkingv1.IngressClass{
ObjectMeta: metav1.ObjectMeta{
Name: name.Name,
Expand All @@ -88,6 +89,7 @@ func desiredIngressClass(haveIngressController bool, ingressControllerName strin
APIGroup: &operatorv1.GroupName,
Kind: "IngressController",
Name: ingressControllerName,
Scope: &scope,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/controller/ingressclass/ingressclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// TestDesiredIngressClass verifies that desiredIngressClass behaves as
// expected.
func TestDesiredIngressClass(t *testing.T) {
scope := "Cluster"
makeIngressClass := func(icName string, annotateAsDefault bool) *networkingv1.IngressClass {
apiGroup := "operator.openshift.io"
name := "openshift-" + icName
Expand All @@ -27,6 +28,7 @@ func TestDesiredIngressClass(t *testing.T) {
APIGroup: &apiGroup,
Kind: "IngressController",
Name: icName,
Scope: &scope,
},
},
}
Expand Down

0 comments on commit 739e3ed

Please sign in to comment.