From 1053bda904581cf6889a881692cc5bcae6568d9d Mon Sep 17 00:00:00 2001 From: arturrez <56270896+arturrez@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:25:35 -0700 Subject: [PATCH] make sure we use latest released amw-relayer (#2194) * make sure we use latest released amw-relayer * go mod tidy --------- Signed-off-by: arturrez <56270896+arturrez@users.noreply.github.com> --- cmd/nodecmd/wiz.go | 11 ++++++++--- pkg/docker/compose.go | 1 + pkg/docker/ssh.go | 6 ++++-- pkg/docker/templates/awmrelayer.docker-compose.yml | 2 +- pkg/ssh/ssh.go | 4 ++-- pkg/teleporter/relayer.go | 8 ++++++-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cmd/nodecmd/wiz.go b/cmd/nodecmd/wiz.go index 61cf9e63c..9532b3bca 100644 --- a/cmd/nodecmd/wiz.go +++ b/cmd/nodecmd/wiz.go @@ -328,7 +328,12 @@ func wiz(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err := setAWMRelayerHost(awmRelayerHost); err != nil { + // get awm-relayer latest version + relayerVersion, err := teleporter.GetLatestRelayerReleaseVersion() + if err != nil { + return err + } + if err := setAWMRelayerHost(awmRelayerHost, relayerVersion); err != nil { return err } if err := setAWMRelayerSecurityGroupRule(clusterName, awmRelayerHost); err != nil { @@ -500,7 +505,7 @@ func updateProposerVMs( return teleporter.SetProposerVM(app, network, "C", "") } -func setAWMRelayerHost(host *models.Host) error { +func setAWMRelayerHost(host *models.Host, relayerVersion string) error { cloudID := host.GetCloudID() ux.Logger.PrintToUser("") ux.Logger.PrintToUser("configuring AWM Relayer on host %s", cloudID) @@ -508,7 +513,7 @@ func setAWMRelayerHost(host *models.Host) error { if err != nil { return err } - if err := ssh.ComposeSSHSetupAWMRelayer(host); err != nil { + if err := ssh.ComposeSSHSetupAWMRelayer(host, relayerVersion); err != nil { return err } nodeConfig.IsAWMRelayer = true diff --git a/pkg/docker/compose.go b/pkg/docker/compose.go index 9136e9e53..858db56fc 100644 --- a/pkg/docker/compose.go +++ b/pkg/docker/compose.go @@ -23,6 +23,7 @@ type dockerComposeInputs struct { WithMonitoring bool WithAvalanchego bool AvalanchegoVersion string + AWMRelayerVersion string E2E bool E2EIP string E2ESuffix string diff --git a/pkg/docker/ssh.go b/pkg/docker/ssh.go index ef012b226..73a96e06f 100644 --- a/pkg/docker/ssh.go +++ b/pkg/docker/ssh.go @@ -136,10 +136,12 @@ func ComposeSSHSetupMonitoring(host *models.Host) error { dockerComposeInputs{}) } -func ComposeSSHSetupAWMRelayer(host *models.Host) error { +func ComposeSSHSetupAWMRelayer(host *models.Host, relayerVersion string) error { return ComposeOverSSH("Setup AWM Relayer", host, constants.SSHScriptTimeout, "templates/awmrelayer.docker-compose.yml", - dockerComposeInputs{}) + dockerComposeInputs{ + AWMRelayerVersion: relayerVersion, + }) } diff --git a/pkg/docker/templates/awmrelayer.docker-compose.yml b/pkg/docker/templates/awmrelayer.docker-compose.yml index 3861c4ac7..f992b1139 100644 --- a/pkg/docker/templates/awmrelayer.docker-compose.yml +++ b/pkg/docker/templates/awmrelayer.docker-compose.yml @@ -1,7 +1,7 @@ name: avalanche-cli services: awm-relayer: - image: avaplatform/awm-relayer + image: avaplatform/awm-relayer:{{ .AWMRelayerVersion }} container_name: awm-relayer restart: unless-stopped user: "1000:1000" # ubuntu user diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 7c2f1d486..13b867db3 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -159,8 +159,8 @@ func RunSSHRestartNode(host *models.Host) error { } // ComposeSSHSetupAWMRelayer used docker compose to setup AWM Relayer -func ComposeSSHSetupAWMRelayer(host *models.Host) error { - if err := docker.ComposeSSHSetupAWMRelayer(host); err != nil { +func ComposeSSHSetupAWMRelayer(host *models.Host, relayerVersion string) error { + if err := docker.ComposeSSHSetupAWMRelayer(host, relayerVersion); err != nil { return err } return docker.StartDockerComposeService(host, utils.GetRemoteComposeFile(), "awm-relayer", constants.SSHLongRunningScriptTimeout) diff --git a/pkg/teleporter/relayer.go b/pkg/teleporter/relayer.go index 6ff0edb77..bb381ca7e 100644 --- a/pkg/teleporter/relayer.go +++ b/pkg/teleporter/relayer.go @@ -210,11 +210,15 @@ func saveRelayerRunFile(runFilePath string, pid int) error { return nil } +func GetLatestRelayerReleaseVersion() (string, error) { + downloader := application.NewDownloader() + return downloader.GetLatestReleaseVersion(binutils.GetGithubLatestReleaseURL(constants.AvaLabsOrg, constants.AWMRelayerRepoName)) +} + func InstallRelayer(binDir, version string) (string, error) { if version == "" || version == "latest" { - downloader := application.NewDownloader() var err error - version, err = downloader.GetLatestReleaseVersion(binutils.GetGithubLatestReleaseURL(constants.AvaLabsOrg, constants.AWMRelayerRepoName)) + version, err = GetLatestRelayerReleaseVersion() if err != nil { return "", err }