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

Before branching day: step 1 #2815

Conversation

danilo-gemoli
Copy link
Contributor

@danilo-gemoli danilo-gemoli commented May 13, 2022

This is a tool that tries to automate the first step of phase "Before branching day" .
Check Centralized Release Branching and Config Management V3
/cc @jmguzik @droslean

@openshift-ci openshift-ci bot requested review from droslean and jmguzik May 13, 2022 13:44
@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 13, 2022
Copy link
Member

@droslean droslean left a comment

Choose a reason for hiding this comment

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

Nice, but I don't think that the folder structure should be designed like that. Just put each tool into his own folder in ci-tools/cmd. Also, none of the tools should execute something from an external Makefile since all logic already exists programmatically.

@@ -0,0 +1,11 @@
build-all:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that the Makefile is necessary

- [RPM dependencies mirroring services](cmd/rpm-deps-mirroring-services/README.md)
- [Generated release gating jobs](cmd/generated-release-gating-jobs/README.md)

## HowTo
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this section.

flag.StringVar(&o.releaseJobsDir, "release-jobs", releaseJobsPath, "Path to release-gating jobs .yaml files")
flag.StringVar(&o.releaseProjDir, "release-proj", "", "Path to 'openshift/release/ folder")
flag.StringVar(&o.outDir, "out", "", "Output directory. Default to --release-jobs dir")
flag.StringVar(&o.lifecycleConfigFilePath, "lifecycle-config", lifecycleConfigFilePathDefaultPath, "Path to the lifecycle config file")
Copy link
Member

Choose a reason for hiding this comment

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

since you are doing that, can you generalize this flag so we can bind it in the rest of the tools as well?

}
}

