Skip to content

Commit

Permalink
Improved version mismatch error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhittaker committed Mar 25, 2024
1 parent 38843c9 commit 69eaa67
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions internal/impl/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@ func Deploy(ctx context.Context, configFilename string) error {
// checkVersionCompatibility checks that the `weaver kube` binary is compatible
// with the application binary being deployed.
func checkVersionCompatibility(appBinary string) error {
versions, err := bin.ReadVersions(appBinary)
// Read the versions of the application binary.
appBinaryVersions, err := bin.ReadVersions(appBinary)
if err != nil {
return fmt.Errorf("read versions: %w", err)
}

// Read the versions of the 'weaver kube' binary (i.e. the currently
// running binary).
tool, err := os.Executable()
if err != nil {
return err
}
weaverKubeVersions, err := bin.ReadVersions(tool)
if err != nil {
return fmt.Errorf("read versions: %w", err)
}
Expand All @@ -142,22 +154,22 @@ func checkVersionCompatibility(appBinary string) error {
return rel
}

if versions.DeployerVersion != version.DeployerVersion {
if appBinaryVersions.DeployerVersion != version.DeployerVersion {
return fmt.Errorf(`
ERROR: The binary you're trying to deploy (%q) was built with
github.com/ServiceWeaver/weaver module version %s. However, the 'weaver-kube'
binary you're using was built with weaver module version %s. These versions are
incompatible.
ERROR: The binary you're trying to deploy (%q) was built with
github.com/ServiceWeaver/weaver module version %s (internal version %s).
However, the 'weaver-kube' binary you're using (%s) was built with weaver
module version %s (internal version %s). These versions are incompatible.
We recommend updating both the weaver module your application is built with and
updating the 'weaver-kube' command by running the following.
We recommend updating both the weaver module your application is built with and
updating the 'weaver-kube' command by running the following.
go get github.com/ServiceWeaver/weaver@latest
go install github.com/ServiceWeaver/weaver-kube/cmd/weaver-kube@latest
go get github.com/ServiceWeaver/weaver@latest
go install github.com/ServiceWeaver/weaver-kube/cmd/weaver-kube@latest
Then, re-build your code and re-run 'weaver-kube deploy'. If the problem
persists, please file an issue at https://github.com/ServiceWeaver/weaver/issues`,
relativize(appBinary), versions.ModuleVersion, selfVersion)
Then, re-build your code and re-run 'weaver-kube deploy'. If the problem
persists, please file an issue at https://github.com/ServiceWeaver/weaver/issues`,
relativize(appBinary), appBinaryVersions.ModuleVersion, appBinaryVersions.DeployerVersion, selfVersion, weaverKubeVersions.ModuleVersion, version.DeployerVersion)
}
return nil
}

0 comments on commit 69eaa67

Please sign in to comment.