Skip to content

Add support for RHEL 9 base images#790

Merged
openshift-merge-bot[bot] merged 9 commits intoopenshift-knative:mainfrom
dsimansk:pr/add-rhel-9-generator
Oct 7, 2025
Merged

Add support for RHEL 9 base images#790
openshift-merge-bot[bot] merged 9 commits intoopenshift-knative:mainfrom
dsimansk:pr/add-rhel-9-generator

Conversation

@dsimansk
Copy link
Copy Markdown
Contributor

@dsimansk dsimansk commented Oct 3, 2025

Comment thread pkg/dockerfilegen/generator.go Outdated
Comment thread pkg/dockerfilegen/generator.go Outdated
Comment thread pkg/dockerfilegen/generator.go Outdated
}
} else {
// version before 1.37+
if metadata.Project.Version == "1.36.1" || metadata.Project.Version == "1.35.1" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can use just the safer side if we do a patch release 1.36.2 or newer

minor, _ := strconv.Atoi(strings.Split(metadata.Project.Version, ".")[1]) if minor <= 36 { rhelVersion = "rhel-8" } else { rhelVersion = "rhel-9" }

Copy link
Copy Markdown
Collaborator

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Thanks for checking on this @dsimansk
I left a few comments

}

rhelVersion := "rhel-9"
if metadata.Project.Tag != "" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we could also add the supposed RHEL version in the project.yaml file (maybe also easier for a potential RHEL 10 switch). In case the field would be empty (like in older SO versions), we could default to RHEL 8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could also be helpful on parts like

// use rhel suffix for OCP version >= 4.15
soVersion := semver.New(metadata.Project.Version)
rhelVersion, err := rhel.ForSOVersion(soVersion)
if err != nil {
return "", fmt.Errorf("could not determine rhel version: %v", err)
}
return fmt.Sprintf("oc.rhel%s", rhelVersion), nil
🙈

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, it seemed quicker to hard code a few hacks in the current generator. But for the future and maintainability we should revisit it.

Comment thread pkg/dockerfilegen/generator.go Outdated
@dsimansk
Copy link
Copy Markdown
Contributor Author

dsimansk commented Oct 7, 2025

@Kaustubh-pande @creydr I've added disk free up commands to template and CI action. It should be good for review now.

Comment thread .github/workflows/release-generate-ci.yaml
@dsimansk dsimansk force-pushed the pr/add-rhel-9-generator branch 2 times, most recently from 6a3253f to 87a26e6 Compare October 7, 2025 08:30
@dsimansk dsimansk force-pushed the pr/add-rhel-9-generator branch from 87a26e6 to f416cd3 Compare October 7, 2025 08:43
@Kaustubh-pande
Copy link
Copy Markdown
Collaborator

/lgtm
/approve

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Oct 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, Kaustubh-pande

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 openshift-ci Bot added the approved label Oct 7, 2025
@openshift-merge-bot openshift-merge-bot Bot merged commit 3642031 into openshift-knative:main Oct 7, 2025
4 checks passed
@simkam
Copy link
Copy Markdown
Contributor

simkam commented Oct 7, 2025

with this I get error

serverless-operator$ make generated-files
GOFLAGS='' go install github.com/openshift-knative/hack/cmd/sobranch@latest
GOFLAGS='' go install -tags="exclude_graphdriver_btrfs containers_image_openpgp" github.com/containers/skopeo/cmd/skopeo@v1.17.0
GOFLAGS='' go install github.com/openshift-knative/hack/cmd/generate@latest
GOFLAGS='' go install github.com/openshift-knative/hack/cmd/sorhel@latest
GOFLAGS='' go install github.com/sigstore/cosign/cmd/cosign@latest
GOFLAGS='' go install github.com/operator-framework/operator-registry/cmd/opm@v1.47.0
GOFLAGS='' go install oras.land/oras/cmd/oras@v1.2.0
GOFLAGS='' go install github.com/openshift-knative/hack/cmd/generate@latest
/home/msimka/go/bin/generate \
        --generators dockerfile \
        --includes knative-operator \
        --includes openshift-knative-operator \
        --includes serving/ingress \
        --includes serving/metadata-webhook \
        --project-file olm-catalog/serverless-operator/project.yaml \
        --output /tmp/serverless-operator-generator/
2025/10/07 16:51:44 Main package path: serving/metadata-webhook/cmd/webhook
2025/10/07 16:51:44 Main package path: knative-operator/cmd/knative-operator
2025/10/07 16:51:44 Main package path: openshift-knative-operator/cmd/openshift-knative-operator
2025/10/07 16:51:44 Main package path: serving/ingress/cmd/ingress
2025/10/07 16:51:44 Dockerfile written: /tmp/serverless-operator-generator/ci-operator/build-image/Dockerfile
2025/10/07 16:51:44 Dockerfile written: /tmp/serverless-operator-generator/ci-operator/source-image/Dockerfile
2025/10/07 16:51:44 🔥 Error: bad template: Parsing failed: template: pattern matches no files: `dockerfile-templates/rhel-9/*.tmpl`

 - bad template

 - template: pattern matches no files: `dockerfile-templates/rhel-9/*.tmpl`
github.com/openshift-knative/hack/pkg/dockerfilegen.generateDockerfile
        /home/msimka/go/pkg/mod/github.com/openshift-knative/hack@v0.0.0-20251007121522-3642031d1093/pkg/dockerfilegen/generator.go:303
github.com/openshift-knative/hack/pkg/dockerfilegen.GenerateDockerfiles
        /home/msimka/go/pkg/mod/github.com/openshift-knative/hack@v0.0.0-20251007121522-3642031d1093/pkg/dockerfilegen/generator.go:137
main.GenerateMain
        /home/msimka/go/pkg/mod/github.com/openshift-knative/hack@v0.0.0-20251007121522-3642031d1093/cmd/generate/generate.go:33
main.main
        /home/msimka/go/pkg/mod/github.com/openshift-knative/hack@v0.0.0-20251007121522-3642031d1093/cmd/generate/generate.go:13
runtime.main
        /usr/lib/go-1.24/src/runtime/proc.go:283
runtime.goexit
        /usr/lib/go-1.24/src/runtime/asm_amd64.s:1700
make: *** [Makefile:345: generate-dockerfiles] Error 1

I'm golang newbie but shouldn't rhel-9 templates be embedded in https://github.com/openshift-knative/hack/blob/main/pkg/dockerfilegen/templates.go ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants