Repository navigation
fix(cli): skip reinstall in rill upgrade when already on latest version - #9985
Conversation
Fixes rilldata#9984. rill upgrade now exits early when the current version is already the latest release. Adds --force to reinstall anyway.
| return false, "", nil | ||
| } | ||
|
|
||
| latest, err := ch.LatestVersion(cmd.Context()) |
There was a problem hiding this comment.
ch.LatestVersion can fetch cached version which means rill upgrade can fail if a new version is released but user's cached version is used.
If we want to fix this then we can take the route of always refetching version in rill upgrade but that adds extra latency.
It can be mitigated to some extent by ensuring latest version is refetched only when current version and cached version are same but that adds more complexity.
There was a problem hiding this comment.
Good catch, thanks! I went with your second suggestion. The cached version is now only trusted when it says an upgrade is needed. If the cache says we're already on the latest, rill upgrade fetches the latest release from GitHub again before skipping. So a stale cache can't block an upgrade, and there's no extra latency when an upgrade is actually available. I added a small RefreshLatestVersion helper in cmdutil for this.
There was a problem hiding this comment.
Hey
Your last change pushed a compile error.
On deeper reflection I realised it is simpler and better to move the check to install script.
Instead of sending it for another round I made changes as part of this PR itself.
|
Verified offline. Test failures can be ignored. |
Fixes #9984.
rill upgrade(with no flags) always ran the install script, so it re-downloaded the same release even when the CLI was already on the latest version.Changes
Helper.LatestVersion, cached for 24h). If the current version is >= latest, printRill is already up to date (vX.Y.Z). Use --force to reinstall.and exit.--forceflag to reinstall anyway.--versionand--nightlybehaviour is unchanged. Dev builds (empty version) and version-lookup errors fall back to the previous behaviour (install).versionUpToDateand add table-driven unit tests incli/cmd/upgrade/upgrade_test.go(equal, older, newer, prerelease, and invalid version cases).Checklist: