Skip to content

ServiceCreate/ServiceUpdate: refactor and fix potential NPE#40826

Merged
tiborvass merged 3 commits intomoby:masterfrom
thaJeztah:cleanup_service
Jul 28, 2020
Merged

ServiceCreate/ServiceUpdate: refactor and fix potential NPE#40826
tiborvass merged 3 commits intomoby:masterfrom
thaJeztah:cleanup_service

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

  • 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 (Plugins on swarm #33575), where the new PluginSpec path was added.
  • imageWithDigestString: return image unmodified if there are no changes
    Instead of returning an empty string, return the image unmodified
  • extract logic for resolving image/plugin digest and platform

- `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]>
@thaJeztah thaJeztah added status/2-code-review area/swarm kind/bugfix PR's that fix bugs kind/refactor PR's that refactor, or clean-up code labels Apr 16, 2020
@thaJeztah thaJeztah requested a review from cpuguy83 April 16, 2020 11:55
@thaJeztah
Copy link
Copy Markdown
Member Author

🤦 made a whoopsie; fixed now

@cpuguy83 ptal

@thaJeztah
Copy link
Copy Markdown
Member Author

Did this one become flaky again? (it was in the past)

=== RUN   TestDockerSuite/TestLogsFollowSlowStdoutConsumer
    --- FAIL: TestDockerSuite/TestLogsFollowSlowStdoutConsumer (1.81s)
        docker_cli_logs_test.go:243: assertion failed: error is not nil: exit status 1

@thaJeztah
Copy link
Copy Markdown
Member Author

@tonistiigi @cpuguy83 PTAL 🤗

Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@tiborvass tiborvass merged commit ca689bf into moby:master Jul 28, 2020
@thaJeztah thaJeztah deleted the cleanup_service branch July 28, 2020 10:05
@thaJeztah thaJeztah added this to the 20.03.0 milestone Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/swarm kind/bugfix PR's that fix bugs kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants