Skip to content

OTA-1531: [2/x] cvo: refactor LoadUpdate #1185

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

Conversation

petr-muller
Copy link
Member

@petr-muller petr-muller commented May 6, 2025

Builds on: #1184

Extract loading tasks from loadUpdatePayloadMetadata one layer up to LoadUpdate, which makes more sense as a logical sequence of "loading the update". This also allows simplifying loadUpdatePayloadMetadata signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.

The architecture is either read from release metadata when present (and in that case it must be a string and must be multi) or determined from runtime in all other cases. Refactor loadReleaseFromMetadata so that it only really reads the metadata, and move the "when metadata does not have architecture, read from runtime" logic to loadPayloadMetadata above (the loadReleaseFromMetadata caller). This will allow to reuse the release metadata loading code without involving more logic than necessary.

Rename loadReleaseFromMetadata->loadReleaseMetadata. I believe this is a better name in the context of the full loading code. Release metadata is a subset of the payload metadata, and the LoadUpdate -> loadPayloadMetadata -> loadReleaseMetadata chain makes the method names more cohesive.

The reason for this refactor is that for OTA-1531 I need to isolate the code that loads payload metadata from the code that loads the full payload. This will allow to probe the metadata for release version near the start of CVO executing, so that the version can be used to set up the desired feature gated behavior to enable or disable.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 6, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 6, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

Builds on: #1184

Extract loading tasks from loadUpdatePayloadMetadata one layer up to LoadUpdate, which makes more sense as a logical sequence of "loading the update". This also allows simplifying loadUpdatePayloadMetadata signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.

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.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 6, 2025
Copy link
Contributor

openshift-ci bot commented May 6, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 6, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 6, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

Builds on: #1184

Extract loading tasks from loadUpdatePayloadMetadata one layer up to LoadUpdate, which makes more sense as a logical sequence of "loading the update". This also allows simplifying loadUpdatePayloadMetadata signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.

The reason for this refactor is that for OTA-1531 I need to isolate the code that loads payload metadata from the code that loads the full payload. This will allow to probe the metadata for release version near the start of CVO executing, so that the version can be used to set up the desired feature gated behavior to enable or disable.

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.

1 similar comment
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 6, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

Builds on: #1184

Extract loading tasks from loadUpdatePayloadMetadata one layer up to LoadUpdate, which makes more sense as a logical sequence of "loading the update". This also allows simplifying loadUpdatePayloadMetadata signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.

The reason for this refactor is that for OTA-1531 I need to isolate the code that loads payload metadata from the code that loads the full payload. This will allow to probe the metadata for release version near the start of CVO executing, so that the version can be used to set up the desired feature gated behavior to enable or disable.

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.

@petr-muller
Copy link
Member Author

/test images unit lint

@petr-muller petr-muller force-pushed the ocpbugs-30080-02-payload-metadata-load-refactor branch from db47626 to 4d67ad3 Compare May 6, 2025 16:14
@petr-muller
Copy link
Member Author

/test images unit lint

@petr-muller petr-muller force-pushed the ocpbugs-30080-02-payload-metadata-load-refactor branch from 4d67ad3 to c2a8f5d Compare May 6, 2025 22:33
@petr-muller petr-muller marked this pull request as ready for review May 6, 2025 22:33
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 6, 2025
@petr-muller
Copy link
Member Author

/retest-required

@hongkailiu
Copy link
Member

/cc

@openshift-ci openshift-ci bot requested a review from hongkailiu May 7, 2025 13:14
@petr-muller
Copy link
Member Author

/hold

I'll need to change this a bit more

@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 May 7, 2025
Extract loading tasks from `loadUpdatePayloadMetadata` one layer up to `LoadUpdate`, which makes more sense as a logical sequence of "loading the update". This also allows simplifying `loadUpdatePayloadMetadata` signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.
The architecture is either read from release metadata when present (and in that case it must be a string and must be multi) or determined from runtime in all other cases. Refactor `loadReleaseFromMetadata` so that it only really reads the metadata, and move the "when metadata does not have architecture, read from runtime" logic to `loadPayloadMetadata` above (the `loadReleaseFromMetadata` caller). This will allow to reuse the release metadata loading code without involving more logic than necessary.

This also simplifies `loadReleaseFromMetadata` signature, improving readability.

Also turn some nested conditionals into guard clauses for readability.
…data`

I believe this is a better name in the context of the full loading code. Release metadata is a subset of the payload metadata, and the `LoadUpdate` -> `loadPayloadMetadata` -> `loadReleaseMetadata` chain makes the method names more cohesive.
@petr-muller petr-muller force-pushed the ocpbugs-30080-02-payload-metadata-load-refactor branch from 425b59e to 4fe21f6 Compare May 7, 2025 14:25
@petr-muller
Copy link
Member Author

/hold cancel

I'll need to change this a bit more
Done

@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 May 7, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 7, 2025

@petr-muller: This pull request references OTA-1531 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

Builds on: #1184

Extract loading tasks from loadUpdatePayloadMetadata one layer up to LoadUpdate, which makes more sense as a logical sequence of "loading the update". This also allows simplifying loadUpdatePayloadMetadata signature because the inputs for loading tasks are partially disjoint from the ones needed for loading the metadata.

The architecture is either read from release metadata when present (and in that case it must be a string and must be multi) or determined from runtime in all other cases. Refactor loadReleaseFromMetadata so that it only really reads the metadata, and move the "when metadata does not have architecture, read from runtime" logic to loadPayloadMetadata above (the loadReleaseFromMetadata caller). This will allow to reuse the release metadata loading code without involving more logic than necessary.

Rename loadReleaseFromMetadata->loadReleaseMetadata. I believe this is a better name in the context of the full loading code. Release metadata is a subset of the payload metadata, and the LoadUpdate -> loadPayloadMetadata -> loadReleaseMetadata chain makes the method names more cohesive.

The reason for this refactor is that for OTA-1531 I need to isolate the code that loads payload metadata from the code that loads the full payload. This will allow to probe the metadata for release version near the start of CVO executing, so that the version can be used to set up the desired feature gated behavior to enable or disable.

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.

Comment on lines +143 to +150
klog.V(2).Infof("Loading updatepayload from %q", dir)
if err := ValidateDirectory(dir); err != nil {
return nil, err
}
var (
cvoDir = filepath.Join(dir, CVOManifestDir)
releaseDir = filepath.Join(dir, ReleaseManifestDir)
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved here from loadUpdatePayloadMetadata

if err != nil {
return nil, err
}

tasks := loadPayloadTasks(releaseDir, cvoDir, releaseImage, profile)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved here from loadUpdatePayloadMetadata

arch := string(release.Architecture)
if arch == "" {
arch = runtime.GOARCH
klog.V(2).Infof("Architecture from %s (%s) retrieved from runtime: %q", cincinnatiJSONFile, release.Version, arch)
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved here from loadReleaseFromMetadata

Copy link
Member

Choose a reason for hiding this comment

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

nit: I would move this part right after line 307.
Then I would not need to check if arch is used between 307 and 318.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a good point, I'll move it right after the error check in a followup PR #1188

}

release.Architecture = configv1.ClusterVersionArchitectureMulti
klog.V(2).Infof("Architecture from %s (%s) is multi: %q", cincinnatiJSONFile, release.Version, arch)
Copy link
Member Author

Choose a reason for hiding this comment

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

The "metadata does not have architecture key, lets read runtime" part moved one layer above to loadPayloadMetadata

Otherwise the logic is identical, just was refactored into guard clause sequence.

@petr-muller
Copy link
Member Author

/test e2e-hypershift

@petr-muller
Copy link
Member Author

https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_cluster-version-operator/1185/pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-ovn-upgrade-into-change/1920136871325732864

There is only one failure which is usually unrelated and normally I would override, but let's be sure on PRs that touch CVO in a potentially sensitive way.

/test e2e-agnostic-ovn-upgrade-into-change

: [bz-etcd][invariant] alert/etcdHighCommitDurations should not be at or above

@petr-muller
Copy link
Member Author

/label no-qe

We agreed on testing approach with QE, we'll want to pre-merge the last PR in the series and will rely on CI for the partial PRs

@openshift-ci openshift-ci bot added the no-qe Allows PRs to merge without qe-approved label label May 7, 2025
@petr-muller
Copy link
Member Author

/test ci/prow/e2e-agnostic-operator

Copy link
Contributor

openshift-ci bot commented May 7, 2025

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

/test e2e-agnostic-operator
/test e2e-agnostic-operator-techpreview
/test e2e-agnostic-ovn
/test e2e-agnostic-ovn-upgrade-into-change
/test e2e-agnostic-ovn-upgrade-into-change-techpreview
/test e2e-agnostic-ovn-upgrade-out-of-change
/test e2e-agnostic-ovn-upgrade-out-of-change-techpreview
/test e2e-aws-ovn-techpreview
/test e2e-hypershift
/test e2e-hypershift-conformance
/test gofmt
/test images
/test lint
/test unit
/test verify-deps

The following commands are available to trigger optional jobs:

/test e2e-agnostic-operator-devpreview
/test okd-scos-e2e-aws-ovn
/test okd-scos-images

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

pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-operator
pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-operator-devpreview
pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-ovn
pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-ovn-upgrade-into-change
pull-ci-openshift-cluster-version-operator-main-e2e-agnostic-ovn-upgrade-out-of-change
pull-ci-openshift-cluster-version-operator-main-e2e-aws-ovn-techpreview
pull-ci-openshift-cluster-version-operator-main-e2e-hypershift
pull-ci-openshift-cluster-version-operator-main-e2e-hypershift-conformance
pull-ci-openshift-cluster-version-operator-main-gofmt
pull-ci-openshift-cluster-version-operator-main-images
pull-ci-openshift-cluster-version-operator-main-lint
pull-ci-openshift-cluster-version-operator-main-okd-scos-e2e-aws-ovn
pull-ci-openshift-cluster-version-operator-main-unit
pull-ci-openshift-cluster-version-operator-main-verify-deps

In response to this:

/test ci/prow/e2e-agnostic-operator

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.

@petr-muller
Copy link
Member Author

/test e2e-agnostic-operator

Copy link
Contributor

openshift-ci bot commented May 7, 2025

@petr-muller: 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/okd-scos-e2e-aws-ovn 4fe21f6 link false /test okd-scos-e2e-aws-ovn

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.

Copy link
Member

@hongkailiu hongkailiu left a comment

Choose a reason for hiding this comment

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

/lgtm

Left only a couple of nits.

}, nil
}

type payloadTasks struct {
Copy link
Member

Choose a reason for hiding this comment

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

super nit: Without moving this struct (feels like the code did not change) it would be easier to comparing the change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I just wanted this struct closer to loadPayloadTasks that creates this data

arch := string(release.Architecture)
if arch == "" {
arch = runtime.GOARCH
klog.V(2).Infof("Architecture from %s (%s) retrieved from runtime: %q", cincinnatiJSONFile, release.Version, arch)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would move this part right after line 307.
Then I would not need to check if arch is used between 307 and 318.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2025
Copy link
Contributor

openshift-ci bot commented May 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@openshift-merge-bot openshift-merge-bot bot merged commit 5d71fb4 into openshift:main May 7, 2025
14 of 15 checks passed
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

Distgit: cluster-version-operator
This PR has been included in build cluster-version-operator-container-v4.20.0-202505080014.p0.g5d71fb4.assembly.stream.el9.
All builds following this will include this PR.

@petr-muller petr-muller deleted the ocpbugs-30080-02-payload-metadata-load-refactor branch May 9, 2025 12:36
petr-muller added a commit to petr-muller/cluster-version-operator that referenced this pull request May 9, 2025
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. no-qe Allows PRs to merge without qe-approved label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants