Skip to content
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 extra labels with smbios data #155

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

Itxaka
Copy link
Contributor

@Itxaka Itxaka commented Sep 1, 2022

Now that we get the smbios data properly, we can add extra labels to the
inventory based on that smbios data.

This could be helpful to identify groups of machines in big deployments
and adds extra info to the inventory so we can search using selectors
via kubectl.

Signed-off-by: Itxaka [email protected]

Now that we get the smbios data properly, we can add extra labels to the
inventory based on that smbios data.

This could be helpful to identify groups of machines in big deployments
and adds extra info to the inventory so we can search using selectors
via kubectl.

Signed-off-by: Itxaka <[email protected]>
@Itxaka Itxaka requested a review from a team September 1, 2022 15:56
@Itxaka Itxaka added the kind/enhancement New feature or request label Sep 1, 2022
@github-actions github-actions bot added area/operator operator related changes area/tests test related changes labels Sep 1, 2022
@Itxaka
Copy link
Contributor Author

Itxaka commented Sep 1, 2022

final labels ends like this:

$ kubectl describe machineinventory --all-namespaces                                              
Name:         my-machine
Namespace:    fleet-default
Labels:       cpuCore=1
              cpuFamily=other
              cpuManufacturer=qemu
              cpuThreads=1
              location=europe
              manufacturer=qemu
              productName=standard-pc-q35-ich9-2009
              serialNumber=not-specified
              uuid=b6bd924f-ffd0-43cf-905b-102007aafe3a

@Itxaka Itxaka enabled auto-merge (squash) September 1, 2022 16:14
Copy link
Contributor

@davidcassany davidcassany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍 Registering machine details looks like a good move to me, I agree this is likely to be useful in large deployments.

I just do not understand the naming start constraints and its change.

@@ -43,7 +43,7 @@ const defaultName = "m-${System Information/Manufacturer}-${System Information/P
var (
sanitize = regexp.MustCompile("[^0-9a-zA-Z]")
doubleDash = regexp.MustCompile("--+")
start = regexp.MustCompile("^[a-zA-Z]")
start = regexp.MustCompile("^[a-zA-Z0-9]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is required? I don't know from where this restriction came from, but I am wondering if relaxing it will cause issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was used just to check if the label (was the name) had a valid first character, otherwise m is prepended.
Yep, this code is a bit cumbersome maybe it deserves a rework 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then as a result of this change a name staring with a digit has no m prepended right? will it be an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK no, kubernetes resource names and labels may start with a digit too

Copy link
Contributor Author

@Itxaka Itxaka Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, this was done only with the machine name in mind, so the regex never expected to find a machine name starting with a digit :D

This is mostly due to protection against someone setting a machine name like -sdfa or an empty name ""

And yeah k8s names/labels are alphanumeric + - and . but not at the start or end -> https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

@Itxaka Itxaka merged commit 75792d6 into rancher:main Sep 1, 2022
Copy link
Member

@fgiudici fgiudici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really geat idea, love this patch! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/operator operator related changes area/tests test related changes kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants