-
Notifications
You must be signed in to change notification settings - Fork 516
OCPBUGS-88757: Align HCCO CatalogSource registryPoll interval with OCP defaults #8745
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
Open
shijadha
wants to merge
1
commit into
openshift:main
Choose a base branch
from
shijadha:fix-catalogsource-poll-interval
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+166
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
...rol-plane-operator/hostedclusterconfigoperator/controllers/resources/olm/catalogs_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| package olm | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| . "github.com/onsi/gomega" | ||
|
|
||
| hyperv1 "github.com/openshift/hypershift/api/hypershift/v1beta1" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
| ) | ||
|
|
||
| func TestReconcileCertifiedOperatorsCatalogSource(t *testing.T) { | ||
| testsCases := []struct { | ||
| name string | ||
| placement hyperv1.OLMCatalogPlacement | ||
| params *OperatorLifecycleManagerParams | ||
| }{ | ||
| { | ||
| name: "when placement is Management it should set Address", | ||
| placement: hyperv1.ManagementOLMCatalogPlacement, | ||
| params: &OperatorLifecycleManagerParams{ | ||
| CertifiedOperatorsImage: "registry.example.com/certified:latest", | ||
| OLMCatalogPlacement: hyperv1.ManagementOLMCatalogPlacement, | ||
| }, | ||
| }, | ||
| { | ||
| name: "when placement is Guest it should set Image", | ||
| placement: hyperv1.GuestOLMCatalogPlacement, | ||
| params: &OperatorLifecycleManagerParams{ | ||
| CertifiedOperatorsImage: "registry.example.com/certified:latest", | ||
| OLMCatalogPlacement: hyperv1.GuestOLMCatalogPlacement, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testsCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| g := NewWithT(t) | ||
| cs := &operatorsv1alpha1.CatalogSource{} | ||
|
|
||
| ReconcileCertifiedOperatorsCatalogSource(cs, tc.params) | ||
|
|
||
| // Verify common fields | ||
| g.Expect(cs.Spec.SourceType).To(Equal(operatorsv1alpha1.SourceTypeGrpc)) | ||
| g.Expect(cs.Spec.DisplayName).To(Equal("Certified Operators")) | ||
| g.Expect(cs.Spec.Publisher).To(Equal("Red Hat")) | ||
| g.Expect(cs.Spec.Priority).To(Equal(-200)) | ||
| g.Expect(cs.Spec.GrpcPodConfig.SecurityContextConfig).To(Equal(operatorsv1alpha1.Restricted)) | ||
| g.Expect(cs.Annotations).To(HaveKeyWithValue("target.workload.openshift.io/management", `{"effect": "PreferredDuringScheduling"}`)) | ||
|
|
||
| // Verify RegistryPoll interval is 240 minutes | ||
| g.Expect(cs.Spec.UpdateStrategy).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.RawInterval).To(Equal("240m")) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval.Duration).To(Equal(240 * time.Minute)) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| // Verify placement-specific fields | ||
| if tc.placement == hyperv1.ManagementOLMCatalogPlacement { | ||
| g.Expect(cs.Spec.Address).To(Equal("certified-operators:50051")) | ||
| g.Expect(cs.Spec.Image).To(BeEmpty()) | ||
| } else { | ||
| g.Expect(cs.Spec.Image).To(Equal("registry.example.com/certified:latest")) | ||
| g.Expect(cs.Spec.Address).To(BeEmpty()) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestReconcileCommunityOperatorsCatalogSource(t *testing.T) { | ||
| g := NewWithT(t) | ||
|
|
||
| params := &OperatorLifecycleManagerParams{ | ||
| CommunityOperatorsImage: "registry.example.com/community:latest", | ||
| OLMCatalogPlacement: hyperv1.GuestOLMCatalogPlacement, | ||
| } | ||
|
|
||
| cs := &operatorsv1alpha1.CatalogSource{} | ||
| ReconcileCommunityOperatorsCatalogSource(cs, params) | ||
|
|
||
| // Verify RegistryPoll interval is 240 minutes | ||
| g.Expect(cs.Spec.UpdateStrategy).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.RawInterval).To(Equal("240m")) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval.Duration).To(Equal(240 * time.Minute)) | ||
|
|
||
| g.Expect(cs.Spec.DisplayName).To(Equal("Community Operators")) | ||
| g.Expect(cs.Spec.Priority).To(Equal(-400)) | ||
| g.Expect(cs.Spec.Image).To(Equal("registry.example.com/community:latest")) | ||
| } | ||
|
|
||
| func TestReconcileRedHatMarketplaceCatalogSource(t *testing.T) { | ||
| g := NewWithT(t) | ||
|
|
||
| params := &OperatorLifecycleManagerParams{ | ||
| RedHatMarketplaceImage: "registry.example.com/marketplace:latest", | ||
| OLMCatalogPlacement: hyperv1.ManagementOLMCatalogPlacement, | ||
| } | ||
|
|
||
| cs := &operatorsv1alpha1.CatalogSource{} | ||
| ReconcileRedHatMarketplaceCatalogSource(cs, params) | ||
|
|
||
| // Verify RegistryPoll interval is 240 minutes | ||
| g.Expect(cs.Spec.UpdateStrategy).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.RawInterval).To(Equal("240m")) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval.Duration).To(Equal(240 * time.Minute)) | ||
|
|
||
| g.Expect(cs.Spec.DisplayName).To(Equal("Red Hat Marketplace")) | ||
| g.Expect(cs.Spec.Priority).To(Equal(-300)) | ||
| g.Expect(cs.Spec.Address).To(Equal("redhat-marketplace:50051")) | ||
| } | ||
|
|
||
| func TestReconcileRedHatOperatorsCatalogSource(t *testing.T) { | ||
| g := NewWithT(t) | ||
|
|
||
| params := &OperatorLifecycleManagerParams{ | ||
| RedHatOperatorsImage: "registry.example.com/redhat-operators:latest", | ||
| OLMCatalogPlacement: hyperv1.GuestOLMCatalogPlacement, | ||
| } | ||
|
|
||
| cs := &operatorsv1alpha1.CatalogSource{} | ||
| ReconcileRedHatOperatorsCatalogSource(cs, params) | ||
|
|
||
| // Verify RegistryPoll interval is 240 minutes | ||
| g.Expect(cs.Spec.UpdateStrategy).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval).ToNot(BeNil()) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.RawInterval).To(Equal("240m")) | ||
| g.Expect(cs.Spec.UpdateStrategy.RegistryPoll.Interval.Duration).To(Equal(240 * time.Minute)) | ||
|
|
||
| g.Expect(cs.Spec.DisplayName).To(Equal("Red Hat Operators")) | ||
| g.Expect(cs.Spec.Priority).To(Equal(-100)) | ||
| g.Expect(cs.Spec.Image).To(Equal("registry.example.com/redhat-operators:latest")) | ||
| } | ||
|
|
||
| func TestReconcileCatalogSourcePreservesExistingAnnotations(t *testing.T) { | ||
| g := NewWithT(t) | ||
|
|
||
| params := &OperatorLifecycleManagerParams{ | ||
| RedHatOperatorsImage: "registry.example.com/redhat-operators:latest", | ||
| OLMCatalogPlacement: hyperv1.GuestOLMCatalogPlacement, | ||
| } | ||
|
|
||
| cs := &operatorsv1alpha1.CatalogSource{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Annotations: map[string]string{ | ||
| "existing-annotation": "existing-value", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| ReconcileRedHatOperatorsCatalogSource(cs, params) | ||
|
|
||
| // Verify existing annotation is preserved and management annotation is added | ||
| g.Expect(cs.Annotations).To(HaveKeyWithValue("existing-annotation", "existing-value")) | ||
| g.Expect(cs.Annotations).To(HaveKeyWithValue("target.workload.openshift.io/management", `{"effect": "PreferredDuringScheduling"}`)) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.