Add configuration validation option.#38138
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38138 +/- ##
==========================================
+ Coverage 36.18% 36.70% +0.52%
==========================================
Files 610 608 -2
Lines 45363 45082 -281
==========================================
+ Hits 16413 16547 +134
+ Misses 26707 26252 -455
- Partials 2243 2283 +40 |
|
@justrich this one need to be rebased |
|
(reserved for my derek comments) |
|
@thaJeztah FYI. this looks to be updated based on your review and passing CI (except codecov/patch). |
cmd/dockerd/options.go
Outdated
There was a problem hiding this comment.
We're generally conservative when adding single-letter flags, and want to reserve new ones for "frequently used options"; could you remove the -V shorthand? (It's easy to add in future if we see a need, but it's much harder to remove an option, once it's been released 😅)
| flags.BoolVarP(&o.Validate, "validate", "V", false, "Validate configuration file and exit") | |
| flags.BoolVar(&o.Validate, "validate", false, "Validate configuration file and exit") |
thaJeztah
left a comment
There was a problem hiding this comment.
forgot about this one. I think this one is good to have (docker/cli#1922 would still be useful to have as well, but is orthogonal to this change)
LGTM
(I did a quick rebase to trigger CI again)
|
@AkihiroSuda @tiborvass PTAL |
|
LGTM, but https://ci-next.docker.com/public/job/moby/job/PR-38138/2/display/redirect is now 404, so I can't click the "restart CI" button. Could you rebase to retrigger CI? |
|
Oh; I think editing the top-comment triggers ci (neat little trick); let me try |
|
Yup, that worked 😂. I think it's a bug in how jenkins is triggered, but comes in handy sometimes |
|
Failing CI; I guess it needs a rebase to get some CI fixes in; let me do so |
|
Fixes moby#36911 Add a command line option. Add option to exit before daemon startup if validating config. If config file is invalid we'll exit anyhow, so this just prevents the daemon from starting if the configuration is fine. Mainly useful for making config changes and restarting the daemon iff the config is valid. Signed-off-by: Rich Horwood <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
|
Fixed the above; |
| if opts.Validate { | ||
| // If config wasn't OK we wouldn't have made it this far. | ||
| logrus.Infof("Config OK") | ||
| os.Exit(0) |
There was a problem hiding this comment.
IMO, we should be careful use os.Exit and let the program exit immediately in big program, this may cause some defer doesn't perform and then left with some uncleaned resoure. https://gobyexample.com/exit It's better to return a state to the caller.
There was a problem hiding this comment.
Oh, good one, actually didn't know that.
Yes, looks like that would cause some things to not be run
Lines 77 to 83 in 94c0744
Thinking how we can achieve this; we could return a "special" error, but that may need handling of that error is various places to make sure we still still the daemon, but with a zero exit code.
|
Moved back to "code review" because of #38138 (comment); will have a look if there's a different approach possible |

Fixes #36911
Add a command line option.
Add option to exit before daemon startup if validating config.
If config file is invalid we'll exit anyhow, so this just prevents
the daemon from starting if the configuration is fine.
Mainly useful for making config changes and restarting the daemon
iff the config is valid.
Signed-off-by: Rich Horwood [email protected]
- What I did
- How I did it
- How to verify it
- Description for the changelog
Add option to validate daemon configuration file and exit.
- A picture of a cute animal (not mandatory but encouraged)