-
Notifications
You must be signed in to change notification settings - Fork 74
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
Refresh SA auth token in signaturediscovery client before fetching container image signatures #449
Conversation
9904833
to
ed0f812
Compare
efb0f2d
to
bc27300
Compare
) | ||
|
||
const signatureTagSuffix = "sig" | ||
|
||
type ( | ||
oauth2TokenFetcher func(context.Context) (oauth2.Token, error) |
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.
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
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.
Done.
launcher/auth/auth.go
Outdated
@@ -1,4 +1,5 @@ | |||
package launcher | |||
// Package auth contains functionalities to authenticate docker repo. | |||
package auth |
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.
Like having a new Resolver in this package that takes in mds client instead of the token
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.
Done.
bc27300
to
cbc5822
Compare
launcher/auth/auth.go
Outdated
@@ -1,8 +1,10 @@ | |||
package launcher | |||
// Package auth contains functionalities to authenticate docker repo. |
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.
This would be better named something like registryauth.
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 comment this as a breaking change in the PR description
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.
Done.
OriginalImageDesc v1.Descriptor | ||
RemoteOpts []containerd.RemoteOpt | ||
refreshResolver remoteResolverFetcher |
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.
remoteResolverFetcher
or refreshedResolverFetcher
to match the name below.
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.
Done.
cbc5822
to
5ce689e
Compare
5ce689e
to
ad7225e
Compare
/gcbrun |
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:
auth.go
to from packagelauncher
a to a new sub-packagegithub.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.