Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTA-994: pkg/cli/admin/release/extract: Centralize manifest extraction #1404

Merged

Conversation

wking
Copy link
Member

@wking wking commented Apr 18, 2023

De-duplicate the manifest-walking logic that used to be split between the ExtractManifests and CredentialsRequests branches. The content written to disk (or o.Out) still depends on which of those two is set, but the manifest parsing portion is now shared from a common location.

This continues the effort begun in #1237 now that openshift/origin#27822 is in place to protect me from accidentally breaking things again. The eventual goal is to only extract expected-to-be-reconciled manifests, but I don't want to need to land that logic in two places, and this should be a no-op refactor that will allow me to land it in one place.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2023
@wking wking force-pushed the unify-release-extract-cases branch 4 times, most recently from 9cd8a49 to 261e686 Compare April 18, 2023 18:27
@petr-muller
Copy link
Member

/cc

@openshift-ci openshift-ci bot requested a review from petr-muller April 19, 2023 10:16
@Davoska
Copy link
Contributor

Davoska commented Apr 19, 2023

/cc

@openshift-ci openshift-ci bot requested a review from Davoska April 19, 2023 12:58
Copy link
Member

@petr-muller petr-muller left a comment

Choose a reason for hiding this comment

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

This looks good to me but that method is a beast and I am not confident I can fully assess whether this can break something later in the process.

Left several nits (I understand this is existing code that was just moved, so feel free to ignore)

pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
@wking wking force-pushed the unify-release-extract-cases branch 2 times, most recently from e125e01 to 881647b Compare April 20, 2023 23:30
@wking wking force-pushed the unify-release-extract-cases branch from 881647b to 6e7d860 Compare July 6, 2023 17:53
@wking
Copy link
Member Author

wking commented Jul 6, 2023

OVNKubernetesResourceRetryFailure is unrelated to this pull request.

@wking wking force-pushed the unify-release-extract-cases branch 2 times, most recently from 1e0d0d7 to b67e995 Compare July 7, 2023 04:57
@wking
Copy link
Member Author

wking commented Jul 7, 2023

/hold

This needs some more work to cover the usual file extraction...

@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 Jul 7, 2023
@wking wking force-pushed the unify-release-extract-cases branch from b67e995 to 2f128c0 Compare July 7, 2023 20:26
@wking
Copy link
Member Author

wking commented Jul 7, 2023

Ok, I think I've got the various cases working with 2f128c0.

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 7, 2023
@wking wking changed the title pkg/cli/admin/release/extract: Centralize manifest extraction OTA-994: pkg/cli/admin/release/extract: Centralize manifest extraction Jul 7, 2023
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 7, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 7, 2023

@wking: This pull request references OTA-994 which is a valid jira issue.

In response to this:

De-duplicate the manifest-walking logic that used to be split between the ExtractManifests and CredentialsRequests branches. The content written to disk (or o.Out) still depends on which of those two is set, but the manifest parsing portion is now shared from a common location.

This continues the effort begun in #1237 now that openshift/origin#27822 is in place to protect me from accidentally breaking things again. The eventual goal is to only extract expected-to-be-reconciled manifests, but I don't want to need to land that logic in two places, and this should be a no-op refactor that will allow me to land it in one place.

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/test-infra repository.

@jiajliu
Copy link

jiajliu commented Jul 12, 2023

/hold

@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 Jul 12, 2023
Copy link
Member

@petr-muller petr-muller left a comment

Choose a reason for hiding this comment

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

/hold

LGTM

Some minor code simplification proposals inline, but none of them are that important, feel free to ignore and unhold

pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
continue
}
if expectedProviderSpecKind != "" {
Copy link
Member

Choose a reason for hiding this comment

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

maybe we could simplify the conditions in the loop and avoid multiple continue

for _, m := range ms {
	if o.CredentialsRequests && m.GVK == credentialsRequestGVK && expectedProviderSpecKind != "" {
		kind, _, err := unstructured.NestedString(m.Obj.Object, "spec", "providerSpec", "kind")
		if err != nil {
			return false, errors.Wrap(err, "error extracting cred request kind")
		}
		if kind == expectedProviderSpecKind {
			manifestsToWrite = append(manifestsToWrite, m)
		}
	}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to keep the manifestsToWrite = append(manifestsToWrite, m) outside of the o.CredentialsRequests branch, so I had a single location to add a m.Include(...) call in follow-up work for --included.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks!

pkg/cli/admin/release/extract.go Outdated Show resolved Hide resolved
@petr-muller
Copy link
Member

/test ci/prow/e2e-agnostic-ovn-cmd
Failed on cluster creation...

This one from ci/prow/e2e-metal-ipi-ovn-ipv6 looks suspicious though:

+(utils.sh:421): setup_legacy_release_mirror(): oc adm release mirror --insecure=true -a /opt/dev-scripts/pull_secret.json --from registry.build05.ci.openshift.org/ci-op-pjwdhyyw/release@sha256:1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a --to-release-image virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a --to virthost.ostest.test.metalkube.org:5000/localimages/local-release-image
+(utils.sh:426): setup_legacy_release_mirror(): tee /opt/dev-scripts/registry/ostest-image_mirror-1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a.log
Flag --print-mirror-instructions's value 'icsp' has been deprecated. Use 'idms' instead to allow the printing of instructions for ImageDigestSources and ImageDigestMirrorSet.
error: unable to load image-references from release payload: invalid character '-' after top-level value 

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 12, 2023

@petr-muller: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build-rpms-from-tar
  • /test e2e-agnostic-ovn-cmd
  • /test e2e-aws-ovn
  • /test e2e-aws-ovn-builds
  • /test e2e-aws-ovn-serial
  • /test e2e-aws-ovn-upgrade
  • /test images
  • /test rpm-build
  • /test unit
  • /test verify
  • /test verify-deps

The following commands are available to trigger optional jobs:

  • /test e2e-aws-certrotation
  • /test e2e-metal-ipi-ovn-ipv6

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-openshift-oc-master-build-rpms-from-tar
  • pull-ci-openshift-oc-master-e2e-agnostic-ovn-cmd
  • pull-ci-openshift-oc-master-e2e-aws-ovn
  • pull-ci-openshift-oc-master-e2e-aws-ovn-serial
  • pull-ci-openshift-oc-master-e2e-aws-ovn-upgrade
  • pull-ci-openshift-oc-master-e2e-metal-ipi-ovn-ipv6
  • pull-ci-openshift-oc-master-images
  • pull-ci-openshift-oc-master-rpm-build
  • pull-ci-openshift-oc-master-unit
  • pull-ci-openshift-oc-master-verify
  • pull-ci-openshift-oc-master-verify-deps

In response to this:

/test ci/prow/e2e-agnostic-ovn-cmd
Failed on cluster creation...

This one from ci/prow/e2e-metal-ipi-ovn-ipv6 looks suspicious though:

+(utils.sh:421): setup_legacy_release_mirror(): oc adm release mirror --insecure=true -a /opt/dev-scripts/pull_secret.json --from registry.build05.ci.openshift.org/ci-op-pjwdhyyw/release@sha256:1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a --to-release-image virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a --to virthost.ostest.test.metalkube.org:5000/localimages/local-release-image
+(utils.sh:426): setup_legacy_release_mirror(): tee /opt/dev-scripts/registry/ostest-image_mirror-1be093a02bf8b6ad292283f583b867ccc6705cadc3c7808f8ec270e7c854791a.log
Flag --print-mirror-instructions's value 'icsp' has been deprecated. Use 'idms' instead to allow the printing of instructions for ImageDigestSources and ImageDigestMirrorSet.
error: unable to load image-references from release payload: invalid character '-' after top-level value 

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/test-infra repository.

@petr-muller
Copy link
Member

/test e2e-agnostic-ovn-cmd

@wking wking force-pushed the unify-release-extract-cases branch 3 times, most recently from 2cba141 to b2b34df Compare July 17, 2023 18:05
@wking
Copy link
Member Author

wking commented Jul 18, 2023

Still something going on in that metal presubmit:

error: unable to load image-references from release payload: invalid character '{' after top-level value

@wking wking force-pushed the unify-release-extract-cases branch 2 times, most recently from dfb3937 to 05dd9ca Compare July 18, 2023 07:53
De-duplicate the manifest-walking logic that used to be split between
the ExtractManifests and CredentialsRequests branches.  The content
written to disk (or o.Out) still depends on which of those two is set,
but the manifest parsing portion is now shared from a common location.

This also shifts us to using a tar-entry callback when extracting
manifests, where we used to rely on Mappings.  That sets us up for
centralized filtering of which manifests to extract to the directory.

I've also added some logic to avoid writing to the directory when
Directory is the empty string, which allows the mirror command to
continue to consume the full set of manifests in memory without
writing any of them to disk.
@wking wking force-pushed the unify-release-extract-cases branch from 05dd9ca to 29abd12 Compare July 18, 2023 08:27
@wking
Copy link
Member Author

wking commented Jul 18, 2023

Ok, seems like b2b34df -> 29abd12 fixes the mirror bit, with this run logging:

+(utils.sh:421): setup_legacy_release_mirror(): oc adm release mirror --insecure=true -a /opt/dev-scripts/pull_secret.json --from registry.build05.ci.openshift.org/ci-op-0rwb8880/release@sha256:d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6 --to-release-image virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6 --to virthost.ostest.test.metalkube.org:5000/localimages/local-release-image
+(utils.sh:426): setup_legacy_release_mirror(): tee /opt/dev-scripts/registry/ostest-image_mirror-d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6.log
Flag --print-mirror-instructions's value 'icsp' has been deprecated. Use 'idms' instead to allow the printing of instructions for ImageDigestSources and ImageDigestMirrorSet.
warning: An image was retrieved that failed verification: unable to verify sha256:d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6 against keyrings: verifier-public-key-redhat
info: Mirroring 194 images to virthost.ostest.test.metalkube.org:5000/localimages/local-release-image ...
...
info: Mirroring completed in 1m55.06s (173.8MB/s)

Success
Update image:  virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6
Mirror prefix: virthost.ostest.test.metalkube.org:5000/localimages/local-release-image
Mirror prefix: virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:d4bfccd09a9cf6863bffffb5b2b61e7098cde57647d47a90e0fa6c70d4c44af6

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 18, 2023

@wking: all tests passed!

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/test-infra repository. I understand the commands that are listed here.

Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LalatenduMohanty, petr-muller, wking

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

The pull request process is described 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

@LalatenduMohanty
Copy link
Member

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 18, 2023
@openshift-merge-robot openshift-merge-robot merged commit 26815bf into openshift:master Jul 18, 2023
12 checks passed
@wking wking deleted the unify-release-extract-cases branch July 18, 2023 15:18
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants