-
Notifications
You must be signed in to change notification settings - Fork 68
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
ACM-12773: Fix clusterVersion check for OCP3 #1531
Conversation
/cherrypick release-2.11 |
@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:
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. |
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.
LGTM
386cef4
to
4cbaacf
Compare
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.
LGTM
Signed-off-by: Thibault Mange <[email protected]>
4cbaacf
to
ce76105
Compare
Quality Gate passedIssues Measures |
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.
LGTM thank you for the quick turnaround.
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() |
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.
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.
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.
Yes I agree. The PR is merged, will come in another PR where I'm refactoring e2e.
[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 |
@thibaultmg: new pull request created: #1532 In response to this:
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. |
OCP 3.x spokes do not have the ClusterVersion CRD. In such a case, the
kube-api
client returns an error of typeNoMatchError
. This error is now properly checked and results in a simpleInfo
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 isNoMatch
).