Ensure OCM runtime cleanup runs before process exit
@markirish is already working on this.
Since Sep 4, 2026.
- Dominant language
- Go
- Stars
- 103
- Forks
- 257
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
Description
Summary
Ensure OCM client cleanup occurs before process termination in the runtime and runner paths.
rosa.DefaultRunner defers r.Cleanup(), but its os.Exit(1) error path bypasses deferred calls. In addition, Runtime.WithOCM() can reach ocm.CreateNewClientOrExit, which can terminate the process during visitor execution before DefaultRunner reaches its deferred cleanup.
Rationale
Runtime.WithOCM() requires Cleanup() to close the OCM connection. The current termination paths can skip that cleanup.
This behavior predates PR #3482. Address it separately because it affects every command that uses DefaultRunner and has cross-command behavior risk.
Affected areas
pkg/rosa/runner.go:DefaultRunnerpkg/rosa/runtime.go:Runtime.WithOCM()and runtime cleanup behavior- The OCM client initialization path that currently uses
ocm.CreateNewClientOrExit
Required changes
Refactor the relevant error paths so that OCM client cleanup occurs before process termination. Preserve current command failure behavior. Avoid process termination from lower-level runtime setup where practical, so the caller can perform cleanup.
Acceptance criteria
- An error after OCM client setup does not bypass
Runtime.Cleanup(). - An OCM client initialization failure does not terminate before the runtime cleanup path can run.
- Existing CLI exit behavior remains correct.
- Tests cover cleanup on each affected failure path.
Requested by @markirish.
Backlinks:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.