feat: add startsAt, endsAt, and duration fields to v1alpha2 Silence CRD#580
Open
QuentinBisson wants to merge 6 commits into
Open
feat: add startsAt, endsAt, and duration fields to v1alpha2 Silence CRD#580QuentinBisson wants to merge 6 commits into
QuentinBisson wants to merge 6 commits into
Conversation
Adds `startsAt`, `endsAt`, and `duration` fields with priority-based resolution, comprehensive testing, and refactored matcher conversion while maintaining full backward compatibility.
QuentinBisson
force-pushed
the
enhance-time-management
branch
from
July 15, 2025 19:05
56d6cd9 to
819f280
Compare
|
@QuentinBisson this is a feature that we need and hope to be added soon! |
…lean up tests and docs
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds explicit silence scheduling to the
observability.giantswarm.io/v1alpha2Silence 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 expiresduration— how long the silence is active fromstartsAt; accepts weeks (w), days (d), hours (h), minutes (m), seconds (s):"7d","2w","1d12h","30m"endsAtanddurationare mutually exclusive (CEL validation);startsAtmust precedeendsAtPriority chain when computing end time:
spec.endsAtspec.startsAt+spec.durationvalid-untilannotation (migration path from v1alpha1)Domain type:
SilenceDuration stringinapi/v1alpha2with aDuration()method that expandsd/wto hours before delegating totime.ParseDuration. The controller callssilence.Spec.Duration.Duration()directly.CRD validation:
pattern: ^(\d+(w|d|h|m|s))+$on thedurationfield.Tests:
SilenceDuration.Duration()covering all unit combinations and invalid inputsendsAtpriority,durationwith explicitstartsAt,durationwith creation timestamp,valid-untilannotation fallback, CEL rejection of both fields set simultaneously, matcher type conversion, finalizer lifecycleDocs: README, MIGRATION.md, CHANGELOG, and samples updated.
Closes #580