openshift / openshift/rosa

Ensure OCM runtime cleanup runs before process exit

Open
#3,502 0 comments 0 reactions 1 assignee View on GitHub

@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: DefaultRunner
  • pkg/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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.