Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648dbc5
commit 071f66c
Showing
36 changed files
with
2,244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Notes no how to specify paths | ||
Every path specified below is intended to be an absolute path: | ||
- BAD: `my/relative/path` | ||
- GOOD: `/my/nice/absolute/path/to/config.yaml` | ||
- ALSO-GOOD: `/my/nice/absolute/path/to/a/dir` |
1 change: 1 addition & 0 deletions
1
cmd/branchingconfigmanagers/generated-release-gating-jobs/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
generated-release-gating-jobs |
7 changes: 7 additions & 0 deletions
7
cmd/branchingconfigmanagers/generated-release-gating-jobs/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build: | ||
go build ./... | ||
.PHONY: build | ||
|
||
clean: | ||
go clean ./... | ||
.PHONY: clean |
35 changes: 35 additions & 0 deletions
35
cmd/branchingconfigmanagers/generated-release-gating-jobs/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated release gating jobs manager | ||
This manager attempts to automatize step (2.) of "[Few weeks before code freeze](https://docs.google.com/document/d/19kxmzXFnXrbLChZXBfxy68mCYg06j3qT93VF23wepog/edit#heading=h.r9xn02r1cyfn)" phase. | ||
|
||
## Usage | ||
Check [Notes no how to specify paths](../docs/RELEASE-JOBS-COMMON.md#notes-no-how-to-specify-paths) out first. | ||
|
||
The `--lifecycle-config` switch is always mandatory and it has to point to a valid `ocplifecycle.yaml` config file. | ||
|
||
The `--release-repo-path` has to point to the `openshift/release` folder. | ||
When is specified and no others configurations are provided, the manager defaults `--release-gating` dir to `./ci-operator/config/openshift/release` | ||
|
||
The previous path is relative to `--release-repo-path` | ||
|
||
### Example 1 | ||
```sh | ||
OCP_LIFECYCLE_CONFIG_FULLPATH="/full/path/to/ocplifecycle.yaml" | ||
RELEASE_PROJECT_FULLPATH="/full/path/to/release/project" | ||
$ ./generated-release-gating-jobs \ | ||
--lifecycle-config "$OCP_LIFECYCLE_CONFIG_FULLPATH" \ | ||
--release-repo-path "$RELEASE_PROJECT_FULLPATH" | ||
``` | ||
|
||
Alternatively release-gatings jobs path can be overridden: | ||
|
||
### Example 2 | ||
```sh | ||
OCP_LIFECYCLE_CONFIG_FULLPATH="/full/path/to/ocplifecycle.yaml" | ||
RELEASE_GATING_JOBS_DIR_FULLPATH="/full/path/to/release/gating/jobs/dir" | ||
$ ./generated-release-gating-jobs \ | ||
--lifecycle-config "$OCP_LIFECYCLE_CONFIG_FULLPATH" \ | ||
--release-jobs "$RELEASE_GATING_JOBS_DIR_FULLPATH" | ||
``` | ||
|
||
## Makefile | ||
Run `make integration-tests` to launch integration tests. |
158 changes: 158 additions & 0 deletions
158
cmd/branchingconfigmanagers/generated-release-gating-jobs/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"path" | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
utilerrors "k8s.io/apimachinery/pkg/util/errors" | ||
|
||
"github.com/openshift/ci-tools/pkg/api/ocplifecycle" | ||
"github.com/openshift/ci-tools/pkg/branchcuts/bumper" | ||
mgr "github.com/openshift/ci-tools/pkg/branchcuts/config-manager" | ||
cioperatorcfg "github.com/openshift/ci-tools/pkg/config" | ||
) | ||
|
||
const ( | ||
optsParsingErrorExitStatus = 1 | ||
reconcileErrorExitStatus = 2 | ||
releaseJobsPath = "ci-operator/config/openshift/release" | ||
howManyDaysBefore = 14 | ||
lifecycleConfigFilePathDefaultPath = "" | ||
) | ||
|
||
type options struct { | ||
curOCPVersion string | ||
futureOCPVersion string | ||
releaseJobsDir string | ||
releaseRepoDir string | ||
outDir string | ||
lifecycleConfigFilePath string | ||
logLevel int | ||
newIntervalValue int | ||
} | ||
|
||
func (o *options) tryOverrideOCPVersions(curVersion, futureVersion string) { | ||
if o.curOCPVersion == "" { | ||
o.curOCPVersion = curVersion | ||
} | ||
if o.futureOCPVersion == "" { | ||
o.futureOCPVersion = futureVersion | ||
} | ||
} | ||
|
||
func (o *options) adjustPaths() error { | ||
if o.releaseRepoDir != "" { | ||
if !path.IsAbs(o.releaseRepoDir) { | ||
return errors.New("release-repo-path path has to be absolute") | ||
} | ||
|
||
if path.IsAbs(o.releaseJobsDir) { | ||
return errors.New("release-jobs path can't be absolute when release-jobs is specified") | ||
} | ||
|
||
o.releaseJobsDir = path.Join(o.releaseRepoDir, o.releaseJobsDir) | ||
} | ||
return nil | ||
} | ||
|
||
func gatherOptions() (*options, error) { | ||
var errs []error | ||
o := &options{} | ||
flag.StringVar(&o.curOCPVersion, "current-release", "", "Current OCP version") | ||
flag.StringVar(&o.futureOCPVersion, "future-release", "", "Next OCP version") | ||
flag.StringVar(&o.releaseJobsDir, "release-jobs", releaseJobsPath, "Path to release-gating jobs .yaml files") | ||
flag.StringVar(&o.releaseRepoDir, "release-repo-path", "", "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") | ||
flag.IntVar(&o.newIntervalValue, "interval", 168, "New interval to set") | ||
flag.IntVar(&o.logLevel, "log-level", int(logrus.DebugLevel), "Log level") | ||
flag.Parse() | ||
|
||
if _, err := ocplifecycle.ParseMajorMinor(o.curOCPVersion); o.curOCPVersion != "" && err != nil { | ||
errs = append(errs, fmt.Errorf("error parsing current-release %s", o.curOCPVersion)) | ||
} | ||
|
||
if _, err := ocplifecycle.ParseMajorMinor(o.futureOCPVersion); o.futureOCPVersion != "" && err != nil { | ||
errs = append(errs, fmt.Errorf("error parsing future-release %s", o.futureOCPVersion)) | ||
} | ||
|
||
if o.newIntervalValue < 0 { | ||
errs = append(errs, errors.New("error parsing interval: value is not a positive integer")) | ||
} | ||
|
||
if o.lifecycleConfigFilePath == "" { | ||
errs = append(errs, errors.New("lifecycle-config is mandatory")) | ||
} | ||
if !path.IsAbs(o.lifecycleConfigFilePath) { | ||
errs = append(errs, errors.New("lifecycle-config path is not absolute")) | ||
} | ||
|
||
if o.outDir != "" && !path.IsAbs(o.outDir) { | ||
errs = append(errs, errors.New("out path is not absolute")) | ||
} | ||
|
||
return o, utilerrors.NewAggregate(errs) | ||
} | ||
|
||
func main() { | ||
o, err := gatherOptions() | ||
if err != nil { | ||
logrus.WithError(err).Error("failed to gather options") | ||
os.Exit(optsParsingErrorExitStatus) | ||
} | ||
|
||
if err = o.adjustPaths(); err != nil { | ||
logrus.WithError(err).Error("failed to gather options") | ||
os.Exit(optsParsingErrorExitStatus) | ||
} | ||
|
||
logrus.SetLevel(logrus.Level(o.logLevel)) | ||
logrus.Debugf("using options %+v", o) | ||
|
||
recStatus, err := reconcile(time.Now(), o) | ||
switch recStatus { | ||
case mgr.ReconcileOk: | ||
logrus.Info("status reconciled") | ||
default: | ||
logrus.WithError(err).Error("failed to reconcile the status") | ||
os.Exit(reconcileErrorExitStatus) | ||
} | ||
} | ||
|
||
func reconcile(now time.Time, o *options) (mgr.ReconcileStatus, error) { | ||
lifecycleConfig, err := ocplifecycle.LoadConfig(o.lifecycleConfigFilePath) | ||
if err != nil { | ||
return mgr.ReconcileErr, fmt.Errorf("OCP Lifecycle load: %w", err) | ||
} | ||
|
||
ocpLifecycle := ocplifecycle.NewOCPCodeFreezeLifecycle(&lifecycleConfig, now) | ||
|
||
if !ocpLifecycle.IsBeforeCodeFreeze(howManyDaysBefore) { | ||
return mgr.ReconcileSkipped, nil | ||
} | ||
|
||
currentVersion, futureVersion, err := ocpLifecycle.GetOCPVersions() | ||
if err != nil { | ||
return mgr.ReconcileErr, fmt.Errorf("OCP Lifecycle versions: %w", err) | ||
} | ||
|
||
o.tryOverrideOCPVersions(currentVersion.GetVersion(), futureVersion.GetVersion()) | ||
logrus.Debugf("using options %+v", o) | ||
|
||
b := bumper.NewGeneratedReleaseGatingJobsBumper(o.curOCPVersion, o.releaseJobsDir, o.newIntervalValue) | ||
bumped, err := bumper.Bump[*cioperatorcfg.DataWithInfo](b, &bumper.BumpingOptions{ | ||
OutDir: o.outDir, | ||
}) | ||
|
||
if !bumped || err != nil { | ||
return mgr.ReconcileErr, fmt.Errorf("bumper: %w", err) | ||
} | ||
|
||
return mgr.ReconcileOk, nil | ||
} |
1 change: 1 addition & 0 deletions
1
cmd/branchingconfigmanagers/rpm-deps-mirroring-services/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rpm-deps-mirroring-services |
7 changes: 7 additions & 0 deletions
7
cmd/branchingconfigmanagers/rpm-deps-mirroring-services/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build: | ||
go build ./... | ||
.PHONY: build | ||
|
||
clean: | ||
go clean ./... | ||
.PHONY: clean |
35 changes: 35 additions & 0 deletions
35
cmd/branchingconfigmanagers/rpm-deps-mirroring-services/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# RPM dependencies mirroring services | ||
This manager attempts to automatize step (1.) of "[Few weeks before code freeze](https://docs.google.com/document/d/19kxmzXFnXrbLChZXBfxy68mCYg06j3qT93VF23wepog/edit#heading=h.r9xn02r1cyfn)" phase. | ||
|
||
## Usage | ||
Check [Notes no how to specify paths](../docs/RELEASE-JOBS-COMMON.md#notes-no-how-to-specify-paths) out first. | ||
|
||
The `--lifecycle-config` switch is always mandatory and it has to point to a valid `ocplifecycle.yaml` config file. | ||
|
||
The `--release-repo-path` has to point to the `openshift/release` folder. | ||
If not specified, the manager defaults `--mirroring-services` dir to `core-services/release-controller/_repos` | ||
|
||
The previous paths are relative to `--release-repo-path` | ||
|
||
### Example | ||
```sh | ||
OCP_LIFECYCLE_CONFIG_FULLPATH="/full/path/to/ocplifecycle.yaml" | ||
RELEASE_PROJECT_FULLPATH="/full/path/to/release/project" | ||
$ ./generated-release-gating-jobs \ | ||
--lifecycle-config "$OCP_LIFECYCLE_CONFIG_FULLPATH" \ | ||
--release-repo-path "$RELEASE_PROJECT_FULLPATH" | ||
``` | ||
|
||
Alternatively `--mirroring-services` path can be overridden: | ||
|
||
### Example | ||
```sh | ||
OCP_LIFECYCLE_CONFIG_FULLPATH="/full/path/to/ocplifecycle.yaml" | ||
RPM_DEPS_MIRRORING_SERVICES_FULLPATH="/full/path/to/rpm/deps/mirroring/services" | ||
$ ./generated-release-gating-jobs \ | ||
--lifecycle-config "$OCP_LIFECYCLE_CONFIG_FULLPATH" \ | ||
--mirroring-services "$RPM_DEPS_MIRRORING_SERVICES_FULLPATH" | ||
``` | ||
|
||
## Makefile | ||
Run `make integration-tests` to launch integration tests. |
Oops, something went wrong.