fix: merge LaunchPlan security context per field on registration#3442
fix: merge LaunchPlan security context per field on registration#34421fanwang wants to merge 2 commits into
Conversation
Signed-off-by: 1fanwang <1fannnw@gmail.com>
| secrets=options_sc.secrets or entity_sc.secrets, | ||
| tokens=options_sc.tokens or entity_sc.tokens, |
There was a problem hiding this comment.
nit: not a blocker, just wondering if a user explicitly sets secrets=[] or tokens=[] in options to clear the entity value, we'll ignore them here and use the one from entity. Have you observed any usage of setting them as empty list?
There was a problem hiding this comment.
Good point — right now the or treats an explicit empty list the same as "unset", so options.secrets=[]/tokens=[] can't clear an authored list; the launch-plan value wins. I haven't seen []-to-clear used in practice (registration options have been additive in what I've hit — service account, labels), so I kept the simpler or. If you'd rather honor an explicit empty list as "clear", I can switch to an is not None check per field — happy to do whichever you prefer.
There was a problem hiding this comment.
Thanks, we can keep it simpler for now
Signed-off-by: 1fanwang <1fannnw@gmail.com>
machichima
left a comment
There was a problem hiding this comment.
LGTM! Thank you. Please rebase/merge master for the CI fix
Why are the changes needed?
Registering a launch plan that declares
secrets(ortokens) while passing registrationOptionsthat only set a service account silently drops the secrets.get_serializable_launch_plandoesoptions.security_context or entity.security_context— a wholesale replace — so any non-empty options context wipes whatever the launch plan authored.What changes were proposed in this pull request?
Merge the two security contexts per field instead of replacing wholesale: options win field-by-field (
run_as,secrets,tokens), so a service-account-only override stops clobbering authored secrets.How was this patch tested?
test_get_serializable_launch_plandrives the same path. Also end-to-end against a real flyteadmin (flyte demo): register the secrets launch plan with service-account-only options and read it back — before,secretsreturnsNone(dropped); after, it's preserved alongside the overridden service account.Check all the applicable boxes