Fix the Get Secret Bug from OS Environment Variable#2077
Conversation
os.environ.get
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2077 +/- ##
==========================================
- Coverage 85.71% 81.04% -4.68%
==========================================
Files 313 176 -137
Lines 23396 17001 -6395
Branches 3501 3501
==========================================
- Hits 20055 13779 -6276
+ Misses 2733 2643 -90
+ Partials 608 579 -29 ☔ View full report in Codecov by Sentry. |
wild-endeavor
left a comment
There was a problem hiding this comment.
I think this is a low-risk change so let's go ahead, but i don't understand what's happening. why is this happening now? why hasn't this come up before? it could be an issue in the secrets mounting bit? when you get the secret using kubectl, are we sure it doesn't have the newline?
I have tested the scenario in the single binary mode using I think maybe we have encountered this issue before, that's why we will remove whitespace when using |
This reverts commit 452a2ec.
Signed-off-by: Future Outlier <eric901201@gmai.com> Co-authored-by: Future Outlier <eric901201@gmai.com>

Why are the changes needed?
In the current design of flytekit, we have two ways to retrieve secrets:
If you choose the first method, you will encounter an issue: the retrieved secret value needs to have
whitespace charactersremoved.This update aims to fix errors that occur when using
flytekit.current_context().secrets.getalong with the first method above, especially inSingle Binary Mode.What changes were proposed in this pull request?
Call
stripmethod to remove whitespace characters incontext managerget secret function.Note: The type of variable from os environment is python pickle object, maybe that's why we have this error.
I've tried to return
typeof the secret value.Use code like below.
{ "o0":{ "type":"single (PythonPickle) blob", "uri":"s3://my-s3-bucket/data/81/f4d0ab375012340e7942-fjfcm5iy-0/004422d2313077a075ec20a2e765bcb9/e5d6226b55aa2670cc70e14f7ec76bda" } }How was this patch tested?
Setup process
Use Default Flytekit Image
Return Value
{"o0":"abc_jDDmlkadf8ASSD8DSDA5F66ds6saADSFFdas\n"}Use Flytekit Image Built by this branch
Return Value
{"o0":"abc_jDDmlkadf8ASSD8DSDA5F66ds6saADSFFdas"}Dockerfile (Use this branch)
Python File
Screenshots
Use Default Flytekit Image
This image shows the output from the
default Flytekit image, which includes a trailing blank space at the end of the output string.Use Built Image By This branch
This image displays the output using the
new Flytekit imagefrom this branch, where the trailing blank space at the end of the output string is removed.Check all the applicable boxes