-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(operator): pod management #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bmcquilkin-sentry
wants to merge
9
commits into
main
Choose a base branch
from
bmcquilkin/operator/pods
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
50b3b68
feat(operator): pod management
bmcquilkin-sentry 399b877
feat(operator): level-based reconcile w/ daemon
bmcquilkin-sentry 771ab6f
fix(operator): pod name length
bmcquilkin-sentry db11345
fix(operator): stale removed set bug
bmcquilkin-sentry ca2e22e
ref(k8s): remove rbac from here
bmcquilkin-sentry 7fa09a8
ref(operator): use status.generations instead of configmap
bmcquilkin-sentry 33d025e
ref(operator): create podhealth dataclass
bmcquilkin-sentry 054abf7
ref(operator): pod status module
bmcquilkin-sentry c2ce18e
ref(operator): properly typed k8s
bmcquilkin-sentry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
sentry_streams_k8s/chart/streaming-operator/templates/rbac.yaml
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
sentry_streams_k8s/sentry_streams_k8s/operator/constants.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| GROUP = "streams.sentry.io" | ||
| VERSION = "v1alpha1" | ||
| PLURAL = "streamingpipelines" | ||
|
|
||
| FIELD_MANAGER = "streaming-operator" | ||
| WORKLOAD_NAMESPACE_ENV = "WORKLOAD_NAMESPACE" | ||
|
|
||
| # The CR and its workloads may live in different namespaces, so we cannot use | ||
| # ownerReferences (Kubernetes forbids cross-namespace owning) or kopf.adopt. | ||
| # Instead every workload carries the owning CR's UID as a label with | ||
| # name/namespace annotations so the operator can delete resources itself: | ||
|
|
||
| OWNER_UID_LABEL = "streams.sentry.io/owner-uid" | ||
| OWNER_NAME_ANNOTATION = "streams.sentry.io/owner-name" | ||
| OWNER_NAMESPACE_ANNOTATION = "streams.sentry.io/owner-namespace" | ||
|
|
||
| # Marks every Pod the operator manages so the cluster-wide Pod event watcher can | ||
| # select operator-owned Pods without knowing their individual UIDs: | ||
|
|
||
| MANAGED_BY_LABEL = "streams.sentry.io/managed-by" | ||
|
|
||
| # Identifies independently reconciled Pod sets owned by the same pipeline: | ||
|
|
||
| WORKLOAD_SET_LABEL = "streams.sentry.io/workload-set" | ||
|
|
||
| PRIMARY_WORKLOAD_SET = "primary" | ||
| CANARY_WORKLOAD_SET = "canary" | ||
|
|
||
| ALL_WORKLOAD_SETS = (PRIMARY_WORKLOAD_SET, CANARY_WORKLOAD_SET) | ||
|
|
||
| # The ordinal is the stable replica number. The generation increments each time a replica's | ||
| # Pod is replaced so the new Pod's name never collides with a still-terminating old one: | ||
|
|
||
| ORDINAL_LABEL = "streams.sentry.io/ordinal" | ||
| GENERATION_LABEL = "streams.sentry.io/generation" | ||
|
|
||
| # Pod names are cannot exceed 63 characters, so we reserve space for the | ||
| # largest possible replicas + generation and give the rest to the base name: | ||
|
|
||
| MAX_POD_NAME_LENGTH = 63 | ||
|
|
||
| MAX_REPLICAS = 999 | ||
| MAX_GENERATION = 9999 | ||
|
|
||
| MAX_BASE_NAME_LENGTH = MAX_POD_NAME_LENGTH - len(f"-{MAX_REPLICAS}-{MAX_GENERATION}") | ||
|
|
||
| # Hash of the desired Pod state. Used to detect config/spec changes: | ||
|
|
||
| SPEC_HASH_ANNOTATION = "streams.sentry.io/spec-hash" | ||
|
|
||
| # Waiting states that may recover when the operator creates a new Pod: | ||
|
|
||
| UNHEALTHY_WAITING_REASONS = frozenset({"ErrImagePull", "ImagePullBackOff"}) | ||
|
|
||
| # Waiting states caused by an invalid workload specification. | ||
| # Should raise a PermanentError and not trigger replacement: | ||
|
|
||
| PERMANENT_WAITING_REASONS = frozenset({"InvalidImageName"}) | ||
|
|
||
| # WAITING_GRACE: A Pod stuck in a bad waiting state is terminated after this long. | ||
| # TERMINATING_GRACE: A Pod stuck in a terminating state for this long is force-deleted. | ||
|
|
||
| POD_WAITING_GRACE_SECONDS = 300 | ||
| POD_TERMINATING_GRACE_SECONDS = 600 | ||
|
|
||
| # How often the daemon re-runs a full reconcile as a safety net behind the watch: | ||
|
|
||
| HEALTH_SCAN_INTERVAL_SECONDS = 60 | ||
|
|
||
| # Bound full reconciliations across pipelines so changes | ||
| # to many CRs cannot overload Kubernetes API requests: | ||
|
|
||
| MAX_CONCURRENT_RECONCILES = 4 | ||
|
|
||
| Logger = Any | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unhandled waiting reasons stay silent
Medium Severity
pod_healthonly classifiesErrImagePull,ImagePullBackOff, andInvalidImageNamewaiting states. Other common failures such asCreateContainerConfigErrorproduce noreason, so Pods are neither replaced, marked permanent, nor listed underunhealthyPods, leaving pipelines stuck withreadyReplicasat 0 and little signal why.Additional Locations (1)
sentry_streams_k8s/sentry_streams_k8s/operator/pod_health.py#L148-L181Reviewed by Cursor Bugbot for commit db11345. Configure here.