-
Notifications
You must be signed in to change notification settings - Fork 84
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
[GEP-27] Use cloud profile bastion machine and image #948
Conversation
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.
mostly lgtm.
pkg/controller/bastion/options.go
Outdated
// getProviderSpecificImage returns the provider specific MachineImageVersion that matches with the given VmDetails | ||
func getProviderSpecificImage(images []azure.MachineImages, vm VmDetails) (*armcompute.ImageReference, error) { | ||
imageIndex := slices.IndexFunc(images, func(image azure.MachineImages) bool { | ||
return image.Name == vm.ImageBaseName |
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 could be nice and use strings.EqualFold
, but there might also be value in strictness.
Just a thought.
pkg/controller/bastion/vmdetails.go
Outdated
ImageVersion string | ||
} | ||
|
||
// DetermineVmDetails calculates the |
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.
Incomplete comment
pkg/controller/bastion/vmdetails.go
Outdated
machineIndex := slices.IndexFunc(machineTypes, func(machine core.MachineType) bool { | ||
return machine.Name == bastion.MachineType.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.
same as above, Index
should do the trick
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.
Index
can only be used on primitive types and not for structs.
pkg/controller/bastion/vmdetails.go
Outdated
} | ||
|
||
// find the machine in cloud profile with the lowest amount of cpus | ||
var minCpu int64 = math.MaxInt64 |
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.
Consider using a pointer and nil
to signal unchanged var. Seems a tiny bit more semantically fitting. It's a matter of preference, though.
pkg/controller/bastion/vmdetails.go
Outdated
|
||
findSupportedArchs := func(versions []core.MachineImageVersion, specVersion *string) { | ||
for _, version := range versions { | ||
if specVersion != nil && version.Version == *bastion.MachineImage.Version { |
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.
Since I was hit by that in the recent past: bastion
could be nil
. Maybe we should be careful just in case.
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.
Okay, I see, it cannot be nil
. I'd prefer having it as an explicit parameter in that case, though. Clearer that way.
pkg/controller/bastion/vmdetails.go
Outdated
|
||
// if only machineImage is set -> find all supported versions if no version is set otherwise return arch of version | ||
if bastion.MachineImage != nil && bastion.MachineType == nil { | ||
imageIndex := slices.IndexFunc(images, func(image core.MachineImage) bool { |
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.
slices.Index
pkg/controller/bastion/vmdetails.go
Outdated
} | ||
|
||
// getImageVersion returns the image version for the bastion. | ||
func getImageVersion(imageName, machineArch string, bastion *core.Bastion, images []core.MachineImage) (string, error) { |
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.
All this seems very familiar. Is there a way to deduplicate it? Maybe a shared function that is used in both places.
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.
Good point! Refactored by creating a function findImageByName
.
pkg/controller/bastion/vmdetails.go
Outdated
return *bastion.MachineImage.Version, nil | ||
} | ||
|
||
var newest *semver.Version |
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: strictly speaking, that would be greatest
.
/hold until updated gardener/gardener |
2739d43
to
ae9a2c9
Compare
/unhold |
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
How to categorize this PR?
/area quality
/kind enhancement
/platform azure
What this PR does / why we need it:
Instead of using a hardcoded bastion image we will use the image provided in the bastion section of the cloud profile.
See also GEP proposal
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
We need to wait until the bastion section is released with gardener/gardener/types_cloudprofile.go.
Release note: