ServiceCreate/ServiceUpdate: refactor and fix potential NPE#40826
Merged
tiborvass merged 3 commits intomoby:masterfrom Jul 28, 2020
Merged
ServiceCreate/ServiceUpdate: refactor and fix potential NPE#40826tiborvass merged 3 commits intomoby:masterfrom
tiborvass merged 3 commits intomoby:masterfrom
Conversation
- `ContainerSpec` and `PluginSpec` are mutually exclusive, so instead of using two separate if-statements, combine them in a switch. - Use local variables (at cost of some slight duplication) - Fix a potential NPE if image-digest resolution failed for a `PluginSpec`. The code was always using `ContainerSpec.Image` to create a `digestWarning`, but in case we're resoling the digest for a `PluginSpec`, `ContainerSpec` will be `nil` (as they're mutually exclusive). This issue was introduced in 72c3bcf, where the new `PluginSpec` path was added. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Instead of returning an empty string, return the image unmodified Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
03aa8f2 to
ed09653
Compare
Member
Author
|
🤦 made a whoopsie; fixed now @cpuguy83 ptal |
Member
Author
|
Did this one become flaky again? (it was in the past) |
Member
Author
|
@tonistiigi @cpuguy83 PTAL 🤗 |
tiborvass
approved these changes
Jul 28, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ContainerSpecandPluginSpecare mutually exclusive, so instead of using two separate if-statements, combine them in a switch.PluginSpec. The code was always usingContainerSpec.Imageto create adigestWarning, but in case we're resoling the digest for aPluginSpec,ContainerSpecwill benil(as they're mutually exclusive). This issue was introduced in 72c3bcf (Plugins on swarm #33575), where the newPluginSpecpath was added.Instead of returning an empty string, return the image unmodified