Skip to content

Commit

Permalink
CI-1059: small refactor to code to set min grace period (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
VSpike authored Dec 14, 2021
1 parent b310284 commit eebc78d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.0
3.7.1
11 changes: 7 additions & 4 deletions controllers/workloads/console/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,12 @@ func (r *ConsoleReconciler) buildSidecarContainer(consoleId string) corev1.Conta
}
}

func ensureMinimum(target **int64, minimum int64) {
if *target == nil || **target < minimum {
*target = &minimum
}
}

func (r *ConsoleReconciler) addSessionRecordingToPodTemplate(logger logr.Logger, podTemplate *corev1.PodTemplateSpec, consoleId string) *corev1.PodTemplateSpec {

mutatedTemplate := podTemplate.DeepCopy()
Expand Down Expand Up @@ -771,10 +777,7 @@ func (r *ConsoleReconciler) addSessionRecordingToPodTemplate(logger logr.Logger,
// The grace period for the pod must be longer than Sidewrap's delay
// and grace periods combined
var gracePeriod int64 = SidewrapShutdownDelay + SidewrapGracePeriod + 30
if mutatedTemplate.Spec.TerminationGracePeriodSeconds == nil ||
*mutatedTemplate.Spec.TerminationGracePeriodSeconds < gracePeriod {
mutatedTemplate.Spec.TerminationGracePeriodSeconds = &gracePeriod
}
ensureMinimum(&mutatedTemplate.Spec.TerminationGracePeriodSeconds, gracePeriod)

return mutatedTemplate
}
Expand Down

0 comments on commit eebc78d

Please sign in to comment.