Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#LFX 3147] Bug/Approval List #2828

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cla-backend-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ github.com/communitybridge/easycla v1.0.133 h1:aJulQGLLRISCMsZcCP4aIE8xGtHoBNm/E
github.com/communitybridge/easycla v1.0.135 h1:Dvn8jX+7BAnpmA+jvdK0n5ajWP8SoH5vvopt7whZDEU=
github.com/communitybridge/easycla v1.0.145 h1:ikhBSsOeEL2u3/EoyDsufh/j3HkjfFTiXAk1d61GoS8=
github.com/communitybridge/easycla v2.0.10+incompatible h1:6eRJ5fxrMxRZHBkg8piYo+zHTcSowMrP85nZXzp5mpA=
github.com/communitybridge/easycla v2.0.16+incompatible h1:I0hEApDh4IvlwRPyHV1LOsSYlSPbqBsGszjSTHwkdak=
github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ=
Expand Down
98 changes: 49 additions & 49 deletions cla-backend-go/signatures/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,6 @@ func (repo repository) UpdateApprovalList(ctx context.Context, claManager *model
if invalidateErr != nil {
msg := fmt.Sprintf("unable to invalidate signatures based on Approval List : %+v ", approvalList)
log.WithFields(f).Warn(msg)
return nil, errors.New(msg)
}
}
}
Expand Down Expand Up @@ -2373,7 +2372,34 @@ func (repo repository) invalidateSignatures(ctx context.Context, approvalList *A
iclas, err := repo.GetClaGroupICLASignatures(ctx, approvalList.ClaGroupID, nil)
if err != nil {
log.WithFields(f).Warn("unable to get iclas")
return err
}

if iclas != nil {
var iclaWg sync.WaitGroup
//Iterate iclas
iclaWg.Add(len(iclas.List))
log.WithFields(f).Debug("invalidating signature icla records... ")
for _, icla := range iclas.List {
go func(icla *models.IclaSignature) {
defer iclaWg.Done()
signature, sigErr := repo.GetSignature(ctx, icla.SignatureID)
if sigErr != nil {
log.WithFields(f).Warnf("unable to fetch signature for ID: %s ", icla.SignatureID)
return
}
// Grab user record
if signature.SignatureReferenceID == "" {
log.WithFields(f).Warnf("no signatureReferenceID for signature: %+v ", signature)
return
}
verifyErr := repo.verifyUserApprovals(ctx, signature.SignatureReferenceID, signature.SignatureID, claManager, approvalList)
if verifyErr != nil {
log.WithFields(f).Warnf("unable to verify user: %s ", signature.SignatureReferenceID)
return
}
}(icla)
}
iclaWg.Wait()
}

// Get ECLAs
Expand All @@ -2387,54 +2413,28 @@ func (repo repository) invalidateSignatures(ctx context.Context, approvalList *A
return err
}

var iclaWg, eclaWg sync.WaitGroup

//Iterate iclas
iclaWg.Add(len(iclas.List))
log.WithFields(f).Debug("invalidating signature icla records... ")

for _, icla := range iclas.List {
go func(icla *models.IclaSignature) {
defer iclaWg.Done()
signature, err := repo.GetSignature(ctx, icla.SignatureID)
if err != nil {
log.WithFields(f).Warnf("unable to fetch signature for ID: %s ", icla.SignatureID)
return
}
// Grab user record
if signature.SignatureReferenceID == "" {
log.WithFields(f).Warnf("no signatureReferenceID for signature: %+v ", signature)
return
}
verifyErr := repo.verifyUserApprovals(ctx, signature.SignatureReferenceID, signature.SignatureID, claManager, approvalList)
if verifyErr != nil {
log.WithFields(f).Warnf("unable to verify user: %s ", signature.SignatureReferenceID)
return
}
}(icla)
}
iclaWg.Wait()

log.WithFields(f).Debug("invalidating signature ecla records... ")
// Iterate eclas
eclaWg.Add(len(eclas.Signatures))
for _, ecla := range eclas.Signatures {
go func(ecla *models.Signature) {
defer eclaWg.Done()
// Grab user record
if ecla.SignatureReferenceID == "" {
log.WithFields(f).Warnf("no signatureReferenceID for signature: %+v ", ecla)
return
}
verifyErr := repo.verifyUserApprovals(ctx, ecla.SignatureReferenceID, ecla.SignatureID, claManager, approvalList)
if verifyErr != nil {
log.WithFields(f).Warnf("unable to verify user: %s ", ecla.SignatureReferenceID)
return
}
}(ecla)
if eclas != nil {
var eclaWg sync.WaitGroup
log.WithFields(f).Debug("invalidating signature ecla records... ")
// Iterate eclas
eclaWg.Add(len(eclas.Signatures))
for _, ecla := range eclas.Signatures {
go func(ecla *models.Signature) {
defer eclaWg.Done()
// Grab user record
if ecla.SignatureReferenceID == "" {
log.WithFields(f).Warnf("no signatureReferenceID for signature: %+v ", ecla)
return
}
verifyErr := repo.verifyUserApprovals(ctx, ecla.SignatureReferenceID, ecla.SignatureID, claManager, approvalList)
if verifyErr != nil {
log.WithFields(f).Warnf("unable to verify user: %s ", ecla.SignatureReferenceID)
return
}
}(ecla)
}
eclaWg.Wait()
}
eclaWg.Wait()

return nil
}

Expand Down