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 16c3eb5
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 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,12 +154,12 @@ 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.
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.
Expand All @@ -157,7 +169,7 @@ func checkVersionCompatibility(appBinary string) error {
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)
relativize(appBinary), appBinaryVersions.ModuleVersion, appBinaryVersions.DeployerVersion, selfVersion, weaverKubeVersions.ModuleVersion, version.DeployerVersion)
}
return nil
}

0 comments on commit 16c3eb5

Please sign in to comment.