Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

shimv2: Add a "--version" cli option #2887

Merged
merged 2 commits into from
Aug 25, 2020

Conversation

jodh-intel
Copy link
Contributor

All components should support a --version option to allow clear identification of the version of the component being used.

Note that the build changes are required to allow the shim binary to access the golang code generated by the build (such as the version variable).

This is a backport of kata-containers/kata-containers#308.

Fixes: #2886.

Signed-off-by: James O. D. Hunt [email protected]

Folded the overly long clean rule across multiple lines.

Signed-off-by: James O. D. Hunt <[email protected]>
Copy link

@devimc devimc left a comment

Choose a reason for hiding this comment

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

thanks @jodh-intel - one nit

func shimConfig(config *shim.Config) {
config.NoReaper = true
config.NoSubreaper = true
}

func main() {
shim.Run("io.containerd.kata.v2", containerdshim.New, shimConfig)
if len(os.Args) == 2 && os.Args[1] == "--version" {
Copy link

Choose a reason for hiding this comment

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

I wonder if this should be part of parseFlags() in shim.go, since --version is not displayed in the usage message

./containerd-shim-kata-v2 --help
Usage of ./containerd-shim-kata-v2:
  -address string
    	grpc address back to main containerd
  -bundle string
    	path to the bundle if not workdir
  -debug
    	enable debug output in logs
  -id string
    	id of the task
  -namespace string
    	namespace that owns the shim
  -publish-binary string
    	path to publish binary (used for publishing events) (default "containerd")
  -socket string
    	abstract socket path to serve

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @devimc - that's a good question. However, you can't call flag.Parse() twice: the first call wins meaning only --verbose would be recognised and the shim wouldn't work. Also, this is a backport from 2.0 so I'd like to keep it as similar as possible.

All components should support a `--version` option to allow clear
identification of the version of the component being used.

Note that the build changes are required to allow the shim binary to
access the golang code generated by the build
(such as the `version` variable).

Fixes: kata-containers#2886.

Signed-off-by: James O. D. Hunt <[email protected]>
@jodh-intel jodh-intel force-pushed the shimv2-add-version-flag branch from 1e74fd3 to 9bb8e36 Compare August 19, 2020 09:36
Copy link

@devimc devimc left a comment

Choose a reason for hiding this comment

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

thanks @jodh-intel

@jodh-intel
Copy link
Contributor Author

/test-ubuntu

@codecov
Copy link

codecov bot commented Aug 19, 2020

Codecov Report

Merging #2887 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2887      +/-   ##
==========================================
- Coverage   51.41%   51.40%   -0.01%     
==========================================
  Files         118      118              
  Lines       17434    17441       +7     
==========================================
+ Hits         8963     8965       +2     
- Misses       7388     7393       +5     
  Partials     1083     1083              

@jodh-intel jodh-intel merged commit 32db885 into kata-containers:master Aug 25, 2020
@jodh-intel jodh-intel added the backport Change from a newer branch / repository label Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport Change from a newer branch / repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add version cli option to shimv2
3 participants