From 16c3eb5ce34c537cd562a9f18e5230a04741fb68 Mon Sep 17 00:00:00 2001 From: Michael Whittaker Date: Mon, 25 Mar 2024 20:44:54 +0000 Subject: [PATCH] Improved version mismatch error message. --- internal/impl/deploy.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/impl/deploy.go b/internal/impl/deploy.go index 35a9cdc..4a9aa39 100644 --- a/internal/impl/deploy.go +++ b/internal/impl/deploy.go @@ -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) } @@ -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. @@ -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 }