-
Notifications
You must be signed in to change notification settings - Fork 286
✨Return all NodeAddresses in OpenStackMachine.Status.Addresses #1004
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
Conversation
|
✔️ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready! 🔨 Explore the source changes: aea62dd 🔍 Inspect the deploy log: https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/615625a6ee1bca00079ce7ee 😎 Browse the preview: https://deploy-preview-1004--kubernetes-sigs-cluster-api-openstack.netlify.app |
a8bfa75 to
7440d78
Compare
| if err = networkingService.DeleteFloatingIP(openStackCluster, floatingIP); err != nil { | ||
| handleUpdateOSCError(openStackCluster, errors.Errorf("failed to delete floating IP: %v", err)) | ||
| return errors.Errorf("failed to delete floating IP: %v", err) | ||
| for _, address := range addresses { |
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.
just curious, what's the reason behind the removal of disasociate floating ip for bastion only?
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.
Consistency. We've never done it for controllers:
cluster-api-provider-openstack/controllers/openstackmachine_controller.go
Lines 246 to 251 in cf5e5cb
| if !openStackCluster.Spec.ManagedAPIServerLoadBalancer && util.IsControlPlaneMachine(machine) && openStackCluster.Spec.APIServerFloatingIP == "" && floatingIP != "" { | |
| if err = networkingService.DeleteFloatingIP(openStackCluster, floatingIP); err != nil { | |
| handleUpdateMachineError(logger, openStackMachine, errors.Errorf("error deleting Openstack floating IP: %v", err)) | |
| return ctrl.Result{}, nil | |
| } | |
| } |
Also it's redundant, because the floating IP will be disassociated automatically on deletion.
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.
ok, thanks for the confirmation
I don't know the disassociate also happen on deletion.. thanks:)
| } | ||
|
|
||
| if instanceStatus == nil { | ||
| logger.Info("Skipped deleting machine that is already deleted") |
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.
maybe add instance ID here?
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 added this, but then removed it again because after looking at how we create the log object I realised it's redundant. We don't have instance ID here because the machine has been deleted. I had added machine name, but that's already included by the logger:
| log = log.WithValues("openStackMachine", openStackMachine.Name) |
| case "fixed": | ||
| addressType = corev1.NodeInternalIP | ||
| default: | ||
| // Ignore unknown address types |
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.
maybe add some log as reference? though should not reach here..
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 thought about this, and I'm not sure.
The most likely reason that we would get an unknown address type here is that OpenStack introduced a new address type which we don't use, yet. This would be a new feature, and logging something here because of a new feature we don't support yet would be very noisy. I guess we could log this and IPv6 addresses at debug level just in case?
Interestingly, I was speaking to a Nova developer about addresses yesterday, and his impression is that addresses is more likely to go away entirely rather than gain new features because it's viewed as a proxy API. The replacement would be to directly query neutron for ports associated with the device id. The only reason I didn't make that change here is that as long as Nova is caching NetworkInfo, getting it from Nova requires 1 less API call.
TL;DR I might add this at debug.
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've added this.
|
|
||
| // FloatingIP returns the first listed floating ip of an instance for the given | ||
| // network name. | ||
| func (ns *InstanceNetworkStatus) FloatingIP(networkName string) string { |
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 guess I lost some background
usually ,multiple network is reasonable, so we have multiple NICs from various network
but multiple NIC from one network is not so familiar to me, anyway, seems no harm if we
return the first ip
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.
We're actually only using this method in 1 place: APIInstance() above. And the only thing that uses APIInstance() is the bastion host. I guess we're not likely to put a second floating IP on the bastion host, so this is really just something to make the behaviour defined if we ever did.
|
/lgtm overall looks great, just very some minor questions.. thanks~ |
1c090b4 to
fcbf207
Compare
macaptain
left a comment
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.
Looks great! Unit tests and e2e tests, we are spoiled.
| networks := make([]string, 0, len(ns.addresses)) | ||
| for network := range ns.addresses { | ||
| networks = append(networks, network) | ||
| } |
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.
Would it be more idiomatic to do a copy here?
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 read your comment, looked at my code, and agreed with you.
I was trying to work out why I wrote it this way when I realised the code is actually correct, because the range iterates over only the keys of the map, not the elements.
I think that's a fairly clear indication this code needs another comment 😂 I'll add one.
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.
Added a comment.
test/e2e/suites/e2e/e2e_test.go
Outdated
| Expect(len(workerMachines)).To(Equal(1)) | ||
| Expect(len(controlPlaneMachines)).To(Equal(3)) |
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 see that this creates a four node cluster with the machines having ports on two different networks. Did you also want to test your functions? I think you should be able to see e.g. controlPlaneMachines[0].Status.Addresses, if the controller is working, this should show multiple addresses, since they get assigned in reconciliation:
| openStackMachine.Status.Addresses = addresses |
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.
This was a lazy late addition, tbh. I'd previously written it as a standalone create/delete test which I expected to fail. However, it turns out that it eventually comes up because although IP selection was non-deterministic and failed when it picked the wrong one, the reconciler would just retry and eventually it picked the right one 🤷♂️
You are right: this test would be massively improved by testing the resulting addresses.
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.
This commit makes 2 closely related changes: * Add NetworkStatus.Addresses(), and return this in OpenStackMachine * Update IP() and FloatingIP() to return individual addresses by network name There are also a couple of incidental changes: * Don't bother with DisassociateFloatingIP before DeleteFloatingIP for bastion host * Delete floating IPs before server during machine delete: avoids orphaned floating IPs if floating IP delete fails.
fcbf207 to
6a5c44b
Compare
6a5c44b to
aea62dd
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hidekazuna, macaptain, mdbooth The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
@macaptain: changing LGTM is restricted to collaborators DetailsIn 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/test-infra repository. |
chrischdi
left a comment
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
This commit makes 2 closely related changes:
network name
There are also a couple of incidental changes:
bastion host
orphaned floating IPs if floating IP delete fails.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #1001, fixes #926