Skip to content

feat: add startsAt, endsAt, and duration fields to v1alpha2 Silence CRD#580

Open
QuentinBisson wants to merge 6 commits into
mainfrom
enhance-time-management
Open

feat: add startsAt, endsAt, and duration fields to v1alpha2 Silence CRD#580
QuentinBisson wants to merge 6 commits into
mainfrom
enhance-time-management

Conversation

@QuentinBisson

@QuentinBisson QuentinBisson commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

Adds explicit silence scheduling to the observability.giantswarm.io/v1alpha2 Silence CRD.

Changes

New spec fields:

  • startsAt — RFC 3339 timestamp for when the silence becomes active (defaults to creation time)
  • endsAt — RFC 3339 timestamp for when the silence expires
  • duration — how long the silence is active from startsAt; accepts weeks (w), days (d), hours (h), minutes (m), seconds (s): "7d", "2w", "1d12h", "30m"
  • endsAt and duration are mutually exclusive (CEL validation); startsAt must precede endsAt

Priority chain when computing end time:

  1. spec.endsAt
  2. spec.startsAt + spec.duration
  3. valid-until annotation (migration path from v1alpha1)
  4. 100-year default (v1alpha1 backward compatibility)

Domain type: SilenceDuration string in api/v1alpha2 with a Duration() method that expands d/w to hours before delegating to time.ParseDuration. The controller calls silence.Spec.Duration.Duration() directly.

CRD validation: pattern: ^(\d+(w|d|h|m|s))+$ on the duration field.

Tests:

  • Table-driven unit tests for SilenceDuration.Duration() covering all unit combinations and invalid inputs
  • Integration tests for: endsAt priority, duration with explicit startsAt, duration with creation timestamp, valid-until annotation fallback, CEL rejection of both fields set simultaneously, matcher type conversion, finalizer lifecycle

Docs: README, MIGRATION.md, CHANGELOG, and samples updated.

Closes #580

@QuentinBisson QuentinBisson self-assigned this Jul 15, 2025
@QuentinBisson
QuentinBisson requested a review from a team as a code owner July 15, 2025 19:00
Adds `startsAt`, `endsAt`, and `duration` fields with priority-based resolution, comprehensive testing, and refactored matcher conversion while maintaining full backward compatibility.
@QuentinBisson
QuentinBisson force-pushed the enhance-time-management branch from 56d6cd9 to 819f280 Compare July 15, 2025 19:05
@QuentinBisson QuentinBisson mentioned this pull request Jul 30, 2025
1 task
@github-project-automation github-project-automation Bot moved this to Inbox 📥 in Roadmap Oct 28, 2025
@QuentinBisson QuentinBisson moved this from Inbox 📥 to Blocked / Waiting ⛔️ in Roadmap Oct 28, 2025
@QuentinBisson QuentinBisson moved this from Blocked / Waiting ⛔️ to Validation ☑️ in Roadmap Oct 28, 2025
@QuentinBisson QuentinBisson moved this from Validation ☑️ to Blocked / Waiting ⛔️ in Roadmap Oct 28, 2025
@github-project-automation github-project-automation Bot moved this from Blocked / Waiting ⛔️ to Validation ☑️ in Roadmap May 20, 2026
@mondaymorningman

Copy link
Copy Markdown

@QuentinBisson this is a feature that we need and hope to be added soon!

@QuentinBisson QuentinBisson reopened this May 27, 2026
@QuentinBisson QuentinBisson changed the title **Enhanced v1alpha2 Silence CRD with flexible time management** feat: add startsAt, endsAt, and duration fields to v1alpha2 Silence CRD May 27, 2026
- Define `SilenceDuration string` in api/v1alpha2 with a `Duration()` method
  that expands d→24h and w→168h before delegating to time.ParseDuration.
- Change `SilenceSpec.Duration` from `*metav1.Duration` to `*SilenceDuration`
  so CRD serialization remains a plain string while the domain type owns parsing.
- Remove parseSilenceDuration and durationExtPattern from the controller; the
  Duration branch now calls silence.Spec.Duration.Duration().
- Update zz_generated.deepcopy.go to use new(SilenceDuration).
- Add table-driven unit tests covering plain units (h, m, s), extended units
  (d, w), combinations (1d12h, 2w3d), and invalid inputs.
- Update CRD YAML (config/ and helm/) with pattern ^(\d+(w|d|h|m|s))+$ and
  corrected duration description.
- Update integration tests to use SilenceDuration string literals.
- Update README, MIGRATION.md, CHANGELOG, and samples to reflect the new
  duration syntax and valid-until fallback chain.
- Hoist durationMultipliers to package-level var (was re-allocated per regex match)
- Switch Duration() error to fmt.Errorf; pkg/errors stack traces are inappropriate in an API types package
- Replace time.Now() fallback with an error return; non-deterministic endsAt when creationTimestamp is zero hides a bug rather than surfacing it
- Fix misleading comment: valid-until annotation is an absolute timestamp, not added to startsAt
- Remove verbose convertMatchers function comment
- Trim redundant mock alertmanager comments
@Rotfuks Rotfuks moved this from Validation ☑️ to Done ✅ in Roadmap Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✅

Development

Successfully merging this pull request may close these issues.

3 participants