Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: make kata-check check for newer release #735

Conversation

jodh-intel
Copy link
Contributor

Update kata-check to see if there is a newer version available for download. Useful for users installing static packages (without a package manager).

Fixes: #734.

Signed-off-by: James O. D. Hunt james.o.hunt@intel.com

@jodh-intel
Copy link
Contributor Author

/test

@jodh-intel jodh-intel force-pushed the 2.0-dev-kata-check-compare-versions branch from 84410f5 to 43f0328 Compare September 16, 2020 11:26
@jodh-intel
Copy link
Contributor Author

This won't work for 2.0 yet as we haven't made any releases:

$ ./kata-runtime kata-check --verbose
INFO[0000] IOMMUPlatform is disabled by default.
INFO[0000]                                               arch=amd64 current-version=2.0.0-alpha3 name=kata-runtime pid=21324 source=runtime
No releases available

... But you can test how it would work for Kata 1.x by setting the KATA_RELEASE_URL env var:

$ KATA_RELEASE_URL=https://api.github.com/repos/kata-containers/runtime/releases/latest ./kata-runtime kata-check --verbose
INFO[0000] IOMMUPlatform is disabled by default.
INFO[0000]                                               arch=amd64 current-version=2.0.0-alpha3 latest-version=1.11.3 name=kata-runtime pid=21336 source=runtime
No newer release available for download

Notice the latest-version=1.11.3 output, corresponding to https://github.com/kata-containers/runtime/releases.

@fidencio
Copy link
Member

@jodh-intel, first of all, patch itself looks good, thanks for working on this one!

Shall we ensure only official releases are used? If so, we could do that by enforcing a URL check and aborting if the URL doesn't point to the official repos.

@jodh-intel jodh-intel force-pushed the 2.0-dev-kata-check-compare-versions branch from 43f0328 to a92af46 Compare September 16, 2020 13:04
@jodh-intel
Copy link
Contributor Author

@fidencio - agreed and fixed 😄

@jodh-intel
Copy link
Contributor Author

jodh-intel commented Sep 16, 2020

$ KATA_RELEASE_URL=https://google.com ./kata-runtime kata-check
INFO[0000] IOMMUPlatform is disabled by default.
ERRO[0000] release URL "https://google.com" does not have expected prefix: "https://api.github.com/repos/kata-containers"  arch=amd64 name=kata-runtime pid=24115 source=runtime
release URL "https://google.com" does not have expected prefix: "https://api.github.com/repos/kata-containers"
$ echo $?
1

@jodh-intel
Copy link
Contributor Author

/test

Copy link
Member

@fidencio fidencio left a comment

Choose a reason for hiding this comment

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

lgtm!

Thanks, @jodh-intel!

projectAPIURLPrefix = "https://api.github.com/repos/kata-containers"

// URL used to determine latest release
defaultReleaseURL = projectAPIURLPrefix + "/kata-containers/releases/latest"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Marking as dnm for now since this isn't reliable - the "latest" release is simply the most recently uploaded release! The correct solution is to look through all releases, sort by semver and find the newest from that.

Thanks @jcvenegas for pointing this out!

@jodh-intel jodh-intel added the do-not-merge PR has problems or depends on another label Sep 17, 2020
@jodh-intel jodh-intel force-pushed the 2.0-dev-kata-check-compare-versions branch from a92af46 to 59598e7 Compare September 21, 2020 09:02
@jodh-intel jodh-intel removed the do-not-merge PR has problems or depends on another label Sep 21, 2020
@jodh-intel
Copy link
Contributor Author

Thanks for reviewing @fidencio - I've just updated the branch quite a lot if you want to take another look?

/test

@jodh-intel jodh-intel force-pushed the 2.0-dev-kata-check-compare-versions branch 2 times, most recently from 641b7fb to 547b3d9 Compare September 21, 2020 09:57
@jodh-intel
Copy link
Contributor Author

/test

@jodh-intel
Copy link
Contributor Author

@GabyCT, @lifupan - the clh CI is failing - looks like we might need to source ~/.cargo/env?:

11:19:31 Rust is installed now. Great!

    :

11:23:36 + rustup show
11:23:36 /tmp/jenkins/workspace/jobs-2.0/kata-2-ubuntu-1804-PR-cloud-hypeprvisor-k8s-containerd/go/src/github.com/kata-containers/kata-containers/tools/osbuilder/rootfs-builder/rootfs.sh: line 544: rustup: command not found

Update `kata-check` to see if there is a newer version available for
download. Useful for users installing static packages (without a package
manager).

Fixes: kata-containers#734.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@jodh-intel jodh-intel force-pushed the 2.0-dev-kata-check-compare-versions branch from 547b3d9 to 1a77f69 Compare September 21, 2020 12:47
@jodh-intel
Copy link
Contributor Author

