Skip to content

Commit

Permalink
make sure we use latest released amw-relayer (#2194)
Browse files Browse the repository at this point in the history
* make sure we use latest released amw-relayer

* go mod tidy

---------

Signed-off-by: arturrez <[email protected]>
  • Loading branch information
arturrez authored Oct 22, 2024
1 parent d2170e9 commit 1053bda
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
11 changes: 8 additions & 3 deletions cmd/nodecmd/wiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -500,15 +505,15 @@ 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)
nodeConfig, err := app.LoadClusterNodeConfig(cloudID)
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
Expand Down
1 change: 1 addition & 0 deletions pkg/docker/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type dockerComposeInputs struct {
WithMonitoring bool
WithAvalanchego bool
AvalanchegoVersion string
AWMRelayerVersion string
E2E bool
E2EIP string
E2ESuffix string
Expand Down
6 changes: 4 additions & 2 deletions pkg/docker/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
2 changes: 1 addition & 1 deletion pkg/docker/templates/awmrelayer.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions pkg/teleporter/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1053bda

Please sign in to comment.