-
Notifications
You must be signed in to change notification settings - Fork 280
✨ AccessSubnetUUID: we can specify source subnet for access IP address #756
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,7 @@ type Instance struct { | |
FailureDomain string `json:"failureDomain,omitempty"` | ||
SecurityGroups *[]string `json:"securigyGroups,omitempty"` | ||
Networks *[]Network `json:"networks,omitempty"` | ||
AccessSubnet string `json:"accessSubnet,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Tags []string `json:"tags,omitempty"` | ||
Image string `json:"image,omitempty"` | ||
Flavor string `json:"flavor,omitempty"` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ func (s *Service) InstanceCreate(clusterName string, machine *clusterv1.Machine, | |
ConfigDrive: openStackMachine.Spec.ConfigDrive, | ||
FailureDomain: *machine.Spec.FailureDomain, | ||
RootVolume: openStackMachine.Spec.RootVolume, | ||
AccessSubnet: openStackMachine.Spec.Subnet, | ||
} | ||
|
||
if openStackMachine.Spec.Trunk { | ||
|
@@ -153,6 +154,7 @@ func createInstance(is *Service, clusterName string, i *infrav1.Instance) (*infr | |
return nil, fmt.Errorf("create new server err: %v", err) | ||
} | ||
|
||
accessIPv4 := "" | ||
nets := i.Networks | ||
portsList := []servers.Network{} | ||
for _, net := range *nets { | ||
|
@@ -182,6 +184,12 @@ func createInstance(is *Service, clusterName string, i *infrav1.Instance) (*infr | |
port = portList[0] | ||
} | ||
|
||
for _, fip := range port.FixedIPs { | ||
sbueringer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if fip.SubnetID == i.AccessSubnet { | ||
accessIPv4 = fip.IPAddress | ||
} | ||
} | ||
|
||
portsList = append(portsList, servers.Network{ | ||
Port: port.ID, | ||
}) | ||
|
@@ -221,6 +229,10 @@ func createInstance(is *Service, clusterName string, i *infrav1.Instance) (*infr | |
} | ||
} | ||
} | ||
if i.AccessSubnet != "" && accessIPv4 == "" { | ||
return nil, fmt.Errorf("no ports with fixed IPs found on AccessSubnet \"%s\"", i.AccessSubnet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If AccessSubnet is renamed to Subnet, This comment would be updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✔️ |
||
} | ||
|
||
var serverCreateOpts servers.CreateOptsBuilder = servers.CreateOpts{ | ||
Name: i.Name, | ||
ImageRef: imageID, | ||
|
@@ -233,6 +245,7 @@ func createInstance(is *Service, clusterName string, i *infrav1.Instance) (*infr | |
Tags: i.Tags, | ||
Metadata: i.Metadata, | ||
ConfigDrive: i.ConfigDrive, | ||
AccessIPv4: accessIPv4, | ||
} | ||
|
||
serverCreateOpts = applyRootVolume(serverCreateOpts, i.RootVolume) | ||
|
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.
hm does it make sense to call the property in instance differently than the one in the spec?
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.
Hm maybe I missed something / or read it incorrectly. Could it be that this adds the Subnet property to the OpenStackMachine and the AccessSubnet to the Instance struct which seems to be only used for the status of the Bastion host?
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.
Instance
struct seems to be used as a status of bastion and as a holder of state of a created VM, but at the same time, it is used as an input forcreateInstance
. I don't know why this is so, but I wanted to minimize the impact of this PR.There are basically two possibilities how to forward the subnet UUID into the
createInstance
function:Instance
struct (what I did)createInstance
functionThe second option seemed inappropriate, taking into consideration the current signature:
Adding
accessSubnetUUID string
does not feel right, but now that I'm thinking about it, the advantage would be that it would not change the public contract in bastion host status.Just let me know, I can add another commit and forward the subnet UUID in an additional argument.
It also might make sense to keep it as it is and add the same possibility to specify subnet UUID for bastion host as well (adding similar
Subnet
property toBastion
structcluster-api-provider-openstack/api/v1alpha3/types.go
Lines 251 to 266 in 437e82f
Then having this property in Bastion status starts making sense.