Skip to content

NO-ISSUE: pkg/cli/admin/release/extract: Read manifests into memory#2232

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
wking:release-extract-read-manifests-into-memory-write-after-tar
Mar 19, 2026
Merged

NO-ISSUE: pkg/cli/admin/release/extract: Read manifests into memory#2232
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
wking:release-extract-read-manifests-into-memory-write-after-tar

Conversation

@wking
Copy link
Member

@wking wking commented Mar 18, 2026

And write them to disk after exiting the tar callback. This uses a bit more memory during processing, but sets us up for more efficient two-stage processing (e.g. if we need to extract feature gates from the manifests to know which manifests need including, #2222).

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 18, 2026
@openshift-ci-robot
Copy link

@wking: This pull request explicitly references no jira issue.

Details

In response to this:

And write them to disk after exiting the tar callback. This uses a bit more memory during processing, but sets us up for more efficient two-stage processing (e.g. if we need to extract feature gates from the manifests to know which manifests need including, #2222).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 5613752b-98db-4aaf-aa38-05c5924e209a

📥 Commits

Reviewing files that changed from the base of the PR and between 525fd35 and 760045b.

📒 Files selected for processing (1)
  • pkg/cli/admin/release/extract.go

Walkthrough

Extraction now runs in two phases: tar entries are parsed and their contents collected into in-memory records (manifests or raw bytes). After archive parsing completes, a single post-processing pass applies filtering and writes serialized manifests or raw files to disk.

Changes

Cohort / File(s) Summary
Extraction core refactor
pkg/cli/admin/release/extract.go
Replaced immediate per-tar-entry emission with in-memory accumulation: added internal files []extractedFile and extractedFile type (name, manifests, rawData). Tar callback now collects entries; a post-extraction loop performs filtering (Included, CredentialsRequests, ProviderSpec), serializes manifests (---\n separated), and writes raw blobs or manifest files to --to directory. Credential-request conditional skipping preserved but evaluated at emit time. Manifest error reporting under ExtractManifests now happens during emission.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested review from atiratree and tchap March 18, 2026 21:31
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 18, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/cli/admin/release/extract.go`:
- Around line 489-498: The loop over o.files opens files and uses defer
file.Close() which delays closing until the enclosing function returns, risking
descriptor exhaustion; change this so each file is closed immediately by either
moving the per-file logic into a small helper function (e.g.,
extractOneFile(fileEntry) that creates, writes and defers Close inside it) or by
explicitly calling file.Close() at the end of the loop iteration instead of
deferring; update the code paths that set out (the block using os.Create, file,
err, out and related write logic) to ensure the file handle is closed before the
next iteration.
- Around line 507-548: This block uses out-of-scope symbols and wrong return
types: pull the helper variables and functions (include,
expectedProviderSpecKind) out of the inner if so they are visible here (or move
this whole filtering block back inside the o.ExtractManifests/TarEntryCallback
scope), replace every use of ms with f.manifests and update the exclusion logic
to modify f.manifests in-place (or re-slice into a new slice and assign back to
f.manifests), and change the erroneous return of "return false, fmt.Errorf(...)"
to "return fmt.Errorf(...)" to match Run()'s signature; target symbols to edit
are include, expectedProviderSpecKind, f.manifests and the error return in
Run()/this function.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 466311d5-6a73-4e3d-a345-b85844a99e03

📥 Commits

Reviewing files that changed from the base of the PR and between ee23f05 and 1f39453.

📒 Files selected for processing (1)
  • pkg/cli/admin/release/extract.go

@wking wking force-pushed the release-extract-read-manifests-into-memory-write-after-tar branch 2 times, most recently from 5c02456 to 525fd35 Compare March 18, 2026 22:52
wking added a commit to wking/oc that referenced this pull request Mar 18, 2026
And write them to disk after exiting the tar callback.  This uses a
bit more memory during processing, but sets us up for more efficient
two-stage processing (e.g. if we need to extract feature gates from
the manifests to know which manifests need including).

The:

  for _, f := range o.file {
    err := func() error {
      ...
        defer file.Close()
      ...
    }()
    if err != nil {
      return err
    }
  }

closure scopes the defer to one round of the loop [1]:

  A "defer" statement invokes a function whose execution is deferred
  to the moment the surrounding function returns...

otherwise open file descriptors would accumulate and only get closed
once the whole loop completes.  CodeRabbit recommended an explicit
Close, but I prefer the simplicity of defer, even if it means another
level of intentation nesting.

[1]: https://go.dev/ref/spec#Defer_statements
[2]: openshift#2232 (comment)
And write them to disk after exiting the tar callback.  This uses a
bit more memory during processing, but sets us up for more efficient
two-stage processing (e.g. if we need to extract feature gates from
the manifests to know which manifests need including).

The:

  for _, f := range o.file {
    err := func() error {
      ...
        defer file.Close()
      ...
    }()
    if err != nil {
      return err
    }
  }

closure scopes the defer to one round of the loop [1]:

  A "defer" statement invokes a function whose execution is deferred
  to the moment the surrounding function returns...

otherwise open file descriptors would accumulate and only get closed
once the whole loop completes.  CodeRabbit recommended an explicit
Close, but I prefer the simplicity of defer, even if it means another
level of intentation nesting.

[1]: https://go.dev/ref/spec#Defer_statements
[2]: openshift#2232 (comment)
@wking wking force-pushed the release-extract-read-manifests-into-memory-write-after-tar branch from 525fd35 to 760045b Compare March 19, 2026 03:56
@JoelSpeed
Copy link
Contributor

/lgtm
/retest

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 19, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wking
Copy link
Member Author

wking commented Mar 19, 2026

/verified by @wking

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Mar 19, 2026
@openshift-ci-robot
Copy link

@wking: This PR has been marked as verified by @wking.

Details

In response to this:

/verified by @wking

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@JoelSpeed
Copy link
Contributor

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 19, 2026

@wking: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit e3f7056 into openshift:main Mar 19, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants