From e4686f31ce4fb7b900081194486d0894595bf68b Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 28 Apr 2026 12:39:26 -0500 Subject: [PATCH] chore: pending worktree changes (k8s probe, profile loader, e2e Makefile) - k8s/deployment.yaml: bump startup-probe failureThreshold from 12 to 24 (70s -> 130s max startup time) to give the app more headroom on cold start. - lib/towerops/profiles/yaml_profiles.ex: defer YAML profile loading from init/1 to a handle_info(:load_profiles, ...) so the supervisor (and Bandit) come up immediately and the profiles populate in the background within ~60s. - e2e/Makefile: convenience target wrappers around the existing npm scripts. --- e2e/Makefile | 24 ++++++++++++++++++++++++ k8s/deployment.yaml | 2 +- lib/towerops/profiles/yaml_profiles.ex | 15 ++++++++------- 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 e2e/Makefile diff --git a/e2e/Makefile b/e2e/Makefile new file mode 100644 index 00000000..a3858454 --- /dev/null +++ b/e2e/Makefile @@ -0,0 +1,24 @@ +.PHONY: all test local staging ui headed debug report + +all: test + +test: + npm test + +local: + npm run test:local + +staging: + npm run test:staging + +ui: + npm run test:ui + +headed: + npm run test:headed + +debug: + npm run test:debug + +report: + npm run report diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 4c429727..52a73001 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -215,7 +215,7 @@ spec: initialDelaySeconds: 10 periodSeconds: 5 timeoutSeconds: 3 - failureThreshold: 12 # 10s + (12 * 5s) = 70s max startup time + failureThreshold: 24 # 10s + (24 * 5s) = 130s max startup time livenessProbe: httpGet: path: /health diff --git a/lib/towerops/profiles/yaml_profiles.ex b/lib/towerops/profiles/yaml_profiles.ex index ba489bbb..b32309fc 100644 --- a/lib/towerops/profiles/yaml_profiles.ex +++ b/lib/towerops/profiles/yaml_profiles.ex @@ -87,18 +87,19 @@ defmodule Towerops.Profiles.YamlProfiles do @impl true def init(_opts) do - # Create ETS table for profiles _ = :ets.new(@table, [:named_table, :set, :public, read_concurrency: true]) + # Defer loading so the supervisor (and Bandit) start immediately. + # Profiles will be available within ~60s; SNMP polling starts well after that. + send(self(), :load_profiles) + {:ok, %{}} + end - # Load profiles and collect raw YAML data + @impl true + def handle_info(:load_profiles, state) do raw_profiles = load_all_profiles() - - # Extract MIB names and trigger asynchronous pre-resolution in MibCache - # This doesn't block - MibCache will resolve in the background mib_names = extract_mib_names_from_profiles(raw_profiles) MibCache.pre_resolve(mib_names) - - {:ok, %{}} + {:noreply, state} end @impl true