-
Notifications
You must be signed in to change notification settings - Fork 87
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
add machine images info to labels #689
Conversation
Hey, @rishabh-11 Take GCP as the first sample, if everything is all good, will open the rest of the others. (AWS,Azure,Alicloud,CCloud) |
pkg/controller/worker/machines.go
Outdated
if pool.MachineImage.Name != "" && pool.MachineImage.Version != "" { | ||
gceInstanceLabels["machine_image_name"] = pool.MachineImage.Name | ||
gceInstanceLabels["machine_image_version"] = pool.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.
Here is an example error when trying to run the change as is:
failed: googleapi: Error 400: Invalid value for field ''resource.labels'': ''''.
Label value ''934.10.0'' violates format constraints. The value can only contain
lowercase letters, numeric characters, underscores and dashes. The value can
be at most 63 characters long. International characters are allowed., invalid]'
The issue is that both key and values need to adhere to gcp conventions and semver that is used in gardenlinux for example doesn't adhere to that (dots being the issue here). You need to sanitize them.
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.
ff28099
btw how did you get this error return? is it from the integration test?
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.
You get this error if you try to create a machine with invalid GCP labels. The error is from GCP API itself
pkg/controller/worker/machines.go
Outdated
@@ -177,6 +177,12 @@ func (w *workerDelegate) generateMachineConfig(_ context.Context) error { | |||
} | |||
|
|||
gceInstanceLabels := getGceInstanceLabels(w.worker.Name, pool) | |||
|
|||
if pool.MachineImage.Name != "" && pool.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.
Why not move this code into function getGceInstanceLabels
itself ? anyways MachineImage/Version
fields are part of pool
obj which is passed to getGceInstanceLabels
Actually after reading the issue that this PR tries to solve I am not convinced about the approach here. What is exactly the end-goal that you are trying to achieve ? Should the annotations be in the The place you are changing now would add labels to the node object and the VM in gcp itself, which the original ticket does not mention as a solution. I would suggest that before considering this change, maybe you add a comment in the initial ticket with the exact solution you are trying to achieve, specifying all the places that you want to add these labels. We can then verify the approach first and review the subsequent PRs accordingly. /hold |
The main idea from our SRE colleague is to extract the os name and os version data from any one of them (machine, machineDeployment, machineclass, machinesets, node) to generate our report. The specific location of the data, whether in labels, annotations or the spec of these objects, is not a concern.
per sync with MCM colleague, The MCM is more independent and cannot directly retrieve OS name and version information from Gardener's Please feel free to suggest any alternative solutions if available. |
The issue does entirely lie with this PR. Let's look at the https://github.com/gardener/gardener-extension-provider-gcp/blob/6c91b945ead507f2b38d0b2aa614f2f1b64b34e0/charts/internal/machineclass/templates/machineclass.yaml#L21C1-L24C11 and https://github.com/gardener/gardener-extension-provider-gcp/blob/6c91b945ead507f2b38d0b2aa614f2f1b64b34e0/charts/internal/machineclass/templates/machineclass.yaml#L43C1-L46C11 You see the labels are used both in the k8s object as well as the VM creation call. Now you try to sanitize the labels to adhere to the restrictions of GCP API, but the OS image name will not match what is in the cloudprofile (due to the transformation). Different providers have different standards regarding the allowed characters. In the end the SREs trying to retrieve the information of the OS, would still need to know how the provider does the transformation to valid labels to match the name as it is in the cloudprofile. Maybe we should split the labels for the machineclass with the labels that we use for the machine itself. In provider-azure for example (https://github.com/gardener/gardener-extension-provider-azure/blob/master/charts/internal/machineclass/templates/machineclass.yaml) we don't use any labels for the machineclass itself. I don't think that the labels as they are offer much value as the information are basically duplicated inside it's spec in the machine. We could therefore either decide to use a separate set of labels for the machineclass or use them unsanizited. |
@tedteng You need rebase this pull request with latest master branch. Please check. |
a4bd901
to
61b7011
Compare
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.
These are not labels of the machineclass. These are properties of the machine class's provider spec as defined here: https://github.com/gardener/machine-controller-manager-provider-gcp/blob/8e6f154abbace7c6fb4a85051191de8211739677/pkg/api/v1alpha1/provider_spec.go#L207
This just adds labels on the provider side for disks but it doesnt change anything on the k8s side
Yes, we should do this. I have one question. I looked at the code and am unable to understand how some of the fields go under |
The default label managed in https://github.com/gardener/machine-controller-manager/blob/7f7878e3176f495a1d8fb031f0105486f0cc2937/pkg/apis/machine/v1alpha1/machineclass_types.go#L41, it also passed to GCP API call. but after a new PR merged https://github.com/gardener/gardener-extension-provider-gcp/pull/669 . it seems the labels are separated. I will try it add new labels in, |
4a90b9c
to
782294a
Compare
782294a
to
a104548
Compare
Hi @kon-angelo Finally I built a test environment, commit 8b80530 and tested. |
a104548
to
6908337
Compare
6908337
to
8b80530
Compare
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 ops-productivity
/kind enhancement
/platform gcp
What this PR does / why we need it:
![image](https://private-user-images.githubusercontent.com/42234376/300317489-3dbb4033-ce8c-455a-91dd-a01ff753ac33.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTMyMDYsIm5iZiI6MTczOTE5MjkwNiwicGF0aCI6Ii80MjIzNDM3Ni8zMDAzMTc0ODktM2RiYjQwMzMtY2U4Yy00NTVhLTkxZGQtYTAxZmY3NTNhYzMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEzMDgyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmYzM0YWUyNzBiZThkYmQ0YTVhNzI5YzVhYzMzNWIwNGVjMjY0ZTljYjk5NGYxMzMzMTAxMWFiMzcwZGQ2MTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.QJ7v30cH6B2vdAjSmQvRwTXf8h7mi8zZuvb2o2hRJZY)
add os information as labels in machine class objects
Which issue(s) this PR fixes:
Fixes gardener/machine-controller-manager#880
Special notes for your reviewer:
Release note:
/invite @rishabh-11