service/progress: ServiceProgress: avoid fuzzy matching service ID in loop #5788
+18
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
service/progress: newReplicatedJobProgressUpdater: slight cleanup
Use intermediate vars, so that the replicatedJobProgressUpdater can
be created in one go intead of setting some fields after the fact.
service/progress: ServiceProgress: avoid fuzzy matching service ID in loop
Tasks with a service filter will result in the daemon performing a lookup
of the full service ID, then updating the provided filter with the actual
ID: https://github.com/moby/moby/blob/96ded2a1badcc5cb99d6d2ab7904d6f9e527cc4b/daemon/cluster/tasks.go#L15-L30
The
getService()
helper has a fast-path for situations where the givenfilter is a full ID, before falling back to fuzzy-logic to search filters
by service name or prefix, which would return an error if the result is
ambiguous;
https://github.com/moby/moby/blob/96ded2a1badcc5cb99d6d2ab7904d6f9e527cc4b/daemon/cluster/helpers.go#L62-L81
The loop executed here calls
client.ServiceInspectWithRaw()
to get infoof the service, and that method is ultimately calling the exact same
getService()
helper on the daemon side, which means that we don't needto repeat the work; we can use the
Service.ID
resolved from that call,and use it to apply as filter for listing the tasks.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)