Skip to content

Commit

Permalink
Issue open-horizon#4156 - Bug: On restart, agbot doesn't update a nod…
Browse files Browse the repository at this point in the history
…e even though a new service was added and a deployment policy update occurred

Signed-off-by: Le Zhang <[email protected]>
  • Loading branch information
LiilyZhang committed Oct 3, 2024
1 parent 79e6077 commit 00d7bd5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions agreementbot/agreementbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,8 @@ func (w *AgreementBotWorker) syncOnInit() error {
}
neededBCInstances[bcOrg][bcType][bcName] = true

//var pol *policy.Policy

// If the agreement has received a reply then we just need to make sure that the policy manager's agreement counts
// are correct. Even for already timedout agreements, the governance process will cleanup old and outdated agreements,
// so we don't need to do anything here.
Expand Down Expand Up @@ -1119,6 +1121,35 @@ func (w *AgreementBotWorker) syncOnInit() error {
glog.V(3).Infof(AWlogString(fmt.Sprintf("added agreement %v to policy agreement counter.", ag.CurrentAgreementId)))
}

// // re-evaluate the agreement
// if pol != nil {
// glog.V(3).Infof(AWlogString(fmt.Sprintf("checking policy against exchange for agreement %v.", ag.CurrentAgreementId)))
// // policyName example: Helloworld_ibm.helloworld_ieam-roks-scale_amd64
// // policyName := pol.Header.Name
// if exchPols, err := exchange.GetBusinessPolicies(w, ag.Org, pol.Header.Name); err != nil {
// glog.Errorf(AWlogString(fmt.Sprintf("error getting business policies from exchange for org: %v, policy name: %v error: %v", ag.Org, pol.Header.Name, err)))
// } else if len(exchPols) == 0 {
// glog.V(5).Infof(AWlogString(fmt.Sprintf("business policy %v from agreement %v is not found from exchange.", pol.Header.Name, ag.CurrentAgreementId)))
// // Need to cancel the agreement
// } else {
// //exchangeBPolicy := bPolicies
// for polId, exchPol := range exchPols {
// bPol := exchPol.GetBusinessPolicy()
// if pPolicy, err := bPol.GenPolicyFromBusinessPolicy(polId); err != nil {
// glog.Errorf(AWlogString(fmt.Sprintf("error generating internal business policies for org: %v, policy name: %v from %v, error: %v", ag.Org, pol.Header.Name, exchPol.String(), err)))
// } else if pPolicy == nil {
// glog.Errorf(AWlogString(fmt.Sprintf("the generated internal business policies is nil for org: %v, policy name: %v from %v", ag.Org, pol.Header.Name, exchPol.String())))
// } else {
// if !pol.IsSameWorkload(pPolicy) {

// }
// }

// }
// }

//}

// This state should never occur, but could if there was an error along the way. It means that a DB record
// was created for this agreement but the record was never updated with the creation time, which is supposed to occur
// immediately following creation of the record. Further, if this were to occur, then the exchange should not have been
Expand All @@ -1131,6 +1162,11 @@ func (w *AgreementBotWorker) syncOnInit() error {

}

// Business policy might get changed during the restarting. Check business policy changes.
if err = w.generatePolicyFromBusinessPols(nil); err != nil {
glog.Errorf(AWlogString(fmt.Sprintf("error checking business policy during syncOnInit, error: %v", err)))
}

// Fire off start requests for each BC client that we need running. The blockchain worker and the container worker will tolerate
// a start request for containers that are already running.
glog.V(3).Infof(AWlogString(fmt.Sprintf("discovered BC instances in DB %v", neededBCInstances)))
Expand Down

0 comments on commit 00d7bd5

Please sign in to comment.