Skip to content
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

Add logMirrorChoice to ctx for log #1099

Merged
merged 1 commit into from Jan 9, 2021
Merged

Conversation

QiWang19
Copy link
Collaborator

@QiWang19 QiWang19 commented Dec 9, 2020

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1881694
This BZ needs change the log level of the image pull location from the debug to info.
Add DockerLogMirrorChoice to types.SystemContext for keeping log level of the physical pull source of images.
Crio could set it to log the image source if it's from a mirror.

Signed-off-by: Qi Wang qiwan@redhat.com

@rhatdan
Copy link
Member

rhatdan commented Dec 9, 2020

LGTM

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

LGTM

@umohnani8
Copy link
Contributor

LGTM

@mtrmac
Copy link
Collaborator

mtrmac commented Dec 9, 2020

I get that this is an “easy quick improvement”, and I don’t have any similarly easy suggestion, but I’m not too happy about a library just logging like this without giving the caller much say in where the log goes, especially on such a frequent path that everyone is going to hit.

Conceptually this probably belongs into the copy.Options.Progress log stream, as a well-typed data structure — but getting the data there would involve changing the ImageSource interface.

@QiWang19
Copy link
Collaborator Author

Could you explain why it would be better to be in copy.Options.Progress log stream, I am not very familiar with it, what is copy.Options.Progress log stream, related with https://github.com/containers/image/blob/master/copy/progress_reader.go?
Will that log show up in crio logs?

@mtrmac
Copy link
Collaborator

mtrmac commented Dec 11, 2020

Yes, that’s the major current producer (+ one event after TryReusingBlob succeeds). The point is to make these things observable by software as an API, not to produce a formatted text that’s impossible to work with because it can change any time.

Notably CRI-O is using that interface already: https://github.com/cri-o/cri-o/blob/8a05a29873456911db9a5c85a8d569e4a0db0ee3/server/image_pull.go#L171

It’s, for the most part, not the job of c/image to provide an UI, but it should allow callers to create an UI. (OTOH, admittedly, copy.Image does create progress bars, and it is expected to write something undefined to copy.Options.ReportWriter.)

copy.Image is required to write important information to the log stream” just does not feel like a good fit in that context; it’s not a sustainable way to define or maintain an API.

Or maybe the mirror choice could go to ReportWriter, sure. That would make it user-readable but not software-consumable, not as good as Progress but better than just the indiscriminate log.

Either way we’re looking at some kind of API break to ImageSource, something that we do need to be able to do eventually but much more work than this is probably worth — the customers in this case could just bump CRI-O to debug mode for the time necessary to test mirroring (or, well, monitor the network externally), if I understand the situation correctly.


I suppose one way to shut me up is to gate this behind a types.SystemContext.DockerLogMirrorChoice opt-in or something like that, making it an ”obscure implementation aspect of the Docker transport that CRI-O specifically knows about”, rather than a design pattern in c/image. OTOH that also could become a very bad precedent.

@QiWang19 QiWang19 changed the title Change pull log-level from debug to info Add pullSpurce to ctx for log Dec 16, 2020
docker/docker_image_src.go Outdated Show resolved Hide resolved
@QiWang19 QiWang19 changed the title Add pullSpurce to ctx for log Add logMirrorChoice to ctx for log Dec 17, 2020
@QiWang19
Copy link
Collaborator Author

@mtrmac PTAL. Change to use the DockerLogMirrorChoice to avoid send the sys back to cri-o.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM. I’m not happy about this but blocking this small improvement on building infrastructure for ImageSource API changes is not proportionate.

Add DockerLogMirrorChoice to types.SystemContext for keeping log level of the physical pull source of images.
Crio could set it log the image source if it's from a mirror.

Signed-off-by: Qi Wang <qiwan@redhat.com>
@mtrmac mtrmac merged commit 7767b3c into containers:master Jan 9, 2021
@QiWang19 QiWang19 deleted the info-pull branch January 10, 2021 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants