-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Time To Live (TTL) to the inventory cache (#605)
Normally, the digest of the plugin inventory is checked every time the DB needs to be read. Although this is faster than downloading the DB each time, there is still between a 2.5s to 4.5s delay in checking the digest. This makes every `plugin search` and `plugin group search` command slower. It also makes some `plugin install --group` commands much slower when all plugins are available in the cache, since the installation of each plugin in the group causes a digest check, even if the plugin binary is already in the cache. This commit provides a type of Time To Live for the DB. This means that when within the TTL, the digest is not checked and the DB is considered valid. The time the digest was last checked is stored as the modification time (mtime) of the digest file. So, whenever the DB needs to be read, if the TTL has not expired since the last time the digest was verified, the DB is directly read from cache; if the TTL has expired, the digest is checked and the DB downloaded if required. On a "plugin source update" or "plugin source init" the TTL is ignored and the digest automatically checked. This is important as either of these commands usually modify the URI of the plugin discovery and therefore invalidates the DB. Note that for any discovery source added through the TANZU_CLI_ADDITIONAL_PLUGIN_DISCOVERY_IMAGES_TEST_ONLY variable, the digest is checked every time (this TTL feature does not apply); this is because there is no way to know if current cache was downloaded from the same URIs as what is currently in the variable. This is different than for "plugin source update/init" because these two commands can actively force a cache refresh but changing the TANZU_CLI_ADDITIONAL_PLUGIN_DISCOVERY_IMAGES_TEST_ONLY variable cannot do that. The value of the cache TTL is of 30 minutes. This means that it can take a CLI up to 30 minutes to notice the publication of new plugins in the central repository. If for some reason a user wants to force a refresh immediately, they can simply do `tanzu plugin source init` (or `tanzu plugin source update default -u ...` if the discovery source is not the default central repository). The TTL value can be overriden using the environment variable TANZU_CLI_PLUGIN_DB_DIGEST_TTL_SECONDS. * Store URI in the main plugin inventory digest file To allow the CLI to know if a plugin inventory cache has become invalid because it represents a different URI, we now store the OCI image URI inside the main digest file. Whenever the TTL is checked to know if the digest must be checked, the URI is also checked; if the URI has changed, the digest must be checked. Signed-off-by: Marc Khouzam <[email protected]>
- Loading branch information
1 parent
ce43487
commit 6b1c899
Showing
11 changed files
with
753 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.