Skip to content

Conversation

hongkailiu
Copy link
Member

@hongkailiu hongkailiu commented Jun 20, 2025

This pull adds a new type ManifestReceiver that works as a middleware
between the upstream extract.ExtractOptions's TarEntryCallback and
the downstream manifestsCallback.

There are two files image-references and release-metadata that are
handled differently from manifest files. When those files come, their
readers from the upstream are sent to the downstream callback right
away.

Other files contain manifests. They are parsed out and then sent to the
downstream. We will embed more changes into this part, e.g., collecting
all manifests in the image and then use them to calculate the enabled
capabilities which are sent as an argument to the downstream callback.
Those changes are coming in other pulls.

/hold

Will rebase after #2047 gets in.

@hongkailiu hongkailiu changed the title Ota 1010 simplify 2 Isolate manifest handling in image-extraction Jun 20, 2025
@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 20, 2025
@openshift-ci openshift-ci bot requested review from deads2k and ingvagabund June 20, 2025 14:59
Copy link
Contributor

openshift-ci bot commented Jun 20, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hongkailiu
Once this PR has been reviewed and has the lgtm label, please assign davidhurta for approval. For more information see the Code Review Process.

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

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

@hongkailiu hongkailiu force-pushed the OTA-1010-simplify-2 branch 2 times, most recently from 68470c8 to e144a77 Compare June 20, 2025 19:06
@hongkailiu hongkailiu changed the title Isolate manifest handling in image-extraction Isolate manifest handling in release-extraction Jun 20, 2025
@hongkailiu
Copy link
Member Author

Test e144a77 with

launch 4.13.12 aws,single-node

$ ./oc adm release extract --included --credentials-requests --to credentials-requests quay.io/openshift-release-dev/ocp-release:4.14.0-rc.0-x86_64
Extracted release payload from digest sha256:1d2cc38cbd94c532dc822ff793f46b23a93b76b400f7d92b13c1e1da042c88fe created at 2023-09-07T07:37:47Zoc git:(OTA-1010-simplify-2) ✗ rg ImageRegistry credentials-requests
credentials-requests/0000_50_cluster-image-registry-operator_01-registry-credentials-request.yaml
6:    capability.openshift.io/name: ImageRegistryoc git:(OTA-1010-simplify-2) ✗ ll credentials-requests
total 48
-rw-r--r--@ 1 hongkliu  staff   1.8K Jun 20 15:08 0000_30_machine-api-operator_00_credentials-request.yaml
-rw-r--r--@ 1 hongkliu  staff   738B Jun 20 15:08 0000_50_cloud-credential-operator_05-iam-ro-credentialsrequest.yaml
-rw-r--r--@ 1 hongkliu  staff   1.3K Jun 20 15:08 0000_50_cluster-image-registry-operator_01-registry-credentials-request.yaml
-rw-r--r--@ 1 hongkliu  staff   920B Jun 20 15:08 0000_50_cluster-ingress-operator_00-ingress-credentials-request.yaml
-rw-r--r--@ 1 hongkliu  staff   1.0K Jun 20 15:08 0000_50_cluster-network-operator_02-cncc-credentials.yaml
-rw-r--r--@ 1 hongkliu  staff   1.5K Jun 20 15:08 0000_50_cluster-storage-operator_03_credentials_request_aws.yaml

$ ./oc adm release extract --included --file=0000_30_machine-api-operator_00_credentials-request.yaml quay.io/openshift-release-dev/ocp-release:4.14.0-rc.0-x86_64 
apiVersion: cloudcredential.openshift.io/v1
kind: CredentialsRequest
...

@petr-muller
Copy link
Member

/cc

This pull adds a new type `ManifestReceiver` that works as a middleware
between the upstream `extract.ExtractOptions`'s `TarEntryCallback` and
the downstream `manifestsCallback`.

There are two files `image-references` and `release-metadata` that are
handled differently from manifest files. When those files come, their
readers from the upstream are sent to the downstream callback right
away.

Other files contain manifests. They are parsed out and then sent to the
downstream. We will embed more changes into this part, e.g., collecting
all manifests in the image and then use them to calculate the enabled
capabilities which are sent as an argument to the downstream callback.
Those changes are coming in other pulls.
@hongkailiu hongkailiu force-pushed the OTA-1010-simplify-2 branch from 077ae8f to 9944151 Compare June 26, 2025 14:39
@hongkailiu hongkailiu changed the title Isolate manifest handling in release-extraction NO-JIRA: Isolate manifest handling in release-extraction Jun 26, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 26, 2025
@openshift-ci-robot
Copy link

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

In response to this:

This pull adds a new type ManifestReceiver that works as a middleware
between the upstream extract.ExtractOptions's TarEntryCallback and
the downstream manifestsCallback.

There are two files image-references and release-metadata that are
handled differently from manifest files. When those files come, their
readers from the upstream are sent to the downstream callback right
away.

Other files contain manifests. They are parsed out and then sent to the
downstream. We will embed more changes into this part, e.g., collecting
all manifests in the image and then use them to calculate the enabled
capabilities which are sent as an argument to the downstream callback.
Those changes are coming in other pulls.

/hold

Will rebase after #2047 gets in.

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.

// * with the reader that contains the content of each file whose name is in skipNames.
// All the errors encountered when parsing the manifests are collected in ManifestErrs.
type ManifestReceiver struct {
manifestsCallback func(filename string, manifests []manifest.Manifest, reader io.Reader) (cont bool, err error)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just call it downstreamCallback? Even your Godoc talks about it that way. Calling it manifestCallback is a bit confusing to me because it kinda hints that it would be called with just manifests (esp. together with the other field called 'skipNames`)

// All the errors encountered when parsing the manifests are collected in ManifestErrs.
type ManifestReceiver struct {
manifestsCallback func(filename string, manifests []manifest.Manifest, reader io.Reader) (cont bool, err error)
skipNames sets.Set[string]
Copy link
Member

Choose a reason for hiding this comment

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

The skipNames naming is a bit confusing to me; "skip" makes me think they are skipped entirely, but they are actually just not parsed as manifests. And actually they are anti-skipped because they would otherwise be skipped because they are not json/yaml files.

klog.V(4).Infof("Found manifest %s", h.Name)
ms, err := manifest.ParseManifests(r)
if err != nil {
mr.ManifestErrs = append(mr.ManifestErrs, errors.Wrapf(err, "error parsing %s", h.Name))
Copy link
Member

Choose a reason for hiding this comment

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

This makes the callback concurrent-unsafe; that's fine (IIRC you already checked once that it is never called in parallel - but maybe it should?) but the GoDoc should mention it.

Copy link
Contributor

openshift-ci bot commented Jul 16, 2025

@hongkailiu: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-serial-1of2 9944151 link true /test e2e-aws-ovn-serial-1of2

Full PR test history. Your PR dashboard.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants