Skip to content

Commit ac65f84

Browse files
authored
Merge pull request open-horizon#4164 from LiilyZhang/zhangl/Issue4156-part2
Issue open-horizon#4156 (part2) - Bug: On restart, agbot doesn't upda…
2 parents a2f6c4b + b9f5d41 commit ac65f84

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

agreementbot/consumer_protocol_handler.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func (b *BaseConsumerProtocolHandler) HandlePolicyChanged(cmd *PolicyChangedComm
329329
clusterNSNotChange := true
330330

331331
if ag.Pattern == "" {
332-
policyMatches, noNewPriority, clusterNSNotChange = b.HandlePolicyChangeForAgreement(ag, cmd.Msg.OldPolicy(), cph)
332+
policyMatches, noNewPriority, clusterNSNotChange = b.HandlePolicyChangeForAgreement(ag, pol, cph)
333333
agStillValid = policyMatches && noNewPriority
334334
if ag.GetDeviceType() == persistence.DEVICE_TYPE_CLUSTER {
335335
agStillValid = agStillValid && clusterNSNotChange
@@ -494,14 +494,23 @@ func (b *BaseConsumerProtocolHandler) HandlePolicyChangeForAgreement(ag persiste
494494

495495
// check if cluster namespace is changed in new policy
496496
if dev.NodeType == persistence.DEVICE_TYPE_CLUSTER && busPol.ClusterNamespace != oldPolicy.ClusterNamespace {
497-
glog.V(5).Infof(BCPHlogstring(b.Name(), fmt.Sprintf("cluster namespace is changed from %v to %v in busiess policy for agreement %v, checking cluster namespace compatibility ...", oldPolicy.ClusterNamespace, busPol.ClusterNamespace, ag.CurrentAgreementId)))
497+
if glog.V(5) {
498+
glog.Infof(BCPHlogstring(b.Name(), fmt.Sprintf("cluster namespace is changed from %v to %v in busiess policy for agreement %v, checking cluster namespace compatibility ...", oldPolicy.ClusterNamespace, busPol.ClusterNamespace, ag.CurrentAgreementId)))
499+
}
498500
t_comp, consumerNamespace, t_reason := compcheck.CheckClusterNamespaceCompatibility(dev.NodeType, dev.ClusterNamespace, dev.IsNamespaceScoped, busPol.ClusterNamespace, wl.ClusterDeployment, ag.Pattern, false, msgPrinter)
499501
if !t_comp {
500-
glog.V(5).Infof(BCPHlogstring(b.Name(), fmt.Sprintf("cluster namespace %v is not longer compatible for agreement %v. Reason is: %v", consumerNamespace, ag.CurrentAgreementId, t_reason)))
501-
502+
if glog.V(5) {
503+
glog.Infof(BCPHlogstring(b.Name(), fmt.Sprintf("cluster namespace %v is not longer compatible for agreement %v. Reason is: %v", consumerNamespace, ag.CurrentAgreementId, t_reason)))
504+
}
505+
return true, true, false
506+
} else if consumerNamespace != oldPolicy.ClusterNamespace {
507+
// this check only applies to cluster-scoped agent
508+
if glog.V(5) {
509+
glog.Infof(BCPHlogstring(b.Name(), fmt.Sprintf("cluster namespace has changed from %v to %v for agreement %v", oldPolicy.ClusterNamespace, consumerNamespace, ag.CurrentAgreementId)))
510+
}
511+
return true, true, false
502512
}
503513
// new cluster namespace is still compatible
504-
return true, true, false
505514
}
506515
}
507516

0 commit comments

Comments
 (0)