-
Notifications
You must be signed in to change notification settings - Fork 291
branchcuts: add bumping of release gating jobs from sippy config #4854
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ type GeneratedReleaseGatingJobsBumper struct { | |
| getFilesRegexp *regexp.Regexp | ||
| jobsDir string | ||
| newIntervalValue int | ||
| sippyConfigPath string // could be fetched from https://github.com/openshift/sippy/blob/main/config/openshift.yaml | ||
| useSippyConfig bool | ||
| } | ||
|
|
||
| var _ Bumper[*cioperatorcfg.DataWithInfo] = &GeneratedReleaseGatingJobsBumper{} | ||
|
|
@@ -38,14 +40,40 @@ func NewGeneratedReleaseGatingJobsBumper(ocpVer, jobsDir string, newIntervalValu | |
| mmRegexp := fmt.Sprintf("%d\\.%d", mm.Major, mm.Minor) | ||
| getFilesRegexp := regexp.MustCompile(fmt.Sprintf(releaseJobsRegexPatternFormat, mmRegexp)) | ||
| return &GeneratedReleaseGatingJobsBumper{ | ||
| mm, | ||
| getFilesRegexp, | ||
| jobsDir, | ||
| newIntervalValue, | ||
| mm: mm, | ||
| getFilesRegexp: getFilesRegexp, | ||
| jobsDir: jobsDir, | ||
| newIntervalValue: newIntervalValue, | ||
| useSippyConfig: false, | ||
| }, nil | ||
| } | ||
|
|
||
| // NewGeneratedReleaseGatingJobsBumperWithSippy creates a bumper that uses Sippy config to determine which files to bump | ||
| func NewGeneratedReleaseGatingJobsBumperWithSippy(ocpVer, jobsDir, sippyConfigPath string, newIntervalValue int) (*GeneratedReleaseGatingJobsBumper, error) { | ||
| mm, err := ocplifecycle.ParseMajorMinor(ocpVer) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("parse release: %w", err) | ||
| } | ||
| mmRegexp := fmt.Sprintf("%d\\.%d", mm.Major, mm.Minor) | ||
| getFilesRegexp := regexp.MustCompile(fmt.Sprintf(releaseJobsRegexPatternFormat, mmRegexp)) | ||
| return &GeneratedReleaseGatingJobsBumper{ | ||
| mm: mm, | ||
| getFilesRegexp: getFilesRegexp, | ||
| jobsDir: jobsDir, | ||
| newIntervalValue: newIntervalValue, | ||
| sippyConfigPath: sippyConfigPath, | ||
| useSippyConfig: true, | ||
| }, nil | ||
| } | ||
|
|
||
| func (b *GeneratedReleaseGatingJobsBumper) GetFiles() ([]string, error) { | ||
| if b.useSippyConfig { | ||
| return b.getFilesFromSippy() | ||
| } | ||
| return b.getFilesFromRegex() | ||
| } | ||
|
|
||
| func (b *GeneratedReleaseGatingJobsBumper) getFilesFromRegex() ([]string, error) { | ||
| files := make([]string, 0) | ||
| err := filepath.Walk(b.jobsDir, func(path string, info fs.FileInfo, err error) error { | ||
| if b.getFilesRegexp.Match([]byte(path)) { | ||
|
|
@@ -56,6 +84,25 @@ func (b *GeneratedReleaseGatingJobsBumper) GetFiles() ([]string, error) { | |
| return files, err | ||
| } | ||
|
|
||
| func (b *GeneratedReleaseGatingJobsBumper) getFilesFromSippy() ([]string, error) { | ||
| releaseVersion := fmt.Sprintf("%d.%d", b.mm.Major, b.mm.Minor) | ||
| configRootDir := filepath.Dir(filepath.Dir(b.jobsDir)) | ||
|
|
||
| configFiles, err := GetConfigFilesForReleaseFromSippy(b.sippyConfigPath, releaseVersion, configRootDir) | ||
| if err != nil { | ||
| logrus.WithError(err).Warnf("failed to get config files from Sippy for release %s, falling back to regex", releaseVersion) | ||
| return b.getFilesFromRegex() | ||
| } | ||
|
|
||
| if len(configFiles) == 0 { | ||
| logrus.Warnf("no config files found from Sippy for release %s, falling back to regex", releaseVersion) | ||
| return b.getFilesFromRegex() | ||
| } | ||
|
|
||
| logrus.Infof("found %d config files from Sippy for release %s", len(configFiles), releaseVersion) | ||
| return configFiles, nil | ||
| } | ||
|
|
||
| func (b *GeneratedReleaseGatingJobsBumper) Unmarshall(file string) (*cioperatorcfg.DataWithInfo, error) { | ||
| cfgDataByFilename, err := cioperatorcfg.LoadDataByFilename(file) | ||
| if err != nil { | ||
|
|
@@ -79,6 +126,12 @@ func (b *GeneratedReleaseGatingJobsBumper) BumpFilename( | |
| return "", err | ||
| } | ||
| dataWithInfo.Info.Metadata.Variant = newVariant | ||
| newBranch, err := ReplaceWithNextVersion(dataWithInfo.Info.Metadata.Branch, b.mm.Major) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| dataWithInfo.Info.Metadata.Branch = newBranch | ||
|
|
||
| return dataWithInfo.Info.Metadata.Basename(), nil | ||
| } | ||
|
|
||
|
|
@@ -102,10 +155,16 @@ func (b *GeneratedReleaseGatingJobsBumper) BumpContent(dataWithInfo *cioperatorc | |
| return nil, err | ||
| } | ||
|
|
||
| // Bump variant in zz_generated_metadata | ||
| if err := ReplaceWithNextVersionInPlace(&config.Metadata.Variant, major); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Bump branch in zz_generated_metadata (e.g., release-4.21 -> release-4.22) | ||
| if err := ReplaceWithNextVersionInPlace(&config.Metadata.Branch, major); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if config.Tests != nil { | ||
| for i := 0; i < len(config.Tests); i++ { | ||
| if config.Tests[i].Interval != nil { | ||
|
|
@@ -178,6 +237,9 @@ func bumpTests(config *cioperatorapi.ReleaseBuildConfiguration, major int) error | |
| continue | ||
| } | ||
|
|
||
| if err := bumpStepEnvVars(test.MultiStageTestConfiguration.Environment, major); err != nil { | ||
| return err | ||
| } | ||
| if err := bumpTestSteps(test.MultiStageTestConfiguration.Pre, major); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -188,8 +250,10 @@ func bumpTests(config *cioperatorapi.ReleaseBuildConfiguration, major int) error | |
| return err | ||
| } | ||
|
|
||
| if err := ReplaceWithNextVersionInPlace(test.MultiStageTestConfiguration.Workflow, major); err != nil { | ||
| return err | ||
| if test.MultiStageTestConfiguration.Workflow != nil { | ||
| if err := ReplaceWithNextVersionInPlace(test.MultiStageTestConfiguration.Workflow, major); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| config.Tests[i] = test | ||
|
|
@@ -198,6 +262,27 @@ func bumpTests(config *cioperatorapi.ReleaseBuildConfiguration, major int) error | |
| return nil | ||
| } | ||
|
|
||
| func bumpStepEnvVars(env cioperatorapi.TestEnvironment, major int) error { | ||
| if env == nil { | ||
| return nil | ||
| } | ||
|
|
||
| for envKey := range env { | ||
| envValue := env[envKey] | ||
| mm, err := ocplifecycle.ParseMajorMinor(envValue) | ||
| if err != nil { | ||
| continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the logger and
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with this I wanted to check if an env variable is parsable as major.minor then we can work with it, if not, I don't care about it. There is no error, it's just not a openshift version |
||
| } | ||
| if envKey == ocpReleaseEnvVarName || mm.Major == major { | ||
| if err := ReplaceWithNextVersionInPlace(&envValue, major); err != nil { | ||
| return err | ||
| } | ||
| env[envKey] = envValue | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func bumpTestSteps(tests []cioperatorapi.TestStep, major int) error { | ||
| if tests == nil { | ||
| return nil | ||
|
|
@@ -218,7 +303,11 @@ func bumpTestStepEnvVars(multistageTest cioperatorapi.TestStep, major int) error | |
| } | ||
| for i := 0; i < len(multistageTest.Environment); i++ { | ||
| env := multistageTest.Environment[i] | ||
| if env.Name == ocpReleaseEnvVarName { | ||
| mm, err := ocplifecycle.ParseMajorMinor(*env.Default) | ||
| if err != nil { | ||
| continue | ||
| } | ||
| if env.Name == ocpReleaseEnvVarName || mm.Major == major { | ||
| if err := ReplaceWithNextVersionInPlace(env.Default, major); err != nil { | ||
| return err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Potential path resolution issue.
Line 89 computes
configRootDirby going up two directories fromjobsDir. IfjobsDiris/repo/ci-operator/jobs, thenconfigRootDirbecomes/repo. However,GetConfigFilesForReleaseFromSippyandGetConfigFilesFromSippyJobsexpectconfigDirto be the actual config directory (e.g.,/repo/ci-operator/config).Inside
GetConfigFilesFromSippyJobs(sippy.go line 167), it computesjobsRootDir = filepath.Join(filepath.Dir(configDir), "jobs"). IfconfigDiris/repo, this yields/jobsinstead of/repo/ci-operator/jobs.Consider fixing the path:
func (b *GeneratedReleaseGatingJobsBumper) getFilesFromSippy() ([]string, error) { releaseVersion := fmt.Sprintf("%d.%d", b.mm.Major, b.mm.Minor) - configRootDir := filepath.Dir(filepath.Dir(b.jobsDir)) + configRootDir := filepath.Join(filepath.Dir(b.jobsDir), "config") configFiles, err := GetConfigFilesForReleaseFromSippy(b.sippyConfigPath, releaseVersion, configRootDir)🏁 Script executed:
Length of output: 7101
I need to verify the actual implementation in sippy.go to confirm the path resolution issue.
Let me check the actual sippy.go implementation to verify the path handling:
Now I need to examine the actual sippy.go implementation to verify the path logic:
🏁 Script executed:
Length of output: 5211
Path calculation error causes incorrect job directory resolution.
Line 89 computes
configRootDirby going up two directories fromjobsDir, passing the repo root instead of the config directory path. At sippy.go line 167,GetConfigFilesFromSippyJobscomputesjobsRootDir := filepath.Join(filepath.Dir(configDir), "jobs"). WithconfigDirset to the repo root (e.g.,/tmp/xyz), this yields/tmp/jobsinstead of the correct/tmp/xyz/ci-operator/jobs, causing job metadata lookups to fail.Fix the path derivation:
func (b *GeneratedReleaseGatingJobsBumper) getFilesFromSippy() ([]string, error) { releaseVersion := fmt.Sprintf("%d.%d", b.mm.Major, b.mm.Minor) - configRootDir := filepath.Dir(filepath.Dir(b.jobsDir)) + configRootDir := filepath.Join(filepath.Dir(b.jobsDir), "config") configFiles, err := GetConfigFilesForReleaseFromSippy(b.sippyConfigPath, releaseVersion, configRootDir)📝 Committable suggestion
🤖 Prompt for AI Agents