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

Add --refresh-configuration-only to download-bundle #728

Merged

Conversation

marckhouzam
Copy link
Contributor

@marckhouzam marckhouzam commented Apr 9, 2024

What this PR does / why we need it

Add --refresh-configuration-only to tanzu plugin download-bundle

This new flag can be used to only download the OCI image without including any new plugin or plugin group. This effectively only updates the central configuration from the source repository.

This is needed to allow air-gap operators to keep the central configuration up-to-date even when no new plugin versions are needed.

Follow up to #707

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

Verify the use of the new flag by creating an air-gap repo and then updating it with new central config data:

$ make start-test-central-repo
[...]

# Setup an air-gap repo the first time
$ tz config set env.TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST localhost:9876/tanzu-cli/plugins/central:small
$ tz plugin download-bundle --image localhost:9876/tanzu-cli/plugins/central:small --group vmware-tanzucli/essentials --to-tar bundle.tar
[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/central:small"

[i] Getting selected plugin information...
[i] will be downloading the one plugin from group: vmware-tanzucli/essentials:v9.9.9
[i] will be downloading the one plugin from group: vmware-tanzucli/essentials:v9.9.9
[i] downloading image "localhost:9876/tanzu-cli/plugins/central:small"
[i] copy | exporting 2 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/central@sha256:6d9f3f990ffdf8b98d3da11d39a9a8ee2acef0e526dc1f83404dc7ebb1d84093
[i] copy | will export localhost:9876/tanzu-cli/plugins/central@sha256:ca212530af87bcf8c41b4b89c48cf453c86621e5e8f9fb501d219a582878f336
[i] copy | exported 2 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (13.834µs)
[i] copy | done: file 'sha256-8ef9de6d1089e40dbd9aef50e2a9278dff929720931d577b99ce5ed12fd84937.tar.gz' (9.875µs)
[i] copy | done: file 'sha256-fc43a06138a126d2716c40b595ab3da446eb220e4303130f6e2efc5aaa317e2f.tar.gz' (2.75275ms)
[i] ---------------------------
[...]
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (5.542µs)
[i] copy | done: file 'sha256-6e6cfa9fc0cec3d08a89324fabbb201b890e81dcb6d3bf51ab0a0c5389ee07bd.tar.gz' (22.375µs)
[i] saving plugin bundle at: bundle.tar

$ tz plugin upload-bundle --tar bundle.tar --to-repo localhost:9876/test/airgapped/v1/tanzu-cli/plugins
[i] extracting "bundle.tar" for processing...
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central"
[i] copy | importing 2 images...
[...]
[i] ---------------------------
[i] publishing plugin inventory metadata image...
[i] plugin inventory metadata image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central-metadata:small" is present. Merging the plugin inventory metadata
[i] uploading image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central-metadata:small"
[i] ---------------------------
[i] successfully published all plugin images to "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small"

# Now use that air-gap repo
$ tz config set env.TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST localhost:9876/tanzu-cli/plugins/central:small,localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small
$ tz plugin source update default -u localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small
[i] Refreshing plugin inventory cache for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small", this will take a few seconds.
[i] Reading plugin inventory for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small"

[ok] updated discovery source default

==
Note: A new version of the Tanzu CLI is available. You are at version: v1.3.0-dev.
To benefit from the latest security and features, please update to a recommended version:
  - v1.5.0-beta.0
  - v1.3.3

Please refer to these instructions for upgrading: https://github.com/vmware-tanzu/tanzu-cli/blob/main/docs/quickstart/install.md.

This message will print at most once per 24 hours until you update the CLI.
Set TANZU_CLI_RECOMMEND_VERSION_DELAY_DAYS to adjust this period (0 to disable).


# Check the content of the central config file which we will modify next
# Notice version alpha.2
$ grep 2.1.0 ~/.cache/tanzu/plugin_inventory/default/central_config.yaml
- version: v2.1.0-alpha.2

# Change the central config file in the "central" repo
# First pull the original image
$ imgpkg pull -o tmp --registry-verify-certs=false -i localhost:9876/tanzu-cli/plugins/central:small
Pulling image 'localhost:9876/tanzu-cli/plugins/central@sha256:ca212530af87bcf8c41b4b89c48cf453c86621e5e8f9fb501d219a582878f336'
Extracting layer 'sha256:fc43a06138a126d2716c40b595ab3da446eb220e4303130f6e2efc5aaa317e2f' (1/1)

Succeeded
$ cd tmp
$ ls
central_config.yaml plugin_inventory.db

# Next, modify the central_config.yaml file
$ grep 2.1.0 central_config.yaml
- version: v2.1.0-alpha.2

$ sed -i.bak 's/2.1.0-alpha.2/2.1.0-beta.1/' central_config.yaml
$ rm central_config.yaml.bak

$ grep 2.1.0 central_config.yaml
- version: v2.1.0-beta.1

# Now publish the new central config back
$ imgpkg push -f . --registry-verify-certs=false -i localhost:9876/tanzu-cli/plugins/central:small
dir: .
file: central_config.yaml
file: plugin_inventory.db
Pushed 'localhost:9876/tanzu-cli/plugins/central@sha256:32fff511c3989f9e6e6af2281118a6755659586c2c93d2683b159422552d9f41'
Succeeded
$ cd ..
$ rm bundle.tar

# Now finally use the new flag to get the latest central config
# Notice that only the OCI image is downloaded, no plugins
$ tz plugin download-bundle --image localhost:9876/tanzu-cli/plugins/central:small --to-tar bundle.tar --refresh-configuration-only
[i] The tanzu cli essential plugins are outdated and are being updated now. The update may take a few seconds.
[i] Installing plugins from plugin group 'vmware-tanzucli/essentials:v9.9.9'
[i] Installed plugin 'telemetry:v9.9.9' with target 'global' (from cache)

[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/central:small"

[i] Getting selected plugin information...
[i] will only be downloading the plugin inventory OCI image and the Central Configuration
[i] downloading image "localhost:9876/tanzu-cli/plugins/central:small"
[i] copy | exporting 1 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/central@sha256:32fff511c3989f9e6e6af2281118a6755659586c2c93d2683b159422552d9f41
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (6.959µs)
[i] copy | done: file 'sha256-424d6fbb5acb3a69ba63198b3bd0b1b22fc9540818381e467e00c0f44480ac5b.tar.gz' (1.776667ms)
[i] saving plugin bundle at: bundle.tar

# Upload the new OCI image to the existing air-gap repo
$ tz plugin upload-bundle --tar bundle.tar --to-repo localhost:9876/test/airgapped/v1/tanzu-cli/plugins
[i] extracting "bundle.tar" for processing...
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central"
[i] copy | importing 1 images...

63.95 KiB / 63.26 KiB [--------------------------------------------------------------------------------------------------------------] 101.08% 1.04 MiB p/s
[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] ---------------------------
[i] publishing plugin inventory metadata image...
[i] plugin inventory metadata image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central-metadata:small" is present. Merging the plugin inventory metadata
[i] uploading image "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central-metadata:small"
[i] ---------------------------
[i] successfully published all plugin images to "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small"


# Before refreshing the cache we still see the old central config values
$ grep 2.1.0 ~/.cache/tanzu/plugin_inventory/default/central_config.yaml
- version: v2.1.0-alpha.2
$ tz plugin search
  NAME       DESCRIPTION              TARGET  LATEST
  telemetry  telemetry functionality  global  v9.9.9

# Force a refresh of the air-gap repo
$ tz plugin source update default -u localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small
[i] Refreshing plugin inventory cache for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small", this will take a few seconds.
[i] Reading plugin inventory for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:9876/test/airgapped/v1/tanzu-cli/plugins/central:small"

[ok] updated discovery source default

# Verify that the plugin is still there
$ tz plugin search
  NAME       DESCRIPTION              TARGET  LATEST
  telemetry  telemetry functionality  global  v9.9.9

# Confirm the updated content of the central config
$ grep 2.1.0 ~/.cache/tanzu/plugin_inventory/default/central_config.yaml
- version: v2.1.0-beta.1

Release note

Provide a `--refresh-configuration-only` flag to `tanzu plugin download-bundle` to allow refreshing the plugin inventory and central configuration without adding any plugins to the air-gap repository.

Additional information

Special notes for your reviewer

This new flag can be used to only download the OCI image without
including any new plugin or plugin group.  This effectively only updates
the central configuration from the source repository.

Signed-off-by: Marc Khouzam <marc.khouzam@broadcom.com>
@marckhouzam marckhouzam added this to the v1.3.0 milestone Apr 10, 2024
@marckhouzam marckhouzam marked this pull request as ready for review April 10, 2024 21:16
@marckhouzam marckhouzam requested a review from a team as a code owner April 10, 2024 21:16
@marckhouzam marckhouzam changed the title [Do not review]: Add --refresh-configuration-only to download-bundle Add --refresh-configuration-only to download-bundle Apr 10, 2024
Copy link
Contributor

@anujc25 anujc25 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 👍

@marckhouzam marckhouzam merged commit 04d8c9f into vmware-tanzu:main Apr 17, 2024
7 checks passed
@marckhouzam marckhouzam deleted the feat/airgapOnlyCentralConfig branch April 17, 2024 16:57
@marckhouzam marckhouzam added the kind/feature Categorizes issue or PR as related to a new feature label Apr 17, 2024
vuil pushed a commit to vuil/tanzu-cli that referenced this pull request Apr 19, 2024
This new flag can be used to only download the OCI image without
including any new plugin or plugin group.  This effectively only updates
the central configuration from the source repository.

Signed-off-by: Marc Khouzam <marc.khouzam@broadcom.com>
vuil pushed a commit that referenced this pull request Apr 19, 2024
This new flag can be used to only download the OCI image without
including any new plugin or plugin group.  This effectively only updates
the central configuration from the source repository.

Signed-off-by: Marc Khouzam <marc.khouzam@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required kind/feature Categorizes issue or PR as related to a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants