-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Convert CLI inject proxy options to annotations #2547
Conversation
} | ||
|
||
if options.dockerRegistry != "" { |
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 still need to check for image name even if the registry option isn't provided.
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.
Code looks good to me. Reusing resourceTransformerInject
is neat 🎈
I did find a use case that might need to be addressed.
Say we have a POD annotated with config.linkerd.io/proxy-memory-limit: 10Mi
Then we inject it with inject --proxy-memory-limit 20Mi
.
The annotation will get updated correctly, but the memory limit in the sidecar will get set to the old 10Mi
, because getOverride()
only looks at the annotations from parsing the payload, disregarding the map of overriding annotations that cli/cmd/inject.go
created.
First thing that comes to mind to address this would be to augment ResourceConfig
to include that map (that cli/cmd/inject.go
would pass when calling NewResourceConfig
), for getOverride
to take into account.
transformer := &resourceTransformerInject{ | ||
configs: configs, | ||
overrideAnnotations: overrideAnnotations, | ||
} |
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.
How about defining this earlier, and have overridedConfigs()
receive it as its sole argument?
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 prefer to keep the arguments of overrideConfigs()
to config data. A function that reads overrideConfigs(someKindOfTransformer)
sounds like we are overriding the transformer's config, which it isn't because the transformer has no configs of its own, and it's more a YAML-parsing receiver, than a config receiver.
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.
Nice, this looks like the right approach to me, and 👍 to @alpeb's feedback about constructing the overrides.
@alpeb My thought is that the payload that is parsed by |
463085a
to
804225c
Compare
Integration test results for 463085a: success 🎉 |
804225c
to
5822eea
Compare
Integration test results for 804225c: success 🎉 |
Integration test results for 5822eea: success 🎉 |
57b7781
to
49e67c0
Compare
Integration test results for 0b7c992: success 🎉 |
Integration test results for 57b7781: fail 👎 |
Integration test results for 49e67c0: success 🎉 |
49e67c0
to
4e80636
Compare
Integration test results for 4e80636: success 🎉 |
8e7a7d2
to
ed35d24
Compare
Integration test results for afeec47: success 🎉 |
Integration test results for 8e7a7d2: fail 👎 |
Integration test results for ed35d24: success 🎉 |
Signed-off-by: Ivan Sim <[email protected]>
The override logic depends on this option to assign different profile suffix. Signed-off-by: Ivan Sim <[email protected]>
… empty Signed-off-by: Ivan Sim <[email protected]>
…atch This ensures that any configs provided via the CLI options are persisted as annotations before the configs override. Signed-off-by: Ivan Sim <[email protected]>
ed35d24
to
ec01a9e
Compare
Integration test results for ec01a9e: fail 👎 |
Signed-off-by: Ivan Sim <[email protected]>
Integration test results for 4b09829: success 🎉 |
Signed-off-by: Ivan Sim <[email protected]>
Signed-off-by: Ivan Sim <[email protected]>
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.
⭐️ Thanks for making those updates. Looks good to me.
@@ -141,6 +143,13 @@ func (conf *ResourceConfig) WithOwnerRetriever(f OwnerRetrieverFunc) *ResourceCo | |||
return conf | |||
} | |||
|
|||
// AppendPodAnnotations appends the given annotations to the pod spec in conf | |||
func (conf *ResourceConfig) AppendPodAnnotations(annotations map[string]string) { |
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.
TIOLI I'd prefer to call this AddPodAnnotations
, since I don't typically think of appending to a map.
Integration test results for 4c375e2: fail 👎 |
The PR introduces code to convert CLI inject proxy options into config annotations. The annotations ensure that these configs are persisted in subsequent resource updates.
Fixes #2447
Signed-off-by: Ivan Sim [email protected]