Skip to content

Allow OperationId to be passed through Image mgmt code#8147

Merged
lcastellano merged 1 commit intovmware:masterfrom
lcastellano:props
Aug 1, 2018
Merged

Allow OperationId to be passed through Image mgmt code#8147
lcastellano merged 1 commit intovmware:masterfrom
lcastellano:props

Conversation

@lcastellano
Copy link
Contributor

This PR implements code to pass the Operation ID through the subsystem responsible for downloading images.

@lcastellano lcastellano requested a review from a team as a code owner July 18, 2018 18:55
@lcastellano lcastellano requested review from hickeng and zjs July 18, 2018 18:55
@lcastellano lcastellano force-pushed the props branch 3 times, most recently from 9b0c801 to 0347c9d Compare July 19, 2018 18:19
"archive/tar"
"bytes"
"compress/gzip"
context "context"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is aliasing context to context and should not be necessary.

@@ -407,7 +407,7 @@ func (s *SystemBackend) AuthenticateToRegistry(ctx context.Context, authConfig *
log.Debugf("logging onto %s", authURL.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

This and a couple of other log.XXX calls should be updated to use the op.XXX equivalent.


if err != nil && options.InsecureAllowHTTP {
// try https without verification
log.Debugf("Trying https without verification, last error: %+v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

replace log.XXX with op.XXX, here and elsewhere in the function.

@@ -104,7 +104,8 @@ func (s *serialProgressOutput) stop() {
// It handles existing and simultaneous layer download de-duplication
// This code is utilizes Docker's xfer package: https://github.com/docker/docker/tree/v1.11.2/distribution/xfer
func (ldm *LayerDownloader) DownloadLayers(ctx context.Context, ic *ImageC) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm inclined to either:
a. have the exported methods using plain context.Context and calling trace.FromContext, or
b. have all of the methods taking trace.Operation

At the moment we have a mix (see lib/imagec/docker.go)

// Use the new context (created as part of Transfer) and the operation ID
// passed in from the callers
opID := op.ID()
op := trace.NewOperationFromID(d.Transfer.Context(), &opID, "makeDownloadFunc")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this shadowing of the op from the outer-outer function is a good idea. Can we make this new operation just after we initialize the new downloadTransfer structure and/or call it something different depending on whether it's supposed to override the outermost op.

func (ldm *LayerDownloader) makeDownloadFuncFromDownload(layer *ImageWithMeta, sourceDownload, parentDownload *downloadTransfer, layers []*ImageWithMeta) xfer.DoFunc {
func (ldm *LayerDownloader) makeDownloadFuncFromDownload(op trace.Operation, layer *ImageWithMeta, sourceDownload, parentDownload *downloadTransfer, layers []*ImageWithMeta) xfer.DoFunc {

return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) xfer.Transfer {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this function may need exactly the same change as made for makeDownloadFunc above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may need it in the future, but right now "op" is not used inside the body of the returned function

ic := imagec.NewImageC(options, streamformatter.NewJSONStreamFormatter())
if err := ic.PullImage(); err != nil {
if err := ic.PullImage(op); err != nil {
log.Fatalf("Pulling image failed due to %s\n", err)
Copy link
Member

Choose a reason for hiding this comment

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

It seems like it'd be useful to update the calls to log.* to use op.* in methods where you've introduced an op.

Copy link
Contributor

@hickeng hickeng left a comment

Choose a reason for hiding this comment

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

The unit test failures need to be addressed before this can merge: https://ci-vic.vmware.com/vmware/vic/19624

@lcastellano lcastellano force-pushed the props branch 2 times, most recently from bbd42da to 968b660 Compare July 31, 2018 17:25
@lcastellano lcastellano merged commit a43b205 into vmware:master Aug 1, 2018
@lcastellano lcastellano deleted the props branch August 1, 2018 19:11
hickeng pushed a commit to hickeng/vic that referenced this pull request Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants