mirror of https://github.com/apache/superset.git
fix: Stabilize and deprecate legacy alerts module (#12627)
* Add deprecation notice to superset.tasks.schedules * Reduce retries and schedule window for alerts
This commit is contained in:
parent
df8bb3bb18
commit
e4ae17def5
|
@ -14,8 +14,11 @@
|
||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
"""
|
||||||
"""Utility functions used across Superset"""
|
DEPRECATION NOTICE: this module is deprecated as of v1.0.0.
|
||||||
|
It will be removed in future versions of Superset. Please
|
||||||
|
migrate to the new scheduler: `superset.tasks.scheduler`.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
@ -535,11 +538,10 @@ def schedule_email_report(
|
||||||
@celery_app.task(
|
@celery_app.task(
|
||||||
name="alerts.run_query",
|
name="alerts.run_query",
|
||||||
bind=True,
|
bind=True,
|
||||||
soft_time_limit=config["EMAIL_ASYNC_TIME_LIMIT_SEC"],
|
|
||||||
# TODO: find cause of https://github.com/apache/superset/issues/10530
|
# TODO: find cause of https://github.com/apache/superset/issues/10530
|
||||||
# and remove retry
|
# and remove retry
|
||||||
autoretry_for=(NoSuchColumnError, ResourceClosedError,),
|
autoretry_for=(NoSuchColumnError, ResourceClosedError,),
|
||||||
retry_kwargs={"max_retries": 5},
|
retry_kwargs={"max_retries": 1},
|
||||||
retry_backoff=True,
|
retry_backoff=True,
|
||||||
)
|
)
|
||||||
def schedule_alert_query(
|
def schedule_alert_query(
|
||||||
|
@ -844,8 +846,8 @@ def schedule_alerts() -> None:
|
||||||
resolution = 0
|
resolution = 0
|
||||||
now = datetime.utcnow()
|
now = datetime.utcnow()
|
||||||
start_at = now - timedelta(
|
start_at = now - timedelta(
|
||||||
seconds=3600
|
seconds=300
|
||||||
) # process any missed tasks in the past hour
|
) # process any missed tasks in the past few minutes
|
||||||
stop_at = now + timedelta(seconds=1)
|
stop_at = now + timedelta(seconds=1)
|
||||||
with session_scope(nullpool=True) as session:
|
with session_scope(nullpool=True) as session:
|
||||||
schedule_window(ScheduleType.alert, start_at, stop_at, resolution, session)
|
schedule_window(ScheduleType.alert, start_at, stop_at, resolution, session)
|
||||||
|
|
Loading…
Reference in New Issue