From 0d15ec6bcb974ba546bc2340dcc7d2f519db37ac Mon Sep 17 00:00:00 2001 From: zhangl Date: Fri, 21 Jul 2023 15:11:32 +0000 Subject: [PATCH] Issue open-horizon#3845 - Update the download woker to allow download cluster agent image with architecture s390x Signed-off-by: zhangl --- download/download_worker.go | 15 ++++++++------- download/download_worker_test.go | 3 ++- persistence/persistence.go | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/download/download_worker.go b/download/download_worker.go index 49925d480..d1bb65bf8 100644 --- a/download/download_worker.go +++ b/download/download_worker.go @@ -32,7 +32,7 @@ const ( MACPACKAGETYPE = "pkg" HZN_CLUSTER_FILE = "horizon-agent-edge-cluster-files.tar.gz" - HZN_CLUSTER_IMAGE = "amd64_anax_k8s.tar.gz" + HZN_CLUSTER_IMAGE = "%v_anax_k8s.tar.gz" HZN_CONTAINER_FILE = "%v_anax.tar.gz" HZN_EDGE_FILE = "horizon-agent-%v-%v-%v.tar.gz" HZN_CONFIG_FILE = "agent-install.cfg" @@ -486,8 +486,14 @@ func (w *DownloadWorker) formAgentUpgradePackageNames(dev *persistence.ExchangeD return nil, "", fmt.Errorf("No node policy found in the local db.") } + archProp, err := pol.Properties.GetProperty(externalpolicy.PROP_NODE_ARCH) + if err != nil { + return nil, "", err + } + if dev.GetNodeType() == persistence.DEVICE_TYPE_CLUSTER { - return &[]string{HZN_CLUSTER_FILE, HZN_CLUSTER_IMAGE}, "", nil + cluster_image := fmt.Sprintf(HZN_CLUSTER_IMAGE, archProp.Value) + return &[]string{HZN_CLUSTER_FILE, cluster_image}, "", nil } installTypeProp, err := pol.Properties.GetProperty(externalpolicy.PROP_NODE_OS) @@ -495,11 +501,6 @@ func (w *DownloadWorker) formAgentUpgradePackageNames(dev *persistence.ExchangeD return nil, "", fmt.Errorf("Failed to find node os property: %v", err) } - archProp, err := pol.Properties.GetProperty(externalpolicy.PROP_NODE_ARCH) - if err != nil { - return nil, "", err - } - allFiles := []string{} containerizedProp, err := pol.Properties.GetProperty(externalpolicy.PROP_NODE_CONTAINERIZED) diff --git a/download/download_worker_test.go b/download/download_worker_test.go index 64ae6e831..28eb6d8d1 100644 --- a/download/download_worker_test.go +++ b/download/download_worker_test.go @@ -4,6 +4,7 @@ package download import ( + "fmt" "github.com/boltdb/bolt" "github.com/open-horizon/anax/config" "github.com/open-horizon/anax/cutil" @@ -208,7 +209,7 @@ func Test_formAgentUpgradePackageNames(t *testing.T) { t.Errorf("Expected 2 files for download. Got %v.", downloadFiles) } else if !cutil.SliceContains(*downloadFiles, HZN_CLUSTER_FILE) { t.Errorf("Did not find expected file %s for download. Got %v.", HZN_CLUSTER_FILE, downloadFiles) - } else if !cutil.SliceContains(*downloadFiles, HZN_CLUSTER_IMAGE) { + } else if !cutil.SliceContains(*downloadFiles, fmt.Sprintf(HZN_CLUSTER_IMAGE, "amd64")) { t.Errorf("Did not find expected file %s for download. Got %v.", HZN_CLUSTER_IMAGE, downloadFiles) } diff --git a/persistence/persistence.go b/persistence/persistence.go index c3b0a4470..6be7690b5 100644 --- a/persistence/persistence.go +++ b/persistence/persistence.go @@ -123,7 +123,7 @@ func (c EstablishedAgreement) String() string { "RunningWorkload: %v, "+ "AgreementTimeout: %v, "+ "ServiceDefId: %v, "+ - "FailedVerAttempts: %v", + "FailedVerAttempts: %v"+ "LastVerAttemptUpdateTime: %v", c.Name, c.DependentServices, c.Archived, c.CurrentAgreementId, c.ConsumerId, c.CounterPartyAddress, ServiceConfigNames(&c.CurrentDeployment), "********", c.ProposalSig,