-
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
Open
MatthieuFin
wants to merge
2
commits into
kubernetes-sigs:main
Choose a base branch
from
MatthieuFin:fix-providerID
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
15 changes: 15 additions & 0 deletions
15
test/e2e/data/kustomize/providerID-with-region-default/kustomization.yaml
This file contains 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,15 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../default | ||
|
||
patches: | ||
- path: patch-machine-template-identity-ref.yaml | ||
target: | ||
kind: OpenStackCluster | ||
- path: patch-kubeadm-config-template-provider-id.yaml | ||
target: | ||
kind: KubeadmConfigTemplate | ||
- path: patch-kubeadm-control-plane-provider-id.yaml | ||
target: | ||
kind: KubeadmControlPlane |
4 changes: 4 additions & 0 deletions
4
...a/kustomize/providerID-with-region-default/patch-kubeadm-config-template-provider-id.yaml
This file contains 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,4 @@ | ||
--- | ||
- op: replace | ||
path: /spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" |
7 changes: 7 additions & 0 deletions
7
...ata/kustomize/providerID-with-region-default/patch-kubeadm-control-plane-provider-id.yaml
This file contains 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,7 @@ | ||
--- | ||
- op: replace | ||
path: /spec/kubeadmConfigSpec/initConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" | ||
- op: replace | ||
path: /spec/kubeadmConfigSpec/joinConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" |
4 changes: 4 additions & 0 deletions
4
...2e/data/kustomize/providerID-with-region-default/patch-machine-template-identity-ref.yaml
This file contains 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,4 @@ | ||
--- | ||
- op: add | ||
path: /spec/identityRef/region | ||
value: ${CAPO_REGION} |
15 changes: 15 additions & 0 deletions
15
test/e2e/data/kustomize/providerID-with-region-override/kustomization.yaml
This file contains 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,15 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../default | ||
|
||
patches: | ||
- path: patch-kubeadm-config-template-provider-id.yaml | ||
target: | ||
kind: KubeadmConfigTemplate | ||
- path: patch-kubeadm-control-plane-provider-id.yaml | ||
target: | ||
kind: KubeadmControlPlane | ||
- path: patch-openstack-machine-template-identityRef.yaml | ||
target: | ||
kind: OpenStackMachineTemplate |
4 changes: 4 additions & 0 deletions
4
.../kustomize/providerID-with-region-override/patch-kubeadm-config-template-provider-id.yaml
This file contains 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,4 @@ | ||
--- | ||
- op: replace | ||
path: /spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" |
7 changes: 7 additions & 0 deletions
7
...ta/kustomize/providerID-with-region-override/patch-kubeadm-control-plane-provider-id.yaml
This file contains 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,7 @@ | ||
--- | ||
- op: replace | ||
path: /spec/kubeadmConfigSpec/initConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" | ||
- op: replace | ||
path: /spec/kubeadmConfigSpec/joinConfiguration/nodeRegistration/kubeletExtraArgs/provider-id | ||
value: "openstack://${CAPO_REGION}/{{ instance_id }}" |
7 changes: 7 additions & 0 deletions
7
...stomize/providerID-with-region-override/patch-openstack-machine-template-identityRef.yaml
This file contains 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,7 @@ | ||
--- | ||
- op: add | ||
path: /spec/template/spec/identityRef | ||
value: | ||
cloudName: ${OPENSTACK_CLOUD} | ||
name: ${CLUSTER_NAME}-cloud-config | ||
region: ${CAPO_REGION} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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 ofinfrav1.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.