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

Adding a commandline graph pruner #253

Conversation

bradmwilliams
Copy link
Contributor

Adding a couple commandline options to prune, and verify, the release-upgrade-graph. Calling the release-controller like:
./release-controller --release-namespace ocp --job-namespace ci --prune-graph, will fetch all the tags from the release imagestream. Then it finds the tags that are NOT present in either of the TO and FROM upgrade graphs. Then, it generates the union of the 2 lists, and prunes the graph accordingly. Lastly, by default, it will pretty print the resultant graph for verification. Optionally, you can also specify the --print-secret-payload option to print out the base64 output of the compressed graph.

@bradmwilliams
Copy link
Contributor Author

/assign @smarterclayton

@bradmwilliams
Copy link
Contributor Author

/hold This shouldn't be merged until the secret has been pruned and the latest state gets saved.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2021
@smarterclayton
Copy link
Contributor

Squash the code review changes and then this lgtm

@smarterclayton
Copy link
Contributor

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bradmwilliams, smarterclayton

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-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 1, 2021
@openshift-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2021
@bradmwilliams
Copy link
Contributor Author

/unhold

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2021

if confirm {
buf := &bytes.Buffer{}
saveUpgradeGraph(buf, c.graph, secretClient, ns, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you passing a buf into this method here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original logic creates the buffer and then resets it for each iteration of the wait.Until() loop:

// keep the secret up to date
buf := &bytes.Buffer{}
wait.Until(func() {
buf.Reset()
if err := graph.Save(buf); err != nil {
klog.Errorf("Unable to calculate graph state: %v", err)
return
}
secret, err := secretClient.Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
klog.Errorf("Can't read latest secret %s/%s: %v", ns, name, err)
return
}
if secret.Data == nil {
secret.Data = make(map[string][]byte)
}
secret.Data["latest"] = buf.Bytes()
if _, err := secretClient.Update(context.TODO(), secret, metav1.UpdateOptions{}); err != nil {
klog.Errorf("Can't save state to secret %s/%s: %v", ns, name, err)
}
klog.V(2).Infof("Saved upgrade graph state to %s/%s", ns, name)
}, 5*time.Minute, stopCh)

When I refactored the code, I extracted the "save" logic into saveUpgradeGraph() and to preserve the original logic, I passed in the *bytes.Buffer.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2021
@bradmwilliams
Copy link
Contributor Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 5, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 5, 2022
@bradmwilliams
Copy link
Contributor Author

/hold
Need to test with the latest/greatest changes

@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 Jan 5, 2022
@bradmwilliams bradmwilliams force-pushed the upgrade-graph-pruner-latest branch 2 times, most recently from 49463d9 to 684b2f9 Compare January 7, 2022 14:12
cmd/release-controller/prune_graph.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2022
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2022
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2022
Extracting the load/save logic into their own functions

Updating commandline options for pruning graph

Code review changes

Adding items that are in both the To and From lists

Go formatting

Performing prune inside method with defer

Returning error from saveUpgradeGraph()

Post-rebase updates

Small refactoring

Fix klog version

Convert to using set
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 4, 2022
@bradmwilliams
Copy link
Contributor Author

/unhold

@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 Mar 4, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 4, 2022

@bradmwilliams: 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.

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

openshift-ci bot commented Mar 4, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexNPavel, bradmwilliams, smarterclayton

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:
  • OWNERS [AlexNPavel,bradmwilliams,smarterclayton]

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

@openshift-merge-robot openshift-merge-robot merged commit 5e762ba into openshift:master Mar 4, 2022
@bradmwilliams bradmwilliams deleted the upgrade-graph-pruner-latest branch March 4, 2022 18:22
hongkailiu pushed a commit to hongkailiu/release-controller that referenced this pull request Sep 28, 2023
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. 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

6 participants