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

ACM-12773: Fix clusterVersion check for OCP3 #1531

Merged

Conversation

thibaultmg
Copy link
Contributor

@thibaultmg thibaultmg commented Jul 17, 2024

OCP 3.x spokes do not have the ClusterVersion CRD. In such a case, the kube-api client returns an error of type NoMatchError. This error is now properly checked and results in a simple Info log.
I have kept the case NotFoundError that will also result in a simple log. Just in case we have an OCP 3 spoke with this CRD 🤷
All other error types will return an error.
Unit tests for these OCP 3 cases have been added (NotFound was already tested but it is not the observed behavior which is NoMatch).

@thibaultmg
Copy link
Contributor Author

/cherrypick release-2.11

@openshift-cherrypick-robot
Copy link
Collaborator

@thibaultmg: once the present PR merges, I will cherry-pick it on top of release-2.11 in a new PR and assign it to you.

In response to this:

/cherrypick release-2.11

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@thibaultmg thibaultmg changed the title Fix clusterVersion check for OCP3 ACM-12773: Fix clusterVersion check for OCP3 Jul 17, 2024
Copy link
Contributor

@moadz moadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci openshift-ci bot added the lgtm label Jul 17, 2024
@thibaultmg thibaultmg force-pushed the fix_ocp3_clusterversion branch from 386cef4 to 4cbaacf Compare July 17, 2024 08:23
@openshift-ci openshift-ci bot removed the lgtm label Jul 17, 2024
Copy link
Contributor

@moadz moadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci openshift-ci bot added the lgtm label Jul 17, 2024
Signed-off-by: Thibault Mange <[email protected]>
@thibaultmg thibaultmg force-pushed the fix_ocp3_clusterversion branch from 4cbaacf to ce76105 Compare July 17, 2024 12:33
@openshift-ci openshift-ci bot removed the lgtm label Jul 17, 2024
Copy link

Copy link
Contributor

@moadz moadz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you for the quick turnaround.

Comment on lines +415 to +477
hubObjs := []runtime.Object{
newObservabilityAddon(name, testHubNamspace),
}
hubInfo := newHubInfoSecret(hubInfoData, testNamespace)
amAccessSrt := newAMAccessorSecret(testNamespace)
allowList := getAllowlistCM()
images := newImagesCM(testNamespace)
objs := []runtime.Object{hubInfo, amAccessSrt, allowList, images, infra,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "extension-apiserver-authentication",
Namespace: "kube-system",
},
Data: map[string]string{
"client-ca-file": "test",
},
},
&corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-ns",
},
},
newObservabilityAddon(name, testNamespace),
newPromSvc(),
}

scheme := scheme.Scheme
addonv1alpha1.AddToScheme(scheme)
mcov1beta2.AddToScheme(scheme)
oav1beta1.AddToScheme(scheme)
corev1.AddToScheme(scheme)
clusterv1.AddToScheme(scheme)
ocinfrav1.AddToScheme(scheme)

hubClient := fake.NewClientBuilder().
WithScheme(scheme).
WithRuntimeObjects(hubObjs...).
WithStatusSubresource(
&addonv1alpha1.ManagedClusterAddOn{},
&mcov1beta2.MultiClusterObservability{},
&oav1beta1.ObservabilityAddon{},
).
Build()

var errClientGetInterceptor error

c := fake.NewClientBuilder().
WithScheme(scheme).
WithRuntimeObjects(objs...).
WithStatusSubresource(
&addonv1alpha1.ManagedClusterAddOn{},
&mcov1beta2.MultiClusterObservability{},
&oav1beta1.ObservabilityAddon{},
).
WithInterceptorFuncs(interceptor.Funcs{
Get: func(ctx context.Context, client client.WithWatch, key types.NamespacedName, obj client.Object, opts ...client.GetOption) error {
if _, ok := obj.(*ocinfrav1.ClusterVersion); ok {
return errClientGetInterceptor
}
return client.Get(ctx, key, obj, opts...)
},
}).
Build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: makes sense for test cleanliness that we spin this out to a helper function, afaics the objects are the only things that differ between the two (barring the interceptor funcs which can be parameterised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree. The PR is merged, will come in another PR where I'm refactoring e2e.

@openshift-ci openshift-ci bot added the lgtm label Jul 17, 2024
Copy link

openshift-ci bot commented Jul 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: moadz, thibaultmg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 64d4922 into stolostron:main Jul 17, 2024
16 checks passed
@openshift-cherrypick-robot
Copy link
Collaborator

@thibaultmg: new pull request created: #1532

In response to this:

/cherrypick release-2.11

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants