-
Notifications
You must be signed in to change notification settings - Fork 256
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
Add e2e test to cover region in providerID clusterv1 machine object #2210
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @MatthieuFin. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/ok-to-test |
8723acf
to
902e688
Compare
Outch, I thinked that CAPO_REGION env variable will be set by https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/templates/env.rc#L89 but it seems not, personally I run tests by setting my own CAPO_REGION variable with my region name. |
0bf46aa
to
b5fa8d3
Compare
/unhold |
@@ -391,6 +391,9 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope | |||
Address: instanceStatus.Name(), | |||
}) | |||
openStackMachine.Status.Addresses = addresses | |||
if openStackMachine.Spec.IdentityRef == nil { |
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.
I'm curious why you need to do that here. We already do it here:
https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/2210/files#diff-e0a0984c0e26655878e2f94623fbf8cddb4d8a89e3443c1296dfaadc8802838aR578-R583
I'll like to avoid dupplications.
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.
function getOrCreateMachineServer
build an openStackServer object, that's not the purpose of this context so I didn't think to use it like that.
Do you think that this way is a better approach ?
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.
No it's not a better approach I think.
However moving the code to a separated function and use it in both places seems a good idea. We share the logic in case it has to change one day.
Thanks for trying that.
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.
Obviously it seems to make sens, I'll take a look on this way.
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.
test/e2e/data/kustomize/providerID-with-region-default/kustomization.yaml
Outdated
Show resolved
Hide resolved
...e/data/kustomize/providerID-with-region-default/patch-kubeadm-control-plane-provider-id.yaml
Outdated
Show resolved
Hide resolved
...data/kustomize/providerID-with-region-default/patch-kubeadm-config-template-provider-id.yaml
Outdated
Show resolved
Hide resolved
...a/kustomize/providerID-with-region-default/patch-openstack-machine-template-identityRef.yaml
Outdated
Show resolved
Hide resolved
test/e2e/data/kustomize/providerID-with-region-override/kustomization.yaml
Outdated
Show resolved
Hide resolved
...ata/kustomize/providerID-with-region-override/patch-kubeadm-config-template-provider-id.yaml
Outdated
Show resolved
Hide resolved
.../data/kustomize/providerID-with-region-override/patch-kubeadm-control-plane-provider-id.yaml
Outdated
Show resolved
Hide resolved
test/e2e/data/kustomize/providerID-with-region-override/patch-no-bastion.yaml
Outdated
Show resolved
Hide resolved
.../kustomize/providerID-with-region-override/patch-openstack-machine-template-identityRef.yaml
Outdated
Show resolved
Hide resolved
Really good start, thanks for writing these tests! A few minor comments inline. |
Signed-off-by: MatthieuFin <[email protected]>
b5fa8d3
to
4bdd8e8
Compare
break | ||
} | ||
} | ||
return namespace, identityRef |
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.
I'm not trying to be picky but I want to ensure we create code that will be maintainable and debuggable. I don't see error management here. What if the identifyRef wasn't found? Shouldn't we return an error?
Or from the callers, if identityRef is nil, we should return an error?
I think either way we need to stop and send a clean error if we can't find an identityRef. Especially because we use a pointer in one of the cases and I like to see pointer checks before using them.
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.
No problem, I ask myself about that too.
I took the choose of that the responsibility of caller since objects ...infrav1.IdentityRefProvider
could have nil pointer to IdentityRef field, I don't wanna return an error because the value of objects could be nil as a normal behavior.
In my 2 callers functions last parameters are openStackCluster
type of infrav1.OpenStackCluster
which is not a pointer https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/api/v1beta1/openstackcluster_types.go#L194 so I'm sure that identityRef variable here and here and correctly defined.
But I'm agree maybe tomorrow it could be different, so I could validate function return from caller for more maintainability.
factorize identityRef lookup from multiple object to implement logic of identityRef's inheritage in one place (scope factory) Signed-off-by: MatthieuFin <[email protected]>
dc72b3c
to
e1edef9
Compare
What this PR does / why we need it:
Add E2E test to cover region in providerID clusterv1 machine object introduced in issue #2183 and PR #2193
Special notes for your reviewer:
I have write 2 test cases:
providerID-with-region-default
and no identityRef specified in OpenStackMachineTemplateproviderID-with-region-override
and identityRef.Region specified in OpenStackMachineTemplate.I uncounter an error on test case number 1, region name missing from clusterv1.Machine providerID string. That why I add a 2nd commit to fix that usecase and keep behavior of identityRef herited from Cluster Object.
It seems to do the job but it is "semantically" not really fair because I mutate object openStackMachine to append Cluster idenityRef if openStackMachine one's is nil, but this object goal of life is to mirror reality so that's technically a hack should I append a parameter to reconcileMachineState function to pass cluster object or cluster's identityRef object ?
/hold