Replace platforms.Format with platforms.FormatAll in user-visible messages and logs.#49973
Replace platforms.Format with platforms.FormatAll in user-visible messages and logs.#49973vvoland merged 2 commits intomoby:masterfrom
Conversation
|
We should probably not mark the ticket as fixed until we reviewed the remaining uses (I changed the "fixes" to "addresses"); we can do those separately (changes in this PR look good AFAICS), but make sure that we're not accidentally dropping os.version in places where it shouldn't be dropped. I had a quick peek (if my IDE is not lying to me), and outside of vendor code, and the good news is that the list is not too long, so probably doable in a follow-up. I found the remaining uses here; moby/builder/builder-next/adapters/containerimage/pull.go Lines 184 to 185 in 294f0c3 moby/builder/builder-next/worker/worker.go Lines 163 to 166 in 294f0c3 moby/daemon/containerd/image_pull.go Lines 79 to 82 in 294f0c3 moby/internal/testutils/specialimage/multiplatform.go Lines 18 to 20 in 294f0c3 moby/internal/testutils/specialimage/partial.go Lines 28 to 30 in 294f0c3 |
| platform = *pp | ||
| } | ||
| log.G(ctx).Debugf("%s resolved to a manifestList object with %d entries; looking for a %s match", ref, len(mfstList.Manifests), platforms.Format(platform)) | ||
| log.G(ctx).Debugf("%s resolved to a manifestList object with %d entries; looking for a %s match", ref, len(mfstList.Manifests), platforms.FormatAll(platform)) |
There was a problem hiding this comment.
Not for this PR, but we should use structured logs more for entries like these; ideally we would review the names we used for fields in those logs (as I think we're not always consistent); having more structured logs allows easier filtering / querying of logs (more so if they carry consistent fields, which allows correlating logs).
Thanks @thaJeztah; yes I saw those remaining instances too, but wasn't sure if the change should apply to them because they are functional changes (as opposed to logging / messaging changes). I'll take a closer look and do another commit on this PR. |
Done with this, I've added a second commit to this PR; see 7a57e73. |
| // key is used to synchronize resolutions that can happen in parallel when doing multi-stage. | ||
| key := "getconfig::" + ref + "::" + platforms.Format(p) | ||
| key := "getconfig::" + ref + "::" + platforms.FormatAll(p) |
There was a problem hiding this comment.
Could use some extra eyes on this one if changing this one is OK to do
There was a problem hiding this comment.
@tonistiigi: does this PR look OK (in particular the use of FormatAll() above).
tonistiigi
left a comment
There was a problem hiding this comment.
This is ok in user messages but may not be fine in places where platform string is passed as input.
| pm := make(map[string]struct{}, len(w.Opt.Platforms)) | ||
| for _, p := range w.Opt.Platforms { | ||
| pm[platforms.Format(p)] = struct{}{} | ||
| pm[platforms.FormatAll(p)] = struct{}{} |
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks; I get what you are recommending, but that seems outside the scope of this PR (i.e., you are suggesting a refactoring of the entire function, where as this PR is simply about replacing Format() with FormatAll()).
Can we do what you are suggesting in a follow-up PR?
There was a problem hiding this comment.
Then don't make changes to this part of the code.
There was a problem hiding this comment.
Just so I understand: is that because the change I am proposing incorrect? If so where, I don't see the error (and CI is green).
There was a problem hiding this comment.
The old code is incorrect and the new code is incorrect as well. OSVersion would be incorrect in here in any case.
There was a problem hiding this comment.
Got it, thanks, I've reverted that part of the change.
There was a problem hiding this comment.
I assume the change in builder/builder-next/adapters/containerimage/pull.go looks good to you?
There was a problem hiding this comment.
Oh, never mind; I looked at the wrong part of the diff 🙈 ignore me.
|
We could probably move the second commit to a separate PR if that one still needs looking at (assuming the first one was green) |
…sages and logs. Use FormatAll in user-visible messages and logs, since it includes the image's platform OS version (when set). Fixes moby#48659. Signed-off-by: Cesar Talledo <[email protected]>
No need, CI is green now (I rebased from |
Signed-off-by: Cesar Talledo <[email protected]>
|
Also @vvoland PTAL (you have a "request changes" pending) |
- What I did
Use
platforms.FormatAll(instead ofplatforms.Format) in user-visible messages and logs, since it includes the image's platform OS version (when set).