feat: make terminationGracePeriodSeconds configurable via field of CollectorSpec#3338
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds an optional ChangesTermination grace period feature
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)Not applicable — the changes are a field addition with default-value logic and documentation updates, lacking a multi-component interaction flow warranting a sequence diagram. 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/hold |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/collector/collector.go (1)
131-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCorrect wiring; consider a named constant for the default value.
The fallback logic correctly mirrors the documented default and matches the added test coverage in
collector_test.go. The only nit: the default value10is now duplicated as a magic number here and in the API doc comment/CRD description (clusterlogforwarder_types.go). Extracting it into a shared constant (e.g.,defaultTerminationGracePeriodSeconds) would reduce the risk of the two drifting apart if the default ever changes.♻️ Optional refactor
+const defaultTerminationGracePeriodSeconds int64 = 10 + func (f *Factory) NewPodSpec(trustedCABundle *v1.ConfigMap, spec obs.ClusterLogForwarderSpec, clusterID string, tlsProfileSpec configv1.TLSProfileSpec, namespace string) *v1.PodSpec { var gracePeriod *int64 if f.CollectorSpec.TerminationGracePeriodSeconds != nil { gracePeriod = f.CollectorSpec.TerminationGracePeriodSeconds } else { - gracePeriod = utils.GetPtr[int64](10) + gracePeriod = utils.GetPtr(defaultTerminationGracePeriodSeconds) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/collector/collector.go` around lines 131 - 142, The fallback wiring in collector pod spec is correct, but the default termination grace period is duplicated as a magic number. Extract the shared default into a named constant (for example, defaultTerminationGracePeriodSeconds) and use it in the collector logic so it stays aligned with the API doc comment and CRD description in clusterlogforwarder_types.go.api/observability/v1/clusterlogforwarder_types.go (1)
125-133: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNew field looks correct; minor consistency nit on the marker syntax.
The new
TerminationGracePeriodSecondsfield is well-documented, uses a pointer type for optionality, and the generated CRD schema (inconfig/crd/bases/...yamlandbundle/manifests/...yaml) correctly reflectsminimum: 1,nullable: true, confirming the marker syntax works as intended.One small nit:
+kubebuilder:validation:Minimum:=1uses the:=assignment form, while every other numeric marker in this file (e.g.exclusiveMinimum/minimumon other fields generated elsewhere) uses the plain=form. Since both produce the same output here, this is purely a style inconsistency, not a functional issue.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/observability/v1/clusterlogforwarder_types.go` around lines 125 - 133, The new TerminationGracePeriodSeconds field is fine, but the kubebuilder validation marker uses an inconsistent assignment style. Update the marker on TerminationGracePeriodSeconds in clusterlogforwarder_types.go from the colon-assignment form to the standard plain equals form used by other markers in this API file, keeping the same minimum value and generated CRD behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/observability/v1/clusterlogforwarder_types.go`:
- Around line 125-133: The new TerminationGracePeriodSeconds field is fine, but
the kubebuilder validation marker uses an inconsistent assignment style. Update
the marker on TerminationGracePeriodSeconds in clusterlogforwarder_types.go from
the colon-assignment form to the standard plain equals form used by other
markers in this API file, keeping the same minimum value and generated CRD
behavior.
In `@internal/collector/collector.go`:
- Around line 131-142: The fallback wiring in collector pod spec is correct, but
the default termination grace period is duplicated as a magic number. Extract
the shared default into a named constant (for example,
defaultTerminationGracePeriodSeconds) and use it in the collector logic so it
stays aligned with the API doc comment and CRD description in
clusterlogforwarder_types.go.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ae918120-e55e-41ee-b11c-60939d4e5777
⛔ Files ignored due to path filters (1)
api/observability/v1/zz_generated.deepcopy.gois excluded by!**/zz_generated*
📒 Files selected for processing (7)
api/observability/v1/clusterlogforwarder_types.gobundle/manifests/cluster-logging.clusterserviceversion.yamlbundle/manifests/observability.openshift.io_clusterlogforwarders.yamlconfig/crd/bases/observability.openshift.io_clusterlogforwarders.yamlconfig/manifests/bases/cluster-logging.clusterserviceversion.yamlinternal/collector/collector.gointernal/collector/collector_test.go
fae9922 to
d63dfd1
Compare
|
/hold cancel |
Expose terminationGracePeriodSeconds as a configurable field in spec.collector, allowing users to customize the termination grace period for collector pods. The field is optional with a default of 10 seconds, maintaining backward compatibility with existing deployments. Users can now set spec.collector.terminationGracePeriodSeconds to increase the grace period when needed, e.g., for workloads with heavy disk buffer flushing requirements. Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
|
@vparfonov: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jcantrill, vparfonov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
04f9921
into
openshift:release-6.2
Description
Problem
The collector pods have
terminationGracePeriodSecondshardcoded to10 seconds. WhendeliveryMode: AtLeastOnceis configured, Vector uses disk buffers to persist log data. During shutdown, Vector needs time to flush in-memory events to disk and close connections to remote sinks. If the grace period is too short, Kubernetes sendsSIGKILLwhile a write is in progress, corrupting the disk buffer and causingCrashLoopBackOffwithInvalidProtobufPayloaderrors on restart.Solution
Expose
terminationGracePeriodSecondsas a configurable field inspec.collector, allowing users to set the appropriate grace period for their environment.spec.collector.terminationGracePeriodSecondsExample
/cc @Clee2691
/assign @jcantrill
Links
Summary by CodeRabbit
New Features
Bug Fixes