id: runtime-end-of-life-watch
namespace: company.team
description: |
Track the runtimes, databases and platforms your services run on against endoflife.date, and alert
the owning team in Slack when a version enters its warning window, its urgent window or reaches end
of life, with the recommended upgrade target. Each stage is announced once per version.
inputs:
- id: components
type: JSON
displayName: Components to track
description: List of objects with a unique key (letters, digits, - and _), an
endoflife.date product, the release cycle you run, an owner and where it
runs.
defaults: |
[
{"key": "orders-db", "product": "postgresql", "version": "14", "owner": "@data-platform", "where": "Primary orders database (RDS)"},
{"key": "billing-api", "product": "python", "version": "3.10", "owner": "@billing-team", "where": "Billing API container image"},
{"key": "web-frontend", "product": "nodejs", "version": "22", "owner": "@web-team", "where": "Next.js frontend build and SSR"},
{"key": "prod-cluster", "product": "amazon-eks", "version": "1.33", "owner": "@platform", "where": "Production EKS cluster"},
{"key": "session-cache", "product": "redis", "version": "8.2", "owner": "@platform", "where": "Session cache"}
]
- id: warning_days
type: INT
displayName: Warning window (days)
description: Announce a version once when its end of life is this close.
defaults: 180
- id: urgent_days
type: INT
displayName: Urgent window (days)
description: Announce it again, as urgent, when its end of life is this close.
defaults: 30
tasks:
- id: for_each_component
type: io.kestra.plugin.core.flow.Loop
description: Check every component independently, five at a time. An unknown
product fails only its own iteration.
values: "{{ inputs.components }}"
concurrencyLimit: 5
tasks:
- id: fetch_releases
type: io.kestra.plugin.core.http.Download
description: All release cycles of the product from the public endoflife.date
API (no key).
uri: "https://endoflife.date/api/v1/products/{{ fromJson(item.value).product }}"
headers:
User-Agent: Kestra-EOL-Watch
- id: load_stage
type: io.kestra.plugin.core.kv.Get
description: The version and lifecycle stage already announced for this
component. Missing on the first run.
key: "eol_watch_{{ fromJson(item.value).key }}"
errorOnMissing: false
- id: evaluate
type: io.kestra.plugin.scripts.python.Script
description: Compute days to end of life, the lifecycle stage and the upgrade
target, and decide whether the stage is new.
containerImage: python:3.12-slim
inputFiles:
product.json: "{{ outputs.fetch_releases.uri }}"
component.json: "{{ item.value }}"
stored.json: "{{ (outputs.load_stage.value ?? {}) | toJson }}"
script: |
import json
import sys
from datetime import date
def load(name):
with open(name, encoding="utf-8") as f:
data = json.load(f)
return json.loads(data) if isinstance(data, str) else data
product = load("product.json")["result"]
component = load("component.json")
stored = load("stored.json") or {}
version = str(component["version"])
releases = product.get("releases", [])
release = next((r for r in releases if r.get("name") == version), None)
if release is None:
names = ", ".join(r.get("name", "") for r in releases[:15])
sys.exit(f"Release '{version}' not found for {product['name']}. Known releases: {names}")
today = date.today()
eol = release.get("eolFrom")
eoes = release.get("eoesFrom")
days_left = (date.fromisoformat(eol) - today).days if eol else None
if release.get("isEol") or (days_left is not None and days_left <= 0):
stage = "eol"
elif days_left is not None and days_left <= {{ inputs.urgent_days }}:
stage = "urgent"
elif days_left is not None and days_left <= {{ inputs.warning_days }}:
stage = "warning"
else:
stage = "ok"
# Upgrade target: the newest maintained cycle, preferring LTS cycles when the product has them.
maintained = [r for r in releases if r.get("isMaintained") and not r.get("isEol")]
lts = [r for r in maintained if r.get("isLts")]
target = (lts or maintained or [None])[0]
rank = {"ok": 0, "warning": 1, "urgent": 2, "eol": 3}
# A new version (after an upgrade) starts from "ok" again.
previous = stored.get("stage", "ok") if stored.get("version") == version else "ok"
should_alert = rank[stage] > rank[previous]
result = {
"product_label": product.get("label", product["name"]),
"version": version,
"stage": stage,
"previous_stage": previous,
"should_alert": should_alert,
"eol_date": eol or "not announced",
"days_left": days_left,
"extended_support_until": eoes,
"latest_patch": (release.get("latest") or {}).get("name"),
"target": target["name"] if target else None,
"target_latest": ((target or {}).get("latest") or {}).get("name"),
"target_eol": (target or {}).get("eolFrom"),
"policy": (product.get("links") or {}).get("releasePolicy") or (product.get("links") or {}).get("html"),
"stored": {"version": version, "stage": stage},
}
print(f"{component['key']}: {result['product_label']} {version} -> {stage} "
f"({days_left} days left, previously {previous}), alert={should_alert}")
print("::" + json.dumps({"outputs": result}) + "::")
- id: if_new_stage
type: io.kestra.plugin.core.flow.If
description: Only post when the component entered a more severe stage than the
one already announced.
condition: "{{ outputs.evaluate.vars.should_alert }}"
then:
- id: alert_owner
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Tell the owning team what reaches end of life, when, and what to
upgrade to.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
messageText: |
{{ outputs.evaluate.vars.stage == 'eol' ? ':red_circle: *End of life reached*' : (outputs.evaluate.vars.stage == 'urgent' ? ':large_orange_circle: *End of life in ' ~ outputs.evaluate.vars.days_left ~ ' days*' : ':large_yellow_circle: *End of life in ' ~ outputs.evaluate.vars.days_left ~ ' days*') }}: {{ outputs.evaluate.vars.product_label }} {{ outputs.evaluate.vars.version }}
Where: {{ fromJson(item.value).where }} | owner: {{ fromJson(item.value).owner }}
End of life: {{ outputs.evaluate.vars.eol_date }}{% if outputs.evaluate.vars.extended_support_until is not null %} | extended support until {{ outputs.evaluate.vars.extended_support_until }}{% endif %} | latest patch of this cycle: {{ outputs.evaluate.vars.latest_patch }}
{% if outputs.evaluate.vars.target is not null %}Upgrade target: {{ outputs.evaluate.vars.product_label }} {{ outputs.evaluate.vars.target }} (latest {{ outputs.evaluate.vars.target_latest }}, supported until {{ outputs.evaluate.vars.target_eol ?? 'not announced' }}){% endif %}
Release policy: {{ outputs.evaluate.vars.policy }}
- id: remember_stage
type: io.kestra.plugin.core.kv.Set
description: Store the announced stage. Runs after the alert, so a failed alert
is retried on the next run.
key: "eol_watch_{{ fromJson(item.value).key }}"
kvType: JSON
overwrite: true
value: "{{ outputs.evaluate.vars.stored | toJson }}"
errors:
- id: alert_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: An unknown product or version must not look like "nothing reaches
end of life".
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
messageText: ":warning: End-of-life watch failed in execution {{ execution.id }}
({{ flow.namespace }}.{{ flow.id }}). Open the failed loop iteration: a
product or version in `components` is probably misspelled."
triggers:
- id: every_monday
type: io.kestra.plugin.core.trigger.Schedule
description: Check every Monday at 08:00. Disabled until the Slack secret is set.
cron: "0 8 * * 1"
disabled: true