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

Fix missing dag parameter in Slack notification #5341

Merged
merged 2 commits into from
Jan 23, 2025
Merged
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
27 changes: 17 additions & 10 deletions catalog/dags/maintenance/rotate_envfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from datetime import datetime

from airflow.decorators import dag, task
from airflow.models import Variable
from airflow.exceptions import AirflowSkipException
from airflow.models import DAG, Variable
from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
from airflow.providers.amazon.aws.hooks.ecs import EcsHook
from airflow.providers.amazon.aws.hooks.s3 import S3Hook
Expand Down Expand Up @@ -281,15 +282,21 @@ def delete_stale_envfiles(


@task
def notify_complete(deleted_envfiles: dict[str, list[str]]):
if deleted_envfiles:
message = ""
for env, envfiles in deleted_envfiles.items():
files = ", ".join(envfiles)
message += f"{env}: {files}\n"
notify_slack.function(
text=f"Deleted the following environment files:\n{message}"
)
def notify_complete(
deleted_envfiles: dict[str, list[str]],
dag: DAG | None = None,
):
if not deleted_envfiles:
raise AirflowSkipException("No environment files were deleted.")

message = ""
for env, envfiles in deleted_envfiles.items():
files = ", ".join(envfiles)
message += f"{env}: {files}\n"
notify_slack.function(
text=f"Deleted the following environment files:\n{message}",
dag=dag,
)


@dag(
Expand Down
Loading