Skip to content

Commit

Permalink
Issue open-horizon#4162 (part2) - Bug: Agbot failed to find service w…
Browse files Browse the repository at this point in the history
…ith x86_64 arch for amd64 device

Signed-off-by: Le Zhang <[email protected]>
  • Loading branch information
LiilyZhang committed Oct 28, 2024
1 parent ba813da commit 32f3819
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions agreementbot/agreementworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,22 +496,36 @@ func (b *BaseAgreementWorker) InitiateNewAgreement(cph ConsumerProtocolHandler,
}

if wi.ConsumerPolicy.PatternId != "" {
glog.Infof(BAWlogstring(workerId, fmt.Sprintf("lily - arch synonyms config: %v.", b.config.ArchSynonyms)))
// Check the arch of the top level service against the node. If it does not match, then do not make an agreement.
// In the pattern case, the top level service spec, arch and version are also put in the node's registeredServices
for _, ms_svc := range exchangeDev.RegisteredServices {
if ms_svc.Url == cutil.FormOrgSpecUrl(workload.WorkloadURL, workload.Org) {
for _, prop := range ms_svc.Properties {
if prop.Name == "arch" {
// convert the arch to GOARCH standard using synonyms defined in the config
/*
"ArchSynonyms": {
"x86_64": "amd64",
"armhf": "arm",
"aarch64": "arm64"
}
*/

//amd64
arch1 := prop.Value
if arch1 != "" && b.config.ArchSynonyms.GetCanonicalArch(arch1) != "" {
arch1 = b.config.ArchSynonyms.GetCanonicalArch(arch1)
}

// x86_64
arch2 := workload.Arch
if arch2 != "" && b.config.ArchSynonyms.GetCanonicalArch(arch2) != "" {
arch2 = b.config.ArchSynonyms.GetCanonicalArch(arch2)
}

glog.Infof(BAWlogstring(workerId, fmt.Sprintf("lily - node arch property: %v, workload arch: %v, arch1 %v, arch2 %v", prop.Value, workload.Arch, arch1, arch2)))

if arch1 != arch2 {
glog.Infof(BAWlogstring(workerId, fmt.Sprintf("workload arch %v does not match the device arch %v. Can not make agreement.", workload.Arch, prop.Value)))
return
Expand Down

0 comments on commit 32f3819

Please sign in to comment.