Skip to content

Commit 8f77948

Browse files
registry_pod: Avoid grace period delay
The shell script does not propagate the SIGTERM signal that is sent to the pod when it is terminated; to avoid this, we run the last command to substitute the shell process, so that the pod stop immediately instead of waiting the 30 default seconds of the grace period when an user uninstall the operator by using 'operator-sdk cleanup ...' command. Signed-off-by: Alejandro Visiedo <learning.little.engineer.2025.1@gmail.com>
1 parent f6829d4 commit 8f77948

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

internal/olm/operator/registry/index/registry_pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const cmdTemplate = `[[ -f {{ .DBPath }} ]] && cp {{ .DBPath }} /tmp/tmp.db; \
377377
{{- range $i, $item := .BundleItems }}
378378
opm registry add -d /tmp/tmp.db -b {{ $item.ImageTag }} --mode={{ $item.AddMode }}{{ if $.CASecretName }} --ca-file=/certs/cert.pem{{ end }} --skip-tls-verify={{ $.SkipTLSVerify }} --use-http={{ $.UseHTTP }} && \
379379
{{- end }}
380-
opm registry serve -d /tmp/tmp.db -p {{ .GRPCPort }}
380+
exec opm registry serve -d /tmp/tmp.db -p {{ .GRPCPort }}
381381
`
382382

383383
// getContainerCmd uses templating to construct the container command

internal/olm/operator/registry/index/registry_pod_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,5 @@ func containerCommandFor(dbPath string, items []BundleItem, hasCA, skipTLSVerify
291291
additions.WriteString(fmt.Sprintf("opm registry add -d /tmp/tmp.db -b %s --mode=%s%s --skip-tls-verify=%v --use-http=%v && \\\n", item.ImageTag, item.AddMode, caFlag, skipTLSVerify, useHTTP))
292292
}
293293

294-
return fmt.Sprintf("[[ -f %s ]] && cp %s /tmp/tmp.db; \\\n%sopm registry serve -d /tmp/tmp.db -p 50051\n", dbPath, dbPath, additions.String())
294+
return fmt.Sprintf("[[ -f %s ]] && cp %s /tmp/tmp.db; \\\n%sexec opm registry serve -d /tmp/tmp.db -p 50051\n", dbPath, dbPath, additions.String())
295295
}

0 commit comments

Comments
 (0)