daemon/c8d: Implement docker tag#44781
Conversation
| err := is.Delete(ctx, img.Name) | ||
|
|
||
| if err != nil { | ||
| logger.WithError(err).Error("failed to delete old image") |
There was a problem hiding this comment.
The other logs are Debug these could be too no?
There was a problem hiding this comment.
My reasoning was that the first one can be Debug, because it mostly should be just an user error (non existing id) and it's kind of expected to happen normally.
But if the image couldn't be created and it's not an "already exists" error, then probably it's something that's not expected to happen under normal circumstances s and it's worth having logging without debug enabled.
There was a problem hiding this comment.
But if the image couldn't be created and it's not an "already exists" error, then probably it's something that's not expected to happen under normal circumstances s and it's worth having logging without debug enabled.
That one should probably be an Error(), as it's an unexpected error (and we currently return a errdefs.System() (internal server error).
There was a problem hiding this comment.
Really we shouldn't need to log and return an error.
There was a problem hiding this comment.
The log has additional information about the context (imageID, tag) - which might be useful when debugging failures. The only caveat is that these will only appear in the daemon log.
Should we drop the logging and just include these in the returned error?
There was a problem hiding this comment.
I think it makes sense to include it in the error.
There was a problem hiding this comment.
Removed the extra logrus logs and included details directly in returned errors.
|
CI failures are related, will fix those. |
0bfe16f to
070f6a0
Compare
| if err != nil { | ||
| if !cerrdefs.IsAlreadyExists(err) { | ||
| logger.WithError(err).Debug("failed to create image") | ||
| return errdefs.System(err) |
There was a problem hiding this comment.
Do we know what errors this can return, and if they should always be considered an internal server error? (does is.Create() return typed errors from containerd, and can any of those be a "user error" (4xx)?
(Perhaps a 5xx is okay in all cases, but might be worth checking and/or a comment to outline that irregardless of the error type, we consider it an internal server error).
There was a problem hiding this comment.
Yeah definitely there are some errors which shouldn't be considered a server error, like: missing name, labels too big. Those are the minority of all errors that could be returned though. The rest look system related (grpc, internal storage failures).
I think we should keep this as System, but validate the image ourselves before calling is.Create() and return an user error.
There was a problem hiding this comment.
Actually, in this case already have a valid reference which is a valid image name. So it's not possible for this one to fail with user user. Will change the Debug to Error log then.
070f6a0 to
c8b96ac
Compare
c8b96ac to
03a38c9
Compare
03a38c9 to
eaf7acb
Compare
eaf7acb to
47569ba
Compare
d29316b to
0e41b77
Compare
| // Error out in case we couldn't persist the old image. | ||
| // If it already exists, then just continue. | ||
| if err != nil && !cerrdefs.IsAlreadyExists(err) { | ||
| logger.WithError(err).Error("failed to create a dangling image for the image being replaced") |
There was a problem hiding this comment.
Same as above, we shouldn't need to log and return an error.
neersighted
left a comment
There was a problem hiding this comment.
Would like to see the following changes:
- Amending commits squashed, TODOs between commits minimized
- Don't override
ctx TagImageinstead ofTagImageWithReferencewould be nice
I feel like you may have preferred TagImageWithReference over TagImage as it makes the need to create the correct reference first clear. It looks like there's common that does this shared between the tag API and the commit code.
Can we consider DRYing that up? It seems possible we could preserve TagImage as a fully encapsulated version, though on the other hand, the need for TagImageWithReference would be decreased. In any case, I'd like the logic of creating the reference to be de-duplicated and contained in the tagging code, if possible.
vvoland
left a comment
There was a problem hiding this comment.
Squashed, removed the ctx overriding and changed TagImageWithReference into TagImage.
I still kept the reference parsing logic outside of tagging code - I don't see how it belongs here, many operations should make sure the reference is valid, before attempting the tag, so they already have a parsed reference. Also it feel weird to make ImageService responsible for parsing that.
I moved the reference parsing from commit to the caller code and made it accept a NamedParsed reference instead. The parsing logic is extracted to httputils as for now only http handlers parse the reference, but ideally this should probably belong to the reference package,
| err := is.Delete(ctx, img.Name) | ||
|
|
||
| if err != nil { | ||
| logger.WithError(err).Error("failed to delete old image") |
There was a problem hiding this comment.
The log has additional information about the context (imageID, tag) - which might be useful when debugging failures. The only caveat is that these will only appear in the daemon log.
Should we drop the logging and just include these in the returned error?
1eb14ec to
b2d47f2
Compare
b2d47f2 to
f539043
Compare
neersighted
left a comment
There was a problem hiding this comment.
Updating my review: LGTM with the exception of dropping the unused method causing a linter error.
f539043 to
c364411
Compare
|
I'd like to see @cpuguy83's logging concerns addressed (looks like he didn't mark them as changes requested). Looks ready to merge once he gives his sign-off. |
b8f4126 to
12efc2d
Compare
|
Let's |
|
arf.. running into the "dubious permissions" issue; @vvoland can you try rebasing? |
Signed-off-by: Nicolas De Loof <[email protected]> Signed-off-by: Paweł Gronowski <[email protected]>
TagImage is just a wrapper for TagImageWithReference which parses the repo and tag into a reference. Change TagImageWithReference into TagImage and move the responsibility of reference parsing to caller. Signed-off-by: Paweł Gronowski <[email protected]>
Implements image tagging under containerd image store. If an image with this tag already exists, and there's no other image with the same target, change its name. The name will have a special format `moby-dangling@<digest>` which isn't a valid canonical reference and doesn't resolve to any repository. Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Paweł Gronowski <[email protected]>
12efc2d to
62be425
Compare
|
@thaJeztah Rebased |
|
Thanks! |
- What I did
Implement
docker tagfor containerd image store.- How I did it
See individual commits.
- How to verify it
Tag replace
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
