Skip to content

Commit

Permalink
Exclude zero values from the probe TGP field
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpage committed Feb 27, 2025
1 parent a57c9f7 commit 3eafec9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions kubernetes/schema_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ func probeSchema(probeType ProbeType) *schema.Resource {
h["termination_grace_period_seconds"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validateTerminationGracePeriodSeconds,
Description: "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's `terminationGracePeriodSeconds` will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). Minimum value is 1. `spec.terminationGracePeriodSeconds` is used if unset.",
ValidateFunc: validateIntGreaterThan(0),
Description: "Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's `terminationGracePeriodSeconds` will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer greater than zero. `spec.terminationGracePeriodSeconds` is used if unset.",
}
}

Expand Down
4 changes: 3 additions & 1 deletion kubernetes/structures_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@ func expandProbe(l []interface{}) *v1.Probe {
if v, ok := in["timeout_seconds"].(int); ok {
obj.TimeoutSeconds = int32(v)
}
if v, ok := in["termination_grace_period_seconds"].(int); ok {

// Set the `TerminationGracePeriodSeconds` field only if it is not set to the default (0)
if v, ok := in["termination_grace_period_seconds"].(int); ok && v != 0 {
obj.TerminationGracePeriodSeconds = ptr.To(int64(v))
}

Expand Down

0 comments on commit 3eafec9

Please sign in to comment.