if err = utilerrors.NewAggregate(errs); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err = utilerrors.NewAggregate(errs); err != nil {
if err := utilerrors.NewAggregate(errs); err != nil {

- GOOD: `/my/nice/absolute/path/to/config.yaml`
- ALSO-GOOD: `/my/nice/absolute/path/to/a/dir`

## Exit codes
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that we care about having different kinds of exit codes. Just logging the error is enough.

func gatherOptions() (*options, error) {
var errs []error
o := &options{}
flag.StringVar(&o.curOCPVersion, "cur-ocp-ver", "", "Current OCP version")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
flag.StringVar(&o.curOCPVersion, "cur-ocp-ver", "", "Current OCP version")
flag.StringVar(&o.curOCPVersion, "current-release", "", "Current OCP version")

var errs []error
o := &options{}
flag.StringVar(&o.curOCPVersion, "cur-ocp-ver", "", "Current OCP version")
flag.StringVar(&o.futureOCPVersion, "future-ocp-ver", "", "Next OCP version")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
flag.StringVar(&o.futureOCPVersion, "future-ocp-ver", "", "Next OCP version")
flag.StringVar(&o.futureOCPVersion, "future-release", "", "Next OCP version")

o := &options{}
flag.StringVar(&o.curOCPVersion, "cur-ocp-ver", "", "Current OCP version")
flag.StringVar(&o.futureOCPVersion, "future-ocp-ver", "", "Next OCP version")
flag.StringVar(&o.releaseProjDir, "release-proj", "", "Path to 'openshift/release/ folder")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
flag.StringVar(&o.releaseProjDir, "release-proj", "", "Path to 'openshift/release/ folder")
flag.StringVar(&o.releaseProjDir, "release-repo-path", "", "Path to openshift/release repository folder")

logrus.Debugf("using options %+v", o)

recStatus, err := reconcile(time.Now(), o)
switch recStatus {
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to check different error codes. Just output the error is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So do we only go on iff everything went ok (exitCode == ReconcileOK)?

Copy link
Member

Choose a reason for hiding this comment

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

If you want the program to exit on that specific error, you can use logrus.WIthError(err).Fatal("...."). Fatal will terminate the code with a non-zero return code.

@@ -0,0 +1,127 @@
package bumper
Copy link
Member

Choose a reason for hiding this comment

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

There is no need for the whole package. Please check: https://github.com/openshift/ci-tools/blob/master/pkg/config/load.go#L242

@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch from bdfb19b to b8ba3db Compare May 18, 2022 08:12
@danilo-gemoli danilo-gemoli marked this pull request as draft May 18, 2022 08:13
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch 3 times, most recently from 0b8d666 to 0675b70 Compare May 24, 2022 08:05
@danilo-gemoli danilo-gemoli marked this pull request as ready for review May 24, 2022 08:56
@danilo-gemoli danilo-gemoli marked this pull request as draft May 30, 2022 09:37
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch 4 times, most recently from e8e2aa3 to 043f645 Compare May 30, 2022 15:04
@danilo-gemoli danilo-gemoli marked this pull request as ready for review May 30, 2022 15:23
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch 2 times, most recently from 4c89fa2 to 3b8c1fa Compare May 31, 2022 08:37
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch from 3b8c1fa to 3c281bd Compare June 13, 2022 12:38
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch from 3c281bd to 071f66c Compare July 4, 2022 12:30
@jmguzik
Copy link
Contributor

jmguzik commented Aug 23, 2022

@danilo-gemoli what about this one?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2022
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 22, 2022
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch from 071f66c to a4c4d58 Compare November 23, 2022 14:56
@danilo-gemoli
Copy link
Contributor Author

/retitle Before branching day: step 1
/remove-lifecycle stale

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2022
@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 Nov 23, 2022
@openshift-ci openshift-ci bot changed the title WIP: release-gating jobs mgr: steps 1, 2 Before branching day: step 1 Nov 23, 2022
@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Nov 23, 2022
@danilo-gemoli danilo-gemoli force-pushed the feature/auto-br-cuts-release-jobs branch from a4c4d58 to fb0b806 Compare November 23, 2022 16:17
Copy link
Contributor

@jmguzik jmguzik left a comment

Choose a reason for hiding this comment

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

Some remarks.

### Example
```sh
$ ./generated-release-gating-jobs \
--current-release "4.12" \
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought about it and it actually can stay that way. This tool is supporting only one action so there is absolutely no need for it to parse (outdated) lifecycle file

ini.PrettyFormat = false
ini.PrettyEqual = true

// What follow should have be avoided by using f.SaveTo(path) directly,
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not 100% get the explanation, also not sure if we should have such a detailed explanation here. What would be desired way to handle this issue?

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 library prints an annoying double '\n' at the end of the file. I fixed this little glitch some months ago: go-ini/ini/pull/321 but we are still referencing the old version.

@@ -0,0 +1,110 @@
package bumper
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these bumper files used in the second PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's why I have created this abstraction. It will become more obvious when you will be reviewing the second and third PRs.

@@ -0,0 +1,110 @@
package bumper
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are correct. I know those tools could potentially miss some other sections as well, especially when it comes to handle non-structured text. As long as the field that it is going to be modified is well defined and it has a structure it is quite easy to perform the replacement. In all other cases I simply do not have strategies other than a naive text/regex replacement and that is dangerous because you could end up modifying text that it is not supposed to be modified.

Example:
Suppose you want to replace release-4.13 with release-4.14 using the sed expression s/4\.13/4\.14/g inside the following script:

curl -L https://github.com/openshift-cnv/cnv-ci/tarball/release-4.13 -o /tmp/cnv-ci.tgz
# Do some work here
# ...
# I'm going to do this and that because of a bug since version 4.13
# ...

That would be transformed into:

- curl -L https://github.com/openshift-cnv/cnv-ci/tarball/release-4.13 -o /tmp/cnv-ci.tgz
+ curl -L https://github.com/openshift-cnv/cnv-ci/tarball/release-4.14 -o /tmp/cnv-ci.tgz 
# Do some work here
# ...
- # I'm going to do this and that because of a bug since version 4.13
+ # I'm going to do this and that because of a bug since version 4.14
# ...

While the first replacement is probably good, the second one for sure it is not as we have changed the semantic of the original text.
Of course we could decide to set some rules as "skip comments if it is a bash script" but I have realized you won't never be 100% sure you made the correct decision if we go down this path.
I bet this is a problem that even @petr-muller faced again and again.
I am obviously open to any advises.

Copy link
Member

Choose a reason for hiding this comment

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

TBH I never worried too much about substitutions like this (which likely resulted in some wrong results but we were always on that fine line between process efficiency and correctness). I think the only place where we did sed substitution was bumping relesae payload jobs, and that was a basically a black box incantation that nobody eventually understood after a few bumps :)

That said, I think a reasonable approach is to not have ambition to bump versions in unstructured texts. You could have a contract that some part of the CI system exposes the "bumped" values in e.g. an envvar, and if people's payloads want to be handled by the tooling, they should use the nevvar. If they don't, they won't be bumped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and I agree. You should either follow the "contract" we established beforehand or those files (or at least some of their stanzas/sections/fields/whatever) won't be bumped to the next version.
That's it, unless we don't want to start training a neural network... that won't be 100% accurate either! :)

Copy link
Contributor

@jmguzik jmguzik Nov 25, 2022

Choose a reason for hiding this comment

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

+ # I'm going to do this and that because of a bug since version 4.14

Most of these problems will around curl as I noticed in the past so I would definitely welcome some regexp that is taking care at least of this case.

which likely resulted in some wrong results but we were always on that fine line between process efficiency and correctness

Generally, I would say yes and agree, but on the other hand, as we are not that experienced still, we would like to avoid possible situations when something is not working because we put the accent on efficiency instead of correctness. I also feel now more eyes are watching the process and there is a bigger pressure to do it right.

@danilo-gemoli with that being said, I am ok to merge it as an initial version that could be corrected in the future.

@danilo-gemoli
Copy link
Contributor Author

/retest

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

openshift-ci bot commented Nov 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danilo-gemoli, jmguzik

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 [danilo-gemoli,jmguzik]

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 25, 2022

@danilo-gemoli: 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-merge-robot openshift-merge-robot merged commit 442d4ce into openshift:master Nov 25, 2022
@danilo-gemoli danilo-gemoli deleted the feature/auto-br-cuts-release-jobs branch January 16, 2023 08:59
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