-
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
✨ New API for Server Groups #1779
✨ New API for Server Groups #1779
Conversation
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
7e58141
to
24cda28
Compare
/cc EmilienM |
24cda28
to
4041278
Compare
3155371
to
f6d6a88
Compare
@@ -562,8 +568,18 @@ func applyServerGroupID(opts servers.CreateOptsBuilder, serverGroupID string) se | |||
return opts | |||
} | |||
|
|||
// Helper function for getting image id from name. | |||
func (s *Service) getImageIDFromName(imageName string) (string, error) { | |||
// Helper function for getting image ID from name or ID. |
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.
Helper function for getting image ID from name or ID.
this seems confusing
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 agree 😄 However, despite what GitHub says I didn't write this. This is being picked up as a moved line when in fact I simply renamed the function from getImageID
to GetImageID
and folded getImageIDFromName
into this. It's also technically true.
if err != nil { | ||
return "", err | ||
} | ||
if serverGroupFilter.Name != "" && serverGroupFilter.Name != serverGroup.Name { |
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.
should we really have this check? or just safely ignore the Name ? I think the logic here want to make sure they are consistent..
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.
So while I think this is silly check and I think providing both a name and ID is even sillier, but if someone does it then I think we should respect their request fully. To not do so would be confusing.
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 with @jichenjc on this one. Can we not just add an admission validation that if you specify ID you can't specify anything else?
If the machine creation fails because the specified ID was invalid that should be reported in the machine status.
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 think this is mostly there. I'd like to:
- Rebase on to v1alpha8
- Consequently, take the opportunity the remove the ServerGroupID field
- Remove changes to ImageID in status unless I'm missing some reason it's required for Server Groups (it's good but I'd prefer a separate PR)
- Remove additional validation of SecurityGroup specified by ID
// ImageID contains the ID of the image this machine was created with. | ||
ImageID string `json:"imageID,omitempty"` |
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.
Why are we also adding ImageID
here? It seems like a good addition, but does it need to happen in this PR?
if err != nil { | ||
return "", err | ||
} | ||
if serverGroupFilter.Name != "" && serverGroupFilter.Name != serverGroup.Name { |
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 with @jichenjc on this one. Can we not just add an admission validation that if you specify ID you can't specify anything else?
If the machine creation fails because the specified ID was invalid that should be reported in the machine status.
f6d6a88
to
3eb70ea
Compare
I tried to implement Matt's remarks based on his own version of this code. I think I'm still failing to get the conversions or the conversions tests right, will continue on that. |
ServerGroupID string `json:"serverGroupID,omitempty"` | ||
// The server group to assign the machine to. | ||
// +optional | ||
ServerGroup *ServerGroupFilter `json:"serverGroup,omitempty"` |
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.
The openstackmachine controller tests need an update, see https://github.com/shiftstack/cluster-api-provider-openstack/blob/3eb70ea4ad246bc5bacf388c18287015fd15e915/controllers/openstackmachine_controller_test.go#L94
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.
beside a few nits which can be fixed later, I think this is good to go (feel free to do it in this PR though)
/lgtm
/hold cancel |
|
||
### `OpenStackMachine` | ||
|
||
#### Change to `serverGroupID` |
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.
#### Change to `serverGroupID` | |
#### ⚠️ Change to `serverGroupID` |
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.
There's something wrong with the API conversions, but the rest of it lgtm.
@@ -0,0 +1,99 @@ | |||
/* | |||
Copyright 2018 The Kubernetes Authors. |
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.
Copyright 2018 The Kubernetes Authors. | |
Copyright 2024 The Kubernetes Authors. |
api/v1alpha7/conversion.go
Outdated
if in.ServerGroupID != "" { | ||
out.ServerGroup = &infrav1.ServerGroupFilter{ID: in.ServerGroupID} | ||
} else { | ||
out.ServerGroup = &infrav1.ServerGroupFilter{} |
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 isn't necessary. You don't need to set ServerGroup in this case: it can safely be 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.
Somehow tests fail when this is set. I have hard time debugging these, I could use pairing with someone who would teach me how to debug conversion tests failures.
api/v1alpha7/conversion_test.go
Outdated
func(v1alpha8OpenStackMachine *infrav1.OpenStackMachine, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8OpenStackMachine) | ||
|
||
// None of the following fields have ever been set in v1alpha7 |
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 is v1alpha8, though, and they are set in v1alpha8.
api/v1alpha7/conversion_test.go
Outdated
|
||
func(v1alpha8OpenStackMachine *infrav1.OpenStackMachine, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8OpenStackMachine) | ||
|
||
// None of the following fields have ever been set in v1alpha7 | ||
v1alpha8OpenStackMachine.Status.ReferencedResources = infrav1.ReferencedMachineResources{} | ||
}, | ||
|
||
func(v1alpha8OpenStackCluster *infrav1.OpenStackCluster, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8OpenStackCluster) | ||
|
||
// None of the following fields have ever been set in v1alpha7 | ||
if v1alpha8OpenStackCluster.Status.Bastion != nil { | ||
v1alpha8OpenStackCluster.Status.Bastion.ReferencedResources = infrav1.ReferencedMachineResources{} | ||
} | ||
}, | ||
|
||
func(v1alpha8ServerGroupFilter *infrav1.ServerGroupFilter, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8ServerGroupFilter) | ||
|
||
// None of the following fields have ever been set in v1alpha7 | ||
v1alpha8ServerGroupFilter.Name = "" | ||
}, |
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 doesn't look right to me. We should support round-trip conversion of all of these new fields without constraining the fuzzer.
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.
For reference, @mdbooth found a problem in the conversion functions: RestoreField must be provided to a HashedFieldRestorer. AFIK he's working on a patch now to address this so we can apply that in ongoing PRs where I wrote these unwanted fuzzer functions.
I addressed the docs and comments issue. I'm not sure how to debug the conversions though. |
9252f66
to
f74831f
Compare
f74831f
to
7e0ee45
Compare
I've addressed the conversion stuff. |
7e0ee45
to
9b4858e
Compare
/test pull-cluster-api-provider-openstack-e2e-test |
} else { | ||
out.ServerGroup = 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.
nit: This can be omitted.
} | ||
|
||
func Convert_v1alpha8_OpenStackMachineStatus_To_v1alpha7_OpenStackMachineStatus(in *infrav1.OpenStackMachineStatus, out *OpenStackMachineStatus, s apiconversion.Scope) error { | ||
// ReferencedResources have no equivalent in v1alpha7 |
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.
// ReferencedResources have no equivalent in v1alpha7 | |
// ReferencedResources has no equivalent in v1alpha7 |
} | ||
|
||
func Convert_v1alpha8_BastionStatus_To_v1alpha7_BastionStatus(in *infrav1.BastionStatus, out *BastionStatus, s apiconversion.Scope) error { | ||
// ReferencedResources have no equivalent in v1alpha7 |
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.
// ReferencedResources have no equivalent in v1alpha7 | |
// ReferencedResources has no equivalent in v1alpha7 |
} else { | ||
out.Instance.ServerGroup = 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.
nit: This can be omitted.
api/v1alpha7/conversion_test.go
Outdated
|
||
func(v1alpha8OpenStackMachine *infrav1.OpenStackMachine, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8OpenStackMachine) | ||
|
||
v1alpha8OpenStackMachine.Status.ReferencedResources = infrav1.ReferencedMachineResources{} | ||
}, | ||
|
||
func(v1alpha8OpenStackCluster *infrav1.OpenStackCluster, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8OpenStackCluster) | ||
|
||
// None of the following fields have ever been set in v1alpha7 | ||
if v1alpha8OpenStackCluster.Status.Bastion != nil { | ||
v1alpha8OpenStackCluster.Status.Bastion.ReferencedResources = infrav1.ReferencedMachineResources{} | ||
} | ||
}, | ||
|
||
func(v1alpha8ServerGroupFilter *infrav1.ServerGroupFilter, c fuzz.Continue) { | ||
c.FuzzNoCustom(v1alpha8ServerGroupFilter) | ||
|
||
// None of the following fields have ever been set in v1alpha7 | ||
v1alpha8ServerGroupFilter.Name = "" | ||
}, |
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.
None of these should be required. I'll debug.
Allow users to request Server Groups by either name or ID. This aligns us with the pattern of filters used for other resources such as Security Groups and Ports. Additionally `ReferencedResources` field is added to `BastionStatus` and `OpenStackMachineStatus` as a container to hold all the IDs of resources computed by the controllers. `ServerGroupID` is the first field added there. Co-Authored-By: Emilien Macchi <emilien@redhat.com> Co-Authored-By: Michał Dulko <mdulko@redhat.com> Co-Authored-By: Stephen Finucane <stephenfin@redhat.com>
9b4858e
to
32369b6
Compare
I've pushed a new version which makes changes only to the conversion code. It:
The last one is interesting. In v1alpha6 |
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
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: EmilienM, mdbooth, stephenfin 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 |
What this PR does / why we need it:
Allow users to (a) specify server groups by name or (b) defer management of server groups to CAPO.
Note
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):n/a
Special notes for your reviewer:
n/a
TODOs:
make generate
/hold