Skip to content

feat: add lifecycle and terminationGracePeriodSeconds values#110

Merged
brendan-kellam merged 4 commits into
mainfrom
bkellam/lifecycle-hooks
Jun 2, 2026
Merged

feat: add lifecycle and terminationGracePeriodSeconds values#110
brendan-kellam merged 4 commits into
mainfrom
bkellam/lifecycle-hooks

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

@brendan-kellam brendan-kellam commented Jun 2, 2026

What

Adds two passthrough values to the Sourcebot deployment:

  • sourcebot.lifecycle — container lifecycle hooks (e.g. a preStop sleep)
  • sourcebot.terminationGracePeriodSeconds — pod termination grace period

Both default to no-ops ({} / null), so existing deployments are unchanged.

Why

On EKS (and other ALB/NLB setups), rolling updates can return brief 502s on the scale-down side: when the old pod terminates, the load balancer may still route to it for a moment while it deregisters the target. A preStop sleep keeps the pod serving during that deregistration window, and terminationGracePeriodSeconds ensures the pod isn't SIGKILLed before the sleep + graceful shutdown complete.

Example:

sourcebot:
  lifecycle:
    preStop:
      exec:
        command: ["/bin/sh", "-c", "sleep 15"]
  terminationGracePeriodSeconds: 45

Changes

  • templates/deployment.yaml — render lifecycle (container) and terminationGracePeriodSeconds (pod spec), guarded by with so they're omitted when unset
  • values.yaml — defaults + documentation
  • values.schema.json — register both (schema is additionalProperties: false)
  • CHANGELOG.md[Unreleased] entry

Testing

helm template renders both fields correctly when set and omits them at defaults; schema validation passes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Pod lifecycle hooks configuration now available, enabling customization of container startup and shutdown behaviors for improved deployment control.
    • Pod termination grace period is now fully configurable, providing flexibility in managing graceful shutdown timing and resource cleanup during pod termination.

Lets a preStop hook keep the pod serving while a load balancer finishes
deregistering its target during a rolling update, avoiding 502s on the
scale-down side. Both default to no-ops, so behavior is unchanged unless set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Warning

Review limit reached

@brendan-kellam, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 48 minutes and 19 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2e01d38-14ed-4547-b8a0-ae0af923d193

📥 Commits

Reviewing files that changed from the base of the PR and between fe80a78 and 966ae8d.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • charts/sourcebot/README.md
  • charts/sourcebot/templates/deployment.yaml

Walkthrough

This PR extends the sourcebot Helm chart to support Kubernetes pod lifecycle hooks and graceful termination configuration. It adds two new optional values: lifecycle (container lifecycle hooks) and terminationGracePeriodSeconds (pod termination grace period), with schema validation, default values, template implementation, and changelog documentation.

Changes

Kubernetes Graceful Termination Configuration

Layer / File(s) Summary
Configuration schema and default values
charts/sourcebot/values.schema.json, charts/sourcebot/values.yaml
The values schema defines lifecycle as an optional object and terminationGracePeriodSeconds as either an integer or null. Default values are provided: empty map for lifecycle and null for termination grace period.
Pod and container lifecycle configuration in deployment template
charts/sourcebot/templates/deployment.yaml
The deployment template conditionally renders terminationGracePeriodSeconds at the pod spec level and a lifecycle block at the container level, both sourced from the configured values.
Release notes documentation
CHANGELOG.md
The Unreleased section is updated to document the two new configurable values for operators.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding lifecycle and terminationGracePeriodSeconds values to the Helm chart configuration, which is reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bkellam/lifecycle-hooks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Helm Unit Test Results

11 tests  ±0   11 ✅ ±0   0s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 966ae8d. ± Comparison against base commit b701360.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
charts/sourcebot/values.schema.json (1)

173-175: ⚡ Quick win

Consider adding a minimum constraint to prevent negative values.

Kubernetes terminationGracePeriodSeconds only accepts 0 or positive integers. Adding "minimum": 0 would catch invalid negative values at schema validation time.

✨ Proposed schema enhancement
 "terminationGracePeriodSeconds": {
-  "type": ["integer", "null"]
+  "type": ["integer", "null"],
+  "minimum": 0
 },
🤖 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 `@charts/sourcebot/values.schema.json` around lines 173 - 175, The schema for
terminationGracePeriodSeconds currently allows integers but not constrained
against negatives; update the values.schema.json entry for
"terminationGracePeriodSeconds" to include a "minimum": 0 (while keeping the
existing "type": ["integer","null"]) so schema validation rejects negative
values; locate the "terminationGracePeriodSeconds" property and add the
"minimum": 0 constraint.
🤖 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.

Inline comments:
In `@charts/sourcebot/templates/deployment.yaml`:
- Around line 33-35: The template guard using "{{- with
$.Values.sourcebot.terminationGracePeriodSeconds }}" drops valid 0 values;
change the guard to test for non-nil explicitly by replacing the with block with
an if that checks "ne $.Values.sourcebot.terminationGracePeriodSeconds nil" so
terminationGracePeriodSeconds: {{ . }} (or use the value expression) is rendered
even when set to 0; update the matching "{{- end }}" accordingly and keep the
same symbol $.Values.sourcebot.terminationGracePeriodSeconds in the template.

---

Nitpick comments:
In `@charts/sourcebot/values.schema.json`:
- Around line 173-175: The schema for terminationGracePeriodSeconds currently
allows integers but not constrained against negatives; update the
values.schema.json entry for "terminationGracePeriodSeconds" to include a
"minimum": 0 (while keeping the existing "type": ["integer","null"]) so schema
validation rejects negative values; locate the "terminationGracePeriodSeconds"
property and add the "minimum": 0 constraint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8deb8f77-cc72-4ce2-83d3-22c104c2bcd4

📥 Commits

Reviewing files that changed from the base of the PR and between b701360 and fe80a78.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • charts/sourcebot/templates/deployment.yaml
  • charts/sourcebot/values.schema.json
  • charts/sourcebot/values.yaml

Comment thread charts/sourcebot/templates/deployment.yaml Outdated
@brendan-kellam brendan-kellam merged commit 463a6b2 into main Jun 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant