Skip to content

Commit

Permalink
Introduce submitter allowlist override
Browse files Browse the repository at this point in the history
Summary:
As a next step towards rolling out BPF CI email notifications, we want to send
emails to every patch submitter [0]. Introduce some logic that allows us to
easily ignore the allow list and send emails to all submitters, with a simple
toggling of a flag in the configuration.

[0] https://lore.kernel.org/bpf/eirb3ygold3flp7p6gtj76pii2q43mli6ocoe5btqwwwz36vsw@tnvv4w2ekgz3/

Reviewed By: chantra

Differential Revision: D51369841

fbshipit-source-id: 3471cfda2b195e6310ad273f1c073384798251db
  • Loading branch information
danielocfb-test authored and facebook-github-bot committed Nov 16, 2023
1 parent f2924f9 commit 7d263cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kernel_patches_daemon/branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async def send_email(config: EmailConfig, series: Series, subject: str, body: st
to_list = copy.copy(config.smtp_to)
cc_list = copy.copy(config.smtp_cc)

if series.submitter_email in config.submitter_allowlist:
if config.ignore_allowlist or series.submitter_email in config.submitter_allowlist:
to_list += [series.submitter_email]

for to in to_list + cc_list:
Expand Down
4 changes: 4 additions & 0 deletions kernel_patches_daemon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class EmailConfig:
# Once we send email notifications to all patch submitters it can be
# removed.
submitter_allowlist: Set[str]
# Ignore the `submitter_allowlist` entries and send emails to all patch
# submitters, unconditionally.
ignore_allowlist: bool

@classmethod
def from_json(cls, json: Dict) -> "EmailConfig":
Expand All @@ -127,6 +130,7 @@ def from_json(cls, json: Dict) -> "EmailConfig":
smtp_cc=json.get("cc", []),
smtp_http_proxy=json.get("http_proxy", None),
submitter_allowlist=json.get("submitter_allowlist", set()),
ignore_allowlist=json.get("ignore_allowlist", False),
)


Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/kpd_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"cc": ["email1-cc@example.com", "email2-cc@example.com"],
"pass": "super-secret-is-king",
"http_proxy": "http://example.com:8080",
"submitter_allowlist": ["email1-allow@example.com", "email2-allow@example.com"]
"submitter_allowlist": ["email1-allow@example.com", "email2-allow@example.com"],
"ignore_allowlist": true
},
"tag_to_branch_mapping": {
"tag": [
Expand Down
1 change: 1 addition & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_valid(self) -> None:
"email1-allow@example.com",
"email2-allow@example.com",
],
ignore_allowlist=True,
),
tag_to_branch_mapping={"tag": ["branch"]},
branches={
Expand Down

0 comments on commit 7d263cd

Please sign in to comment.