Skip to content
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

feat(artifacts): support ephemeral credentials for S3. Fixes #5446 #12467

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

hittingray
Copy link
Contributor

@hittingray hittingray commented Jan 5, 2024

Fixes #5446

Motivation

We would like to use the new S3 access grants feature, which uses only temporary credentials. The aforementioned issue addresses temporary credentials in general (prior to recently though, this would have only been for IAM role).

Modifications

Firstly, some changes needed to be made in the Argo common pkg repo: argoproj/pkg#596
I am still waiting for these changes to be reviewed and therefore still have the forked dependency in my go.mod. This is quite a small set of changes, as support for temporary credentials was already added to the AWS client in general previously.

Inside the Argo Workflows repo, I have made changes to how the S3 artifact driver is initialised, which mainly includes looking for the session token and using it if applicable. There is also a change on the workflow pod side to fetch the relevant secret if applicable.

Verification

I have written a couple unit tests to verify the driver and workflow creation behaviour. There was no test for creation of the driver, so I took the liberty of writing a small test to ensure the behaviour of specifically the changes I made. For the changes in s3.go, the s3client struct is not exported from argoproj/pkg, so it made testing the changes I made impossible. I feel the changes made in this file are fairly small anyway.

I have also tested the changes by attempting to write into a S3 bucket in a workflow, using both IAM role and S3 access grant credentials. The behaviour is as expected; and when the credentials are invalid, or expired, an appropriate error message is returned.

@hittingray hittingray marked this pull request as ready for review January 5, 2024 04:17
@agilgur5 agilgur5 added the area/artifacts S3/GCP/OSS/Git/HDFS etc label Jan 5, 2024
@hittingray hittingray force-pushed the feat-s3-session-tokens branch 2 times, most recently from 4bfb0a0 to d7ff9ed Compare January 8, 2024 04:02
@isubasinghe isubasinghe self-assigned this Jan 14, 2024
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the comments made, generally looks good though

go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@keymon

This comment was marked as spam.

@hittingray
Copy link
Contributor Author

@keymon Still waiting on the argo/pkg PR which you already commented on. There's no point me making the changes requested until that one has been merged in 😞

@hittingray
Copy link
Contributor Author

@isubasinghe I've updated the PR, would appreciate a review when you have time, thank you!

@hittingray
Copy link
Contributor Author

@isubasinghe Sorry to ping again, but would be good if you could review the changes here. The PR has been sitting around for ages and I'd like to avoid having to address merge conflicts in the code gen again.

@keymon
Copy link

keymon commented Jul 15, 2024

Yes, please, add support for this as it blocks some local development and unit testing

argoproj/pkg#596 has been merged and this is ready to merge!

@agilgur5 agilgur5 changed the title feat: Add support for using ephemeral credentials for S3 artifacts. Fixes #5446 (#5446) feat: Add support for using ephemeral credentials for S3 artifacts. Fixes #5446 Jul 19, 2024
@isubasinghe
Copy link
Member

@hittingray will re-review this tomorrow.

@hittingray hittingray force-pushed the feat-s3-session-tokens branch 2 times, most recently from 88cd6e0 to 7915c55 Compare August 28, 2024 06:31
@hittingray
Copy link
Contributor Author

hittingray commented Aug 28, 2024

@isubasinghe I've rebased it on latest main just now. It seems like the Windows unit tests in http_test.go are failing. I haven't touched anything there, so not sure what the problem is. Flakey test or something wrong with the test setup? Could we just re-run the Windows tests?

Edit: Seems like just pushing another commit to trigger it fixed it, so flakey test it is.

@isubasinghe
Copy link
Member

@hittingray Don't stress about the windows tests, they are broken and are not required for merging.

@hittingray
Copy link
Contributor Author

@isubasinghe No worries then. It's ready for your review otherwise then :)

Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor changes

workflow/artifacts/artifacts_test.go Outdated Show resolved Hide resolved
workflow/controller/workflowpod_test.go Outdated Show resolved Hide resolved
@isubasinghe
Copy link
Member

@agilgur5 can you review the documentation for me, you are a bit more knowledgeable there about conventions.

@agilgur5 agilgur5 changed the title feat: Add support for using ephemeral credentials for S3 artifacts. Fixes #5446 feat: support ephemeral credentials for S3 artifacts. Fixes #5446 Aug 30, 2024
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs review in-line below as requested.
Note that this page has yet to be fully re-written to match the style guide, so some of the style you copied from here is actually non-conformant. A more recent example to copy from is #13376

docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Show resolved Hide resolved
@isubasinghe
Copy link
Member

isubasinghe commented Sep 4, 2024

Docs review in-line below as requested.

Thanks for the docs review!

@hittingray hittingray force-pushed the feat-s3-session-tokens branch 5 times, most recently from 7568479 to 1592fa3 Compare September 5, 2024 07:34
@agilgur5 agilgur5 added this to the v3.6.0 milestone Sep 6, 2024
@agilgur5 agilgur5 changed the title feat: support ephemeral credentials for S3 artifacts. Fixes #5446 feat(artifacts): support ephemeral credentials for S3. Fixes #5446 Sep 6, 2024
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Show resolved Hide resolved
docs/configure-artifact-repository.md Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a few more sections I need to think about the edits for, but the in-line comments cover 80-90% (enough to iterate on)

pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
@isubasinghe
Copy link
Member

@hittingray could you please make the suggested changes?

@hittingray hittingray force-pushed the feat-s3-session-tokens branch 3 times, most recently from 192d770 to 6a83625 Compare September 10, 2024 07:17
Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better, thanks for improving the docs greatly!

I left a few more comments on things that were missed, as well as the remaining sections I hadn't covered

docs/configure-artifact-repository.md Outdated Show resolved Hide resolved

!!! Note "Temporary"
IAM role credentials are temporary, so you must refresh them periodically via an external mechanism.
Argo will not refresh them for you.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Argo will not refresh them for you.

I had suggested removing this before as it is redundant with the above sentence.

We can leave it in if you feel strongly about it, but you hadn't commented there, so not sure if leaving this in intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok to remove it. Just wanted to make it clear, but I guess the first sentence is already pretty clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea "external mechanism" == "not Argo". The most explicit way would be to recommend some tooling, but I actually don't know of any that do this out of the box

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, I don't know off the top of my head. For the access grants, we wrote our own admission controller which retrieves the credentials and injects them at workflow creation time, but it's not open source (for now).

docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
docs/configure-artifact-repository.md Outdated Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
@hittingray
Copy link
Contributor Author

@agilgur5 Thanks for the reviews and sorry for all the back-and-forth! Fixed up again with your suggestions.

@agilgur5
Copy link
Member

No worries, iteration is progress and progress is good!
I could also make the changes myself, but if we have a contributor willing to learn the docs style guide etc, I prefer to use a review as a teaching experience 🙂

Copy link
Member

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs LGTM ✅

Thanks @hittingray for your dedication to getting this PR in over a long time period and pushing through all the iteration and upstream changes! ❤️

@isubasinghe you didn't approve this before, so this is now blocked on your previous change request

Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@agilgur5 agilgur5 merged commit 19b2322 into argoproj:main Sep 14, 2024
27 checks passed
@agilgur5
Copy link
Member

I did a partial backport/cherry-pick of the docs changes to existing features here to release-3.5 in 9b337f8 as I thought they were a substantial improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/artifacts S3/GCP/OSS/Git/HDFS etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support session tokens to access S3 buckets
4 participants