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

Run update check when any client command is executed #2909

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

simonwo
Copy link
Contributor

@simonwo simonwo commented Oct 13, 2023

This commit automatically kicks off a background update check whenever any client command is executed and prints the result at the end of the command. This means that update notifications will be reported as part of normal client usage rather than just when requested using the version command.

Resolves #2893.

@simonwo simonwo self-assigned this Oct 13, 2023
@simonwo simonwo requested a review from js-ts October 13, 2023 16:39
@js-ts
Copy link
Contributor

js-ts commented Oct 13, 2023

image
Is there a need to print the update Text for every command if the clientVersion != LatestVersion ?

@simonwo
Copy link
Contributor Author

simonwo commented Oct 14, 2023

image Is there a need to print the update Text for every command if the clientVersion != LatestVersion ?

Users don't run bacalhau version very much and so are unlikely to see an update. This means that they will see the update as part of their normal workflow.

In the next PR, we will introduce a mechanism to only do this once per day (or whatever period) to print the message less often.

Copy link
Contributor

@rossjones rossjones left a comment

Choose a reason for hiding this comment

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

Looks good, but when I tried this manually with devstack it tells me there's an update for every command. And if I were being picky, the text output at the end of the main command's output is too squashed up, could do with some vertical whitespace. Have approved but would be nice to fix the devstack issue

@@ -213,6 +217,9 @@ func (fsr *FsRepo) Init() error {
if err != nil {
return err
}

// TODO this should be a part of the config.
telemetry.SetupFromEnvs()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be in Open and Init?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think our conclusion was maybe? And we're not confident enough to consolidate this.

"github.com/pkg/errors"
)

const endpoint = "http://update.bacalhau.org/version"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a comment/todo to move this to configuration somewhere, otherwise we're at risk of doing a release just to satisfy a move to https or a diff domain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reasons for this are:

  • We do actually want everyone to always use this domain, and it shouldn't be configurable
  • It's actually easier to migrate a hard-coded constant than a configuration value right now because we don't have any config migraiton capability

If the concern is about testing, there's a few ways we can do that even with a hard-coded value (e.g. a mock http client).

This commit automatically kicks off a background update check
whenever any client command is executed and prints the result at the
end of the command. This means that update notifications will be
reported as part of normal client usage rather than just when
requested using the version command.
@simonwo
Copy link
Contributor Author

simonwo commented Oct 16, 2023

Discussed with Ross and comments are above. Broadly we're happy to merge this as long as we get the "once a day" PR out next. So I'll pick that up ASAP.

@simonwo simonwo enabled auto-merge (rebase) October 16, 2023 09:49
@simonwo simonwo merged commit f0cc144 into main Oct 16, 2023
14 checks passed
@simonwo simonwo deleted the 2893-update-checks branch October 16, 2023 09:54
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.

Automatically perform update checks on every command
3 participants