From a71ad2722abe3eeb97d1ab5526bd268917a8f275 Mon Sep 17 00:00:00 2001 From: Doug Larson Date: Thu, 19 Dec 2024 12:08:20 -0800 Subject: [PATCH] Keep agent in sync after startup Signed-off-by: Doug Larson --- agreement/agreement.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agreement/agreement.go b/agreement/agreement.go index 303c20e58..d44249e77 100644 --- a/agreement/agreement.go +++ b/agreement/agreement.go @@ -710,7 +710,14 @@ func (w *AgreementWorker) syncOnInit() error { glog.Errorf(logString(fmt.Sprintf("cannot record agreement %v state %v, error: %v", ag.CurrentAgreementId, state, err))) } } - } + } else { + //Setting this as potentially failed enables governAgreements func in governance/governance.go to use the same mechanism as used in heartbeat restored + //to verify the agreement is still valid or else cancels it to keep agent and hub in sync + _, err := persistence.SetFailedVerAttempts(w.db, ag.CurrentAgreementId, ag.AgreementProtocol, ag.FailedVerAttempts+1) + if err != nil { + glog.Errorf(logString(fmt.Sprintf("encountered error updating agreement %v, error %v", ag.CurrentAgreementId, err))) + } + } glog.V(3).Infof(logString(fmt.Sprintf("added agreement %v to policy agreement counter.", ag.CurrentAgreementId))) } }