Skip to content

Commit 31aa026

Browse files
Add more visibility and fix one dminor debugging message in another function
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 5a9689c commit 31aa026

File tree

4 files changed

+63
-25
lines changed

4 files changed

+63
-25
lines changed

WHITELISTING_BOTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ Or using AWS CLI:
109109
aws --profile "lfproduct-prod" dynamodb scan --table-name "cla-prod-github-orgs" --filter-expression "contains(organization_name,:v)" --expression-attribute-values "{\":v\":{\"S\":\"linuxfoundation\"}}" --max-items 100 | jq -r '.Items'
110110
```
111111

112+
To check for log entries related to skipping CLA check, you can use the following command: `` STAGE=dev DTFROM='1 hour ago' DTTO='1 second ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' 'skip_cla' ``.

cla-backend-go/github/bots.go

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,53 @@ func SkipWhitelistedBots(ev events.Service, orgModel *models.GithubOrganization,
168168
log.WithFields(f).Debug("No skip_cla config found for repo, skipping whitelisted bots check")
169169
return actorsMissingCLA, []*UserCommitSummary{}
170170
}
171+
172+
// Log full configuration
173+
actorDebugData := make([]string, 0, len(actorsMissingCLA))
171174
const nullStr = "(null)"
175+
for _, a := range actorsMissingCLA {
176+
if a == nil {
177+
continue
178+
}
179+
id, login, username, email := nullStr, nullStr, nullStr, nullStr
180+
if a.CommitAuthor != nil && a.CommitAuthor.ID != nil {
181+
id = fmt.Sprintf("%v", *a.CommitAuthor.ID)
182+
}
183+
if a.CommitAuthor != nil && a.CommitAuthor.Login != nil {
184+
login = *a.CommitAuthor.Login
185+
}
186+
if a.CommitAuthor != nil && a.CommitAuthor.Name != nil {
187+
username = *a.CommitAuthor.Name
188+
}
189+
if a.CommitAuthor != nil && a.CommitAuthor.Email != nil {
190+
email = *a.CommitAuthor.Email
191+
}
192+
actorDebugData = append(actorDebugData,
193+
fmt.Sprintf("id='%v',login='%v',username='%v',email='%v'", id, login, username, email))
194+
}
195+
log.WithFields(f).Debugf("final skip_cla config for repo %s is %s; actorsMissingCLA: [%s]",
196+
orgRepo, config, strings.Join(actorDebugData, "; "))
172197

173198
for _, actor := range actorsMissingCLA {
199+
if actor == nil {
200+
continue
201+
}
202+
id, login, username, email := nullStr, nullStr, nullStr, nullStr
203+
if actor.CommitAuthor != nil && actor.CommitAuthor.ID != nil {
204+
id = fmt.Sprintf("%v", *actor.CommitAuthor.ID)
205+
}
206+
if actor.CommitAuthor != nil && actor.CommitAuthor.Login != nil {
207+
login = *actor.CommitAuthor.Login
208+
}
209+
if actor.CommitAuthor != nil && actor.CommitAuthor.Name != nil {
210+
username = *actor.CommitAuthor.Name
211+
}
212+
if actor.CommitAuthor != nil && actor.CommitAuthor.Email != nil {
213+
email = *actor.CommitAuthor.Email
214+
}
215+
actorData := fmt.Sprintf("id='%v',login='%v',username='%v',email='%v'", id, login, username, email)
216+
log.WithFields(f).Debugf("Checking actor: %s for skip_cla config: %s", actorData, config)
174217
if isActorSkipped(actor, config) {
175-
if actor == nil {
176-
continue
177-
}
178-
id, login, username, email := nullStr, nullStr, nullStr, nullStr
179-
if actor.CommitAuthor != nil && actor.CommitAuthor.ID != nil {
180-
id = fmt.Sprintf("%v", *actor.CommitAuthor.ID)
181-
}
182-
if actor.CommitAuthor != nil && actor.CommitAuthor.Login != nil {
183-
login = *actor.CommitAuthor.Login
184-
}
185-
if actor.CommitAuthor != nil && actor.CommitAuthor.Name != nil {
186-
username = *actor.CommitAuthor.Name
187-
}
188-
if actor.CommitAuthor != nil && actor.CommitAuthor.Email != nil {
189-
email = *actor.CommitAuthor.Email
190-
}
191-
actorData := fmt.Sprintf("id='%v',login='%v',username='%v',email='%v'", id, login, username, email)
192218
msg := fmt.Sprintf(
193219
"Skipping CLA check for repo='%s', actor: %s due to skip_cla config: '%s'",
194220
orgRepo, actorData, config,

cla-backend/cla/models/github_models.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def update_merge_group_status(
597597
f"signing url: {sign_url}"
598598
)
599599
cla.log.warning(
600-
"{fn} - This is an error condition - "
600+
f"{fn} - This is an error condition - "
601601
f"should have at least one committer in one of these lists: "
602602
f"{len(signed)} passed, {missing}"
603603
)
@@ -1037,19 +1037,28 @@ def skip_whitelisted_bots(self, org_model, org_repo, actors_missing_cla) -> Tupl
10371037
cla.log.debug("No skip_cla config found for repo %s, skipping whitelisted bots check", org_repo)
10381038
return actors_missing_cla, []
10391039

1040+
actor_debug_data = [
1041+
f"id='{getattr(a, 'author_id', '(null)')}',"
1042+
f"login='{getattr(a, 'author_login', '(null)')}',"
1043+
f"username='{getattr(a, 'author_username', '(null)')}',"
1044+
f"email='{getattr(a, 'author_email', '(null)')}'"
1045+
for a in actors_missing_cla
1046+
]
1047+
cla.log.debug("final skip_cla config for repo %s is %s; actors_missing_cla: [%s]", org_repo, config, ", ".join(actor_debug_data))
10401048
out_actors_missing_cla = []
10411049
whitelisted_actors = []
10421050
for actor in actors_missing_cla:
10431051
if actor is None:
10441052
continue
10451053
try:
1054+
actor_data = "id='{}',login='{}',username='{}',email='{}'".format(
1055+
getattr(actor, "author_id", "(null)"),
1056+
getattr(actor, "author_login", "(null)"),
1057+
getattr(actor, "author_username", "(null)"),
1058+
getattr(actor, "author_email", "(null)"),
1059+
)
1060+
cla.log.debug("Checking actor: %s for skip_cla config: %s", actor_data, config)
10461061
if self.is_actor_skipped(actor, config):
1047-
actor_data = "id='{}',login='{}',username='{}',email='{}'".format(
1048-
getattr(actor, "author_id", "(null)"),
1049-
getattr(actor, "author_login", "(null)"),
1050-
getattr(actor, "author_username", "(null)"),
1051-
getattr(actor, "author_email", "(null)"),
1052-
)
10531062
msg = "Skipping CLA check for repo='{}', actor: {} due to skip_cla config: '{}'".format(
10541063
org_repo,
10551064
actor_data,
@@ -1912,7 +1921,7 @@ def update_pull_request(
19121921
f"signing url: {sign_url}"
19131922
)
19141923
cla.log.warning(
1915-
"{fn} - This is an error condition - "
1924+
f"{fn} - This is an error condition - "
19161925
f"should have at least one committer in one of these lists: "
19171926
f"{len(signed)} passed, {missing}"
19181927
)

utils/skip_cla_entry.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
# delete-item Deletes the entire `skip_cla` entry.
77
#
88
# MODE=add-key ./utils/skip_cla_entry.sh sun-test-org 'repo1' 're:vee?rendra' '*'
9+
# MODE=add-key ./utils/skip_cla_entry.sh 'sun-test-org' 'repo1' 'lukaszgryglicki' 're:gryglicki'
910
# ./utils/scan.sh github-orgs organization_name sun-test-org
11+
# STAGE=dev DTFROM='1 hour ago' DTTO='1 second ago' ./utils/search_aws_log_group.sh 'cla-backend-dev-githubactivity' 'skip_cla'
1012

1113
if [ -z "$MODE" ]
1214
then

0 commit comments

Comments
 (0)