-
Notifications
You must be signed in to change notification settings - Fork 18.9k
daemon: ImageService.LogImageEvent: pass through context #49014
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,8 @@ import ( | |
| ) | ||
|
|
||
| // LogImageEvent generates an event related to an image with only the default attributes. | ||
| func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action) { | ||
| ctx := context.TODO() | ||
| func (i *ImageService) LogImageEvent(ctx context.Context, imageID, refName string, action events.Action) { | ||
| ctx = context.WithoutCancel(ctx) | ||
| attributes := map[string]string{} | ||
|
|
||
| img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{}) | ||
|
Member
Author
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. Wonder if this needs some WithoutCancel as it's called on
Contributor
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. I think it depends on the case. The only usage in Which definitely would need a
Member
Author
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. Yeah, makes sense; I first peeked at the code below this line, and it should handle cancelled contexts gracefully (in which case it just skips image-labels in the event), so probably still would be ok. Looking at that one case where we use
Member
Author
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.
Contributor
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. OTOH, given our current usages, it would make sense to make UNLESS, the calling function would actually be able to roll-back the effects that the event advertises. So, given the above, I think it's also fine to just slap a
Member
Author
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. Yeah, perhaps that makes sense. My slight concern was if the |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,8 @@ import ( | |
| ) | ||
|
|
||
| // LogImageEvent generates an event related to an image with only the default attributes. | ||
| func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action) { | ||
| ctx := context.TODO() | ||
| func (i *ImageService) LogImageEvent(ctx context.Context, imageID, refName string, action events.Action) { | ||
| ctx = context.WithoutCancel(ctx) | ||
|
Comment on lines
+11
to
+12
Member
Author
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. I moved the |
||
| attributes := map[string]string{} | ||
|
|
||
| img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{}) | ||
|
|
||
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.
Same here