-
Notifications
You must be signed in to change notification settings - Fork 35
feat: Propagate LabelPrefix through LMT #799
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #799 +/- ##
==========================================
+ Coverage 62.83% 62.88% +0.05%
==========================================
Files 71 71
Lines 7178 7213 +35
==========================================
+ Hits 4510 4536 +26
- Misses 2401 2407 +6
- Partials 267 270 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| func instanceHasToBeUpdated(machineScope *scope.MachineScope, linodeInstance *linodego.Instance) (bool, linodego.InstanceUpdateOptions) { | ||
| updateOptions := linodego.InstanceUpdateOptions{} | ||
|
|
||
| machineTags := getTags(machineScope, linodeInstance.Tags) |
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.
do you need to sort here?
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.
Pull Request Overview
This PR introduces the ability to propagate LabelPrefix configuration from LinodeMachineTemplate to LinodeMachine resources, enabling custom prefixes for Linode instance labels. The implementation includes updating the controller logic to sync label prefix changes and applying the prefix to instance labels according to specific rules based on machine ownership.
- Adds
LabelPrefixfield to LinodeMachine and LinodeMachineTemplate specs with appropriate CRD validation - Updates LinodeMachineTemplate controller to propagate label prefix changes to associated machines
- Implements label generation logic that handles prefix application based on machine owner references
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| api/v1alpha2/linodemachine_types.go | Adds LabelPrefix field to LinodeMachineSpec |
| config/crd/bases/*.yaml | Updates CRDs with new LabelPrefix field definitions |
| internal/controller/linodemachinetemplate_controller.go | Updates reconciler to handle label prefix propagation |
| internal/controller/linodemachine_controller_helpers.go | Implements label generation and instance update logic |
| internal/controller/linodemachine_controller.go | Updates reconciler to use new instance update logic |
| e2e/linodemachinetemplate-controller/lmt-tags/*.yaml | Adds e2e tests for label prefix functionality |
| docs/src/reference/out.md | Updates documentation with new field description |
e2e/linodemachinetemplate-controller/lmt-tags/lmt-add-label.yaml
Outdated
Show resolved
Hide resolved
e2e/linodemachinetemplate-controller/lmt-tags/lmt-remove-label.yaml
Outdated
Show resolved
Hide resolved
e2e/linodemachinetemplate-controller/lmt-tags/assert-lm-label-addition.yaml
Outdated
Show resolved
Hide resolved
|
|
||
| // update the tags if needed | ||
| machineTags := getTags(machineScope, linodeInstance.Tags) | ||
| if !slices.Equal(machineTags, linodeInstance.Tags) { |
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.
Is there a reason slices.Equal won't work in this 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.
slices.Equal only works if the order is the same - https://cs.opensource.google/go/go/+/refs/tags/go1.24.5:src/slices/slices.go;l=20
we'd either have to sort both these lists and then do slices.Equal or take this approach
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.
machineTags is created from linodeInstance.Tags. linodeInstance.Tags is initially converted to a map. After performing a few operations, it gets converted back to slice. Practically, the order is not changed but theoretically the map is not an orderedMap. So, there is no guarantee for the order.
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 I would prefer we sort the lists rather than write our own equality logic
|
It needs to be rebased from main so that existing GHAs which use |
|
Dropping as CAPI supports this. |
What this PR does / why we need it:
The PR introduces a way to propagate LabelPrefix through LMT. These LabelPrefixes are then added as prefixes to Linode instance labels, adhering to these rules.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
TODOs: