8000 🐛 Fix E2E regressions from the core rebuild by abahmed · Pull Request #528 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content

🐛 Fix E2E regressions from the core rebuild - #528

Merged
abahmed merged 18 commits into
mainfrom
fix/e2e-regressions
Oct 3, 2026
Merged

abahmed merged 18 commits into
mainfrom
fix/e2e-regressions

Conversation

@abahmed
@abahmed abahmed commented Oct 2, 2026
Copy link
Copy Markdown
Owner

Summary

The full E2E run on main (3483373) failed: all four Operational smoke jobs, and the Kind scenarios (which then hit the 1h test timeout). Causes, from the run's logs and artifacts:

Product bug (fixed)

  • Creating kube-root-ca.crt, the default ServiceAccount or any ConfigMap/Secret counted as a recent change that explains a failure. Every pod references the first through its token volume, and a new namespace creates both, so incidents for missing Secrets/ConfigMaps and failing hooks were rooted at configmap/<ns>/kube-root-ca.crt. Creating such an object can only satisfy a reference, so the engine no longer reads those creations as changes. TestExplainIgnoresBootstrapObjectCreation reproduces the CI misattribution and fails without the fix.

Test and script bugs (fixed)

  • assert_can in test-kind-production.sh: kubectl auth can-i exits 1 on "no", which killed the script silently under set -e. This failed every smoke job.
  • The audit matcher did not accept container roots (container/<ns>/<pod>/<container>), so hook and lifecycle scenarios never matched.
  • Ingress scenario expected the Ingress name, but the incident is rooted at the missing Service.
  • Service-account scenario updated a stale Pod object (conflict).
  • base-config.yaml still carried removed keys (smartGrouping, *Monitor, ...), which are ignored with a warning.

Scenarios that asserted behavior that cannot happen (removed from the suite)

  • integration.control-plane: deleting the scheduler's mirror Pod through the API does not stop the scheduler, so its Lease keeps renewing and SchedulerUnavailable is correctly never raised. Marked unsupported-in-kind.
  • security.admission-policy: nothing reads status.typeChecking.expressionWarnings, so AdmissionPolicyInvalid was never raised for a ValidatingAdmissionPolicy. Marked planned.

Not in this PR

  • TestScenarioConfigurationReload and TestScenarioInvalidLiveConfiguration send fields the CRD no longer has (pruned by the API server), so they pass but test little.
  • The removed *Monitor keys used to shorten detection times in the suite; there is no replacement knob, so scenario timeouts may need tuning if this run shows slow detection.

Test plan

  • make verify-focused on rootcause, incident, scenarios, pipeline and test/e2e; docs-verify; shellcheck
  • E2E workflow (label e2e) green on this PR

Root cause: creating kube-root-ca.crt, the default ServiceAccount or any
ConfigMap/Secret counted as a change that explains a failing pod, so
every pod in a new namespace was blamed on its token volume's ConfigMap.
Creating such an object can only satisfy a reference, never break one.

Also: assert_can in the smoke script died on "no" under set -e, the
audit matcher now accepts container roots, the ingress and service
account scenarios expected the wrong resource and a stale Update, the
scheduler and admission-policy scenarios asserted behavior that cannot
happen in Kind or was never implemented, and the base config carried
removed keys.
@abahmed abahmed added the e2e Run the real-cluster E2E suite on this pull request label Oct 2, 2026
abahmed added 17 commits October 3, 2026 03:06
Introduce inNamespace/onCluster, Expect* helpers and one timing file so a
scenario reads as create, expect, fix, expect. Convert the crash-loop and
resolution scenarios as the pattern. Also fix the harness and tests found
in the second CI run: webhook payload matcher, health retry, probe waits,
heartbeat pod security, metrics-api root and service selector edit.
Convert every scenario to the Scenario helper (create, expect, fix,
expect) with one timing file, shared fixtures per area and a README
guide. Scenario files shrink from about 3,300 to 1,500 lines.

Fix the stale assertions found by auditing the scenarios that had never
run against the rebuilt engine: ErrImageNeverPull for PullNever pods,
JobBackoffLimitExceeded, the quota root for ReplicaSetFailure, symptom
findings missing from audit reasons, the 10 minute PDB sustain and
conflict-prone Deployment updates. Pick a node that hosts neither
kwatch nor the receiver for node tests (third Kind worker), make the
OOM workload touch its pages, and spread scenarios over four shards by
coverage order.
Resolved audit rows have no reason, so ExpectResolved no longer takes one,
and an incident may first appear as an update, so ExpectIncident accepts
any announcement. Expectations now match what Kwatch reports: readiness
is ReadinessProbeFailed, a failing liveness probe is a crash loop, the PDB
incident is rooted at its Deployment, and the missing ServiceAccount
needs two minutes. The resolution scenarios use a missing ConfigMap,
because a crash loop flaps and doubles the resolve hold.

The heartbeat Kwatch gets the webhook URL file and its own Lease Role and
prints its log if it fails. The smoke script waits for the API after the
control-plane restart.

Skip as known gaps the three scenarios that expose real engine problems
(pod incidents announced before the node or registry cause, tracked
separately) and drop the ephemeral-storage eviction scenario, which Kind
cannot reproduce.
The heartbeat URL is sensitive, so the test Kwatch must read it through a
${file:} reference. After the control-plane restart the Lease can still
name a replaced Pod, so the smoke script looks the holder up again until
it answers.
The workload's healthy, sleep, disk and memory modes ended in a bare
select{}, which the Go runtime turns into a deadlock crash, so every
"healthy" pod exited with Error. That made rollouts never finish,
incidents never resolve and node and eviction scenarios look like engine
problems. Block with a sleep loop instead, and bring the node and
ephemeral-storage scenarios back.

Kwatch collects the incidents it finds right after a cold start into one
startup summary, so the first scenario of a run now waits until Kwatch is
past that window.
A resolved incident carries the root it had at the end (the Deployment,
not the ConfigMap that was missing first). The audit wait now honours the
caller's deadline, so the PDB scenario can wait its 13 minutes. Kwatch
gets slackTime to become ready after a restart. The metrics APIService is
restored before the namespace is deleted, because deletion waits on every
API group. The active-probe scenario is skipped as a known gap.
The kubelet retries a Pod that cannot start with growing delays, so the fix
could reach the workload minutes late and the incident missed the wait.
Every helper is a Scenario method that stops the test itself, so scenario
bodies carry no context, client or namespace plumbing. One builder per
object kind replaces the duplicated Deployment and Pod builders, files are
named by what they build, the history-based fixture prefixes are gone, and
unused harness code is removed. The configuration reload tests now send
resyncSeconds, a field the CRD defines, so the reload and the rejected
value are real.
Scenarios that only touch their own namespace now run side by side
(SCENARIO_PARALLEL, default 6). Those that stop a node, restart Kwatch,
use the webhook receiver or break a cluster-wide API run alone through
inNamespaceAlone or onCluster. Shards are filled longest test first from
the minutes in coverage.yaml, and each run prints the measured time of
every scenario so those minutes can be kept accurate. Audit waits poll
every two seconds, since parallel scenarios all read the Kwatch log.
The rollout restart, upgrade and rollback steps had the same race as the
node restart: the Lease could still name the Pod that was going away, and
the port-forward lost its connection. All four steps now share one wait
that looks the holder up again on every attempt.
ExpectIncident now returns the incident ID and ExpectResolved waits for
that incident, because an incident's root can change while it is open.
Diagnostics were captured before the scenario namespace was deleted and
then overwritten by a second capture without it; each scenario now
captures once. Shard minutes come from the first measured run.
A resolved entry of a node incident opened by an earlier scenario made
the shared-node check pass its root test with no tier and fail at once.
Skip the resolution scenario as a known gap: on a real cluster the
incident rooted at a missing ConfigMap stays open after the fix, which
is tracked as a product bug.
The refailure scenario hits the same never-resolving incident as the
resolution scenario, and the shared-node scenario sometimes gets one
FailedMount incident per Deployment instead of a single node page.
At -v=4 Kwatch logs every finding raised, changed or cleared and every
finding that joins or leaves an incident, which shows why an incident
stays open. A CI run for one scenario turns this on and also runs
scenarios skipped as known gaps, so a bug can be debugged on a real
cluster.
- A pod's start-up failure events (FailedMount, sandbox, attach) no
  longer count once the pod became ready after them, so a common kubelet
  blip no longer sends one alert per Deployment.
- Event findings of a deleted object of a watched kind clear at once,
  instead of holding an incident open for the 15 minute event window.
- Only incidents restored from the state file wait out the restore grace,
  so an incident opened after a configuration restart resolves after the
  normal hold.
- Image pull failures that only say back-off are grouped under a shared
  registry when two or more workloads fail on it, because the detailed
  pull error is replaced by later kubelet events.

Re-enable the five E2E scenarios that were skipped as known gaps, and
ignore incidents opened before a scenario in its root checks.
@abahmed
abahmed merged commit 423e3ce into main Oct 3, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run the real-cluster E2E suite on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0