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

Refresh SA auth token in signaturediscovery client before fetching container image signatures #449

Merged
merged 1 commit into from
May 17, 2024

Conversation

yawangwang
Copy link
Collaborator

@yawangwang yawangwang commented May 9, 2024

Currently we only fetch the VM SA once, for the purpose of downloading workload image from Artifact registry.
But it doesn't work well for long running workloads because the VM SA token will expire after 1 hr, and thus lead to 401 errors when the signaturediscovery client tries to fetch image signatures periodically.
We'll need to refresh the resolver for signaturediscovery client to authenticate with the target docker repo before fetching container signatures.

Breaking changes:

  • move auth.go to from package launcher a to a new sub-package github.com/google/go-tpm-tools/launcher/registryauth so that auth utilities can be used cross packages. Add a new method that takes in a metadata server client and returns a refreshed remote resolver.
  • refactor of signaturesdiscovery client to be able to refresh resolver before pulling docker image.

@yawangwang yawangwang force-pushed the fix-vm-sa-credential-expire branch from 9904833 to ed0f812 Compare May 9, 2024 20:30
@yawangwang yawangwang changed the title Refresh SA auth token before fetching container image signatures Refresh SA auth token in signaturediscovery client before fetching container image signatures May 9, 2024
@yawangwang yawangwang force-pushed the fix-vm-sa-credential-expire branch 3 times, most recently from efb0f2d to bc27300 Compare May 9, 2024 20:54
@yawangwang yawangwang marked this pull request as ready for review May 9, 2024 22:32
)

const signatureTagSuffix = "sig"

type (
oauth2TokenFetcher func(context.Context) (oauth2.Token, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having the logic in the signature client, can we move it to auth.go package? So the resolver can handle the token fetching itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -1,4 +1,5 @@
package launcher
// Package auth contains functionalities to authenticate docker repo.
package auth
Copy link
Contributor

Choose a reason for hiding this comment

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

Like having a new Resolver in this package that takes in mds client instead of the token

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@yawangwang yawangwang force-pushed the fix-vm-sa-credential-expire branch from bc27300 to cbc5822 Compare May 10, 2024 22:52
@yawangwang yawangwang requested a review from jkl73 May 10, 2024 22:55
@@ -1,8 +1,10 @@
package launcher
// Package auth contains functionalities to authenticate docker repo.
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be better named something like registryauth.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please comment this as a breaking change in the PR description

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

OriginalImageDesc v1.Descriptor
RemoteOpts []containerd.RemoteOpt
refreshResolver remoteResolverFetcher
Copy link
Contributor

Choose a reason for hiding this comment

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

remoteResolverFetcher or refreshedResolverFetcher to match the name below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@yawangwang yawangwang force-pushed the fix-vm-sa-credential-expire branch from cbc5822 to 5ce689e Compare May 16, 2024 21:37

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@yawangwang yawangwang force-pushed the fix-vm-sa-credential-expire branch from 5ce689e to ad7225e Compare May 16, 2024 21:41
@yawangwang
Copy link
Collaborator Author

/gcbrun

@yawangwang yawangwang merged commit 3710f6b into google:main May 17, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants