-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
WIP: fix(Backend+SDK): Update kubernetes.use_secret_as_volume to accept secret name dynamically at runtime #11039
base: master
Are you sure you want to change the base?
Conversation
845fccb
to
fbf772e
Compare
/lgtm I also verified it, so @chensun mind taking a quick look? |
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.
Please create a test for this scenario
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
good call |
c788e29
to
e3b156b
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.
Looks good to me !
@@ -147,6 +147,34 @@ def my_pipeline(): | |||
} | |||
} | |||
|
|||
def test_with_secret_name_param(self): | |||
@dsl.pipeline | |||
def my_pipeline(secret_name: str = 'my-secret'): |
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.
It is missing a test that assert from the value my-secret
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.
The problem here is the pipeline spec generated from this compile step has the name stored in as a variable under the roots
section.
root:
dag:
tasks:
print-secret:
cachingOptions:
enableCache: true
componentRef:
name: comp-print-secret
taskInfo:
name: print-secret
inputDefinitions:
parameters:
secret_name:
defaultValue: my-secret
isOptional: true
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.8.0
---
platforms:
kubernetes:
deploymentSpec:
executors:
exec-print-secret:
secretAsVolume:
- mountPath: /mnt/my_vol
optional: false
secretName: secret_name
I tried a bunch of combinations to have the defaultValue
field validated, so we know the name is being passed correctly, but the structure of this tests is such that if I pass in the entire pipelineSpec in the assert it fails:
https://github.com/kubeflow/pipelines/actions/runs/10191867165/job/28193820249#step:4:886
The tests only work when platform_spec
is extracted and matched.
Note that the assert statement still verifies that the secret_name
variable is getting passed into the secretAsVolume
, I believe that's a good enough preliminary test at this point. Wdyt? @diegolovison @gregsheremeta
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.
for posterity
The problem here is the pipeline spec generated from this compile step has the name stored in as a variable under the roots section.
we discovered today that that's not how this works. secretName
(at the very bottom of the platforms spec) has to say secretName: my-secret
and not secretName: secret_name
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.
also for posterity, the above comment is also incorrect 😅
secretName: secret_name
actually needs to be a key to the input parameter map, so we can grab the parameter by name at runtime. Newly added changes to driver.go show how we do that.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: amadhusu The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ameter Signed-off-by: ddalvi <[email protected]>
ad536ac
to
c83a482
Compare
c83a482
to
47158f0
Compare
@chensun could you please take a look and let us know if this templating method looks good to you? Thanks! |
/rerun-all |
/lgtm |
@chensun could you please take a look? Thanks! |
- Implemented support for dynamically specifying secret names in the `use_secret_as_volume` function. - Updated driver code to handle secret name substitution at runtime based on input parameters. - Introduced a `{{my_secret}}` template string representation for secret names in the compiled DSL. - Added a test to validate secret name template creation in IR. Co-authored-by: Greg Sheremeta <[email protected]> Signed-off-by: ddalvi <[email protected]>
47158f0
to
6aa7591
Compare
New changes are detected. LGTM label has been removed. |
/rerun-all |
@chensun could you please take a look and let us know if this templating method looks good to you? Thanks! |
@chensun bumping :) |
# if secret_name is a PipelineParameterChannel, then we don't know what secret to mount until RUNTIME | ||
# so, treat is as a map KEY instead of a secret name | ||
if isinstance(secret_name, PipelineParameterChannel): | ||
val = "{{" + secret_name.name + "}}" |
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 am uncertain about this approach, we're essentially implementing templating, but what maybe considered somewhat hacky. Have we considered other approaches?
For example, for names retrieved via parameterschannels, we can include a new field for SecretAsEnv
called "secret_name_parameter".
Based on last community call @chensun had a proposal for an alternative approach as well, so I would be interested in hearing about this as well.
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 can include a new field for SecretAsEnv called "secret_name_parameter".
that does feel cleaner to me
|
||
secretName := secretAsVolume.GetSecretName() | ||
|
||
if strings.HasPrefix(secretName, "{{") && strings.HasSuffix(secretName, "}}") { |
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.
Description of your changes:
Resolves #10914
Attempting to pass the
secret_name
parameter in the dsl compile this way:results in this error:
The secret_name parameter was originally expected to be a string (str). However, in this case, it was being provided as a an object of the
PipelineParameterChannel
class , leading to a type mismatch error when the code tried to use it as a string.Updated
secret_name
to accept either astr
orPipelineParameterChannel
usingUnion[str, PipelineParameterChannel]
and added a check to convertPipelineParameterChannel
to its string representation.Furthermore,
use_secret_as_volume
function.{{secret_name}}
template string representation for secret names in the compiled DSL.Refer to this comment to understand why the driver code change is required.
Please refer to a PoC wherein we've listed out different test cases - four different pairs of DSL compile code and resulting pipeline yaml IRs with which we tested this update.
Collaborated with @gregsheremeta for this contribution, it was a joint effort. Thanks Greg for your contributions! :)
Checklist: