-
Notifications
You must be signed in to change notification settings - Fork 253
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
✨Refactor CreateInstance and CreateBastion #1191
Conversation
Common network and security group handling between CreateBastion() and CreateInstance(). A principal advantage of this refactor is that it makes the marshalling of OpenStackMachineSpec and Instance respectively into an InstanceSpec a cheap operation which makes no API calls.
Refactor instance creation in machine controller and cluster controller (for the bastion) to call compute.CreateInstance() with an InstanceSpec.
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mdbooth 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 |
I like this refactoring a lot! /lgtm |
/hold cancel |
What this PR does / why we need it:
The primary purpose of this this PR is to cleanup the interface of
compute.CreateInstance
and make the separation of concerns between the machine controller (for Machines), the cluster controller (for the Bastion), and compute (for actual server creation) better defined.The Bastion host is represented in the cluster spec as an
Instance
. An OpenStackMachine is represented by context inOpenStackMachine
as well asOpenStackCluster
. So while they both create a server in the same way, they both source the server's parameters in slightly different ways using different source objects.At some point in history we also used
Instance
as the intermediate representation for an OpenStackMachine. That is, we combined parameters from anOpenStackMachine
and anOpenStackCluster
into anInstance
, then passed that to CreateInstance.Instance
is not ideal for this purpose as it is both Spec and Status. It contains fields which cannot be used as input parameters to CreateInstance. Therefore we refactored this into the internal-onlyInstanceSpec
, which contains only spec fields.This refactor takes this further. Firstly we ensure that creating an InstanceSpec from an OpenStackMachine or a cluster bastion is strictly data transformation and therefore very cheap. Anything expensive moves into the new CreateInstance. Secondly we move this code to the controller where it is relevant, and add new unit tests covering the transformation. This also reduces the scope of the CreateInstance unit tests, making them simpler.
Special notes for your reviewer:
I don't intend to squash these commits. They are intended to be independent logical steps. You may find it easier to review this PR by commit rather than as a single change.
This is the code motion portion of #1153 with functional changes to Bastion reconciliation removed.
/hold