Example behaviour:

  • Kata 2.0 isn't available yet:

    $ kata-runtime kata-check 2>&1|grep release
    No releases available
  • But pre-release versions are:

    $ kata-runtime kata-check --include-all-releases 2>&1|grep release
    Newer pre-release release available: 2.0.0-rc0 (url: https://github.com/kata-containers/kata-containers/releases/download/2.0.0-rc0/kata-static-2.0.0-rc0-x86_64.tar.xz, date: 2020-09-20T11:05:25Z)
  • List of releases available from the Kata 2.x repo (none!):

    $ kata-runtime kata-check --only-list-releases 2>&1|grep release
    $
  • But there are some pre-release versions:

    $ kata-runtime kata-check --only-list-releases --include-all-releases 2>&1|grep release
    2.0.0-alpha1;2020-06-06T14:36:48Z;https://github.com/kata-containers/kata-containers/releases/download/2.0.0-alpha1/kata-static-2.0.0-alpha1-x86_64.tar.xz
    2.0.0-alpha2;2020-06-28T05:54:13Z;https://github.com/kata-containers/kata-containers/releases/download/2.0.0-alpha2/kata-static-2.0.0-alpha2-x86_64.tar.xz
    2.0.0-alpha3;2020-07-29T09:02:56Z;https://github.com/kata-containers/kata-containers/releases/download/2.0.0-alpha3/kata-static-2.0.0-alpha3-x86_64.tar.xz
    2.0.0-rc0;2020-09-20T11:05:25Z;https://github.com/kata-containers/kata-containers/releases/download/2.0.0-rc0/kata-static-2.0.0-rc0-x86_64.tar.xz
    $

Newly expanded kata-check usage:

$ ./kata-runtime kata-check --help
NAME:
   kata-runtime kata-check - tests if system can run Kata Containers

USAGE:
   kata-runtime kata-check [command options] [arguments...]

DESCRIPTION:
   tests if system can run Kata Containers and version is current.

ENVIRONMENT VARIABLES:

- KATA_CHECK_NO_NETWORK: If set to any value, act as if "--no-network-checks" was specified.

EXAMPLES:

- Perform basic checks:

  $ kata-runtime kata-check

- Local basic checks only:

  $ kata-runtime kata-check --no-network-checks

- Perform further checks:

  $ sudo kata-runtime kata-check

- Just check if a newer version is available:

  $ kata-runtime kata-check --check-version-only

- List available releases (shows output in format "version;release-date;url"):

  $ kata-runtime kata-check --only-list-releases

- List all available releases (includes pre-release versions):

  $ kata-runtime kata-check --only-list-releases --include-all-releases


OPTIONS:
   --check-version-only     Only compare the current and latest available versions (requires network, non-root only)
   --include-all-releases   Don't filter out pre-release release versions
   --no-network-checks, -n  Do not run any checks using the network
   --only-list-releases     Only list newer available releases (non-root only)
   --strict, -s             perform strict checking
   --verbose, -v            display the list of checks performed

@jodh-intel
Copy link
Contributor Author

/test

@fidencio
Copy link
Member

Thanks for reviewing @fidencio - I've just updated the branch quite a lot if you want to take another look?

Looks even better now! You already have my lgtm, thanks for working on this!

@jodh-intel
Copy link
Contributor Author

Ping @bergwolf, @devimc.

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

This PR does change the behaviour of kata-check slightly since it will now hit the network to check for a new release by default. That was done by design to make it more difficult for users to either ignore or be unaware of new releases. Since as more and more installations are using the binary packages (without a package manager), the ability to determine whether a new release is available is necessary to ensure those installations have the best chance of being updated to the latest release for security and bug fixes and of course new features.

Note the following:

  • The kata-check behaviour can be overriden using either the -n or --no-network-checks CLI option, or by setting KATA_CHECK_NO_NETWORK=1 (that last one is potentially useful if Kata is build in a CI environment that calls kata-check, but which cannot access the network).
  • The PR will not perform the network check if run as root under any circumstances.
  • The PR has comprehensive tests so the risk of adding this functionality is deemed to be low.
  • The kata-check command is not called by a container manager: as the name suggests, it is a Kata-specific command designed to be run by a user or admin. As such, it is not a "core" command or API and does not affect the normal way Kata works.

Given all that, I'm going to merge this...

@jodh-intel jodh-intel merged commit 77ebbc5 into kata-containers:2.0-dev Sep 22, 2020
jodh-intel added a commit to jodh-intel/kata-containers that referenced this pull request Sep 23, 2020
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - kata-containers#735
[3] - kata-containers/tests#2870

Fixes: kata-containers#783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
egernst pushed a commit to egernst/kata-containers that referenced this pull request Oct 2, 2020
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - kata-containers#735
[3] - kata-containers/tests#2870

Fixes: kata-containers#783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
egernst pushed a commit that referenced this pull request Oct 7, 2020
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - #735
[3] - kata-containers/tests#2870

Fixes: #783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
c3d pushed a commit that referenced this pull request Apr 12, 2021
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - #735
[3] - kata-containers/tests#2870

Fixes: #783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
c3d pushed a commit to c3d/kata-containers that referenced this pull request Apr 12, 2021
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - kata-containers#735
[3] - kata-containers/tests#2870

Fixes: kata-containers#783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow kata-check to check for latest version
3 participants