generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 75
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
iterate on geranos MVP #155
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/awserr" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/s3/s3manager" | ||
|
@@ -32,22 +33,32 @@ import ( | |
) | ||
|
||
// see cmd/archeio, this matches the layout of GCR's GCS bucket | ||
const blobKeyPrefix = "/containers/images/" | ||
// containers/images/sha256:$layer_digest | ||
const blobKeyPrefix = "containers/images/" | ||
|
||
type s3Uploader struct { | ||
svc *s3.S3 | ||
uploader *s3manager.Uploader | ||
skipExisting bool | ||
dryRun bool | ||
svc *s3.S3 | ||
uploader *s3manager.Uploader | ||
reuploadLayers bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look like this is used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is read. It is not yet written. |
||
dryRun bool | ||
} | ||
|
||
func newS3Uploader() (*s3Uploader, error) { | ||
sess, err := session.NewSession() | ||
func newS3Uploader(dryRun bool) (*s3Uploader, error) { | ||
cfg := []*aws.Config{} | ||
// force anonymous configs for dry run uploaders | ||
if dryRun { | ||
cfg = append(cfg, &aws.Config{ | ||
Credentials: credentials.AnonymousCredentials, | ||
}) | ||
} | ||
sess, err := session.NewSession(cfg...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
r := &s3Uploader{} | ||
r.svc = s3.New(sess) | ||
r := &s3Uploader{ | ||
dryRun: dryRun, | ||
svc: s3.New(sess), | ||
} | ||
r.uploader = s3manager.NewUploaderWithClient(r.svc) | ||
return r, nil | ||
} | ||
|
@@ -58,11 +69,12 @@ func (s *s3Uploader) CopyToS3(bucket string, layer v1.Layer) error { | |
return err | ||
} | ||
key := keyForLayer(digest) | ||
if s.skipExisting { | ||
if !s.reuploadLayers { | ||
exists, err := s.blobExists(bucket, key) | ||
if err != nil { | ||
klog.Errorf("failed to check if blob exists: %v", err) | ||
} else if exists { | ||
klog.Infof("Layer already exists: %s", key) | ||
return nil | ||
} | ||
} | ||
|
@@ -86,7 +98,7 @@ func (s *s3Uploader) CopyToS3(bucket string, layer v1.Layer) error { | |
uploadInput.ChecksumSHA256 = aws.String(base64.StdEncoding.EncodeToString(b)) | ||
} | ||
// skip actually uploading if this is a dry-run, otherwise finally upload | ||
klog.Infof("Uploading Layer: %s", key) | ||
klog.Infof("Uploading layer: %s", key) | ||
if s.dryRun { | ||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm new here, so maybe this makes more sense to everyone else.
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 default for now is to do a dry run. This would invert that default.