Skip to content

Commit 8c0ca0e

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/onsi/ginkgo/v2-2.11.0
2 parents fc0e3e8 + 88cd476 commit 8c0ca0e

File tree

16 files changed

+304
-53
lines changed

16 files changed

+304
-53
lines changed

.github/workflows/tag-and-build.yml

Lines changed: 100 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,69 @@ on:
77
version:
88
description: 'Tag to be used for operator image'
99
required: true
10-
default: '0.0.0-dev'
10+
default: 'v0.0.0-dev'
1111
replaces:
1212
description: 'The previous semantic version that this tag replaces.'
1313
required: true
14-
default: '0.0.0-dev'
14+
default: 'v0.0.0-dev'
15+
mcad-version:
16+
description: 'Published version of multi-cluster-app-dispatcher'
17+
required: true
18+
default: 'v0.0.0-dev'
19+
codeflare-sdk-version:
20+
description: 'Published version of CodeFlare-SDK'
21+
required: true
22+
default: 'v0.0.0-dev'
23+
instascale-version:
24+
description: 'Published version of InstaScale'
25+
required: true
26+
default: 'v0.0.0-dev'
27+
is-stable:
28+
description: 'Select if the built image should be tagged as stable'
29+
required: true
30+
type: boolean
31+
quay-organization:
32+
description: 'Quay organization used to push the built images to'
33+
required: true
34+
default: 'project-codeflare'
35+
community-operators-prod-fork-organization:
36+
description: 'Owner of forked community-operators-prod repository used to push bundle files to'
37+
required: true
38+
default: 'project-codeflare'
39+
community-operators-prod-organization:
40+
description: 'Owner of target community-operators-prod repository used to open a PR against'
41+
required: true
42+
default: 'redhat-openshift-ecosystem'
1543

1644
jobs:
1745
push:
1846
runs-on: ubuntu-latest
47+
48+
# Permission required to create a release
49+
permissions:
50+
contents: write
51+
1952
steps:
2053
- uses: actions/checkout@v3
2154

55+
- name: Verify that release doesn't exist yet
56+
shell: bash {0}
57+
run: |
58+
gh release view ${{ github.event.inputs.version }}
59+
status=$?
60+
if [[ $status -eq 0 ]]; then
61+
echo "Release ${{ github.event.inputs.version }} already exists."
62+
exit 1
63+
fi
64+
env:
65+
GITHUB_TOKEN: ${{ github.TOKEN }}
66+
2267
- name: Activate cache
2368
uses: actions/cache@v3
2469
with:
2570
path: /cache
2671
key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }}
2772

28-
- name: Create tag
29-
uses: actions/github-script@v6
30-
with:
31-
script: |
32-
github.rest.git.createRef({
33-
owner: context.repo.owner,
34-
repo: context.repo.repo,
35-
ref: 'refs/tags/${{ github.event.inputs.version }}',
36-
sha: context.sha
37-
})
38-
3973
- name: Install operator-sdk
4074
run: make install-operator-sdk
4175

@@ -46,18 +80,62 @@ jobs:
4680
password: ${{ secrets.QUAY_TOKEN }}
4781
registry: quay.io
4882

49-
- name: Image Build
83+
- name: Image Build and Push
5084
run: |
5185
make build
52-
make bundle
53-
make image-build -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG}
54-
podman tag quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} quay.io/project-codeflare/codeflare-operator:latest
86+
make image-build -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }}
87+
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }}
88+
89+
- name: Image Push as stable tag
90+
if: ${{ inputs.is-stable }}
91+
run: |
92+
podman tag quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }} quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:stable
93+
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:stable
94+
95+
- name: Build bundle and create PR in OpenShift community operators repository
96+
run: |
97+
git config --global user.email "[email protected]"
98+
git config --global user.name "CodeFlare CI"
99+
make openshift-community-operator-release
55100
env:
56-
SOURCE_TAG: ${{ github.event.inputs.version }}
101+
VERSION: ${{ github.event.inputs.version }}
102+
PREVIOUS_VERSION: ${{ github.event.inputs.replaces }}
103+
INSTASCALE_VERSION: ${{ github.event.inputs.instascale-version }}
104+
MCAD_VERSION: ${{ github.event.inputs.mcad-version }}
105+
GH_TOKEN: ${{ secrets.GH_PAT }}
106+
IMAGE_ORG_BASE: quay.io/${{ github.event.inputs.quay-organization }}
107+
OPERATORS_REPO_FORK_ORG: ${{ github.event.inputs.community-operators-prod-fork-organization }}
108+
OPERATORS_REPO_ORG: ${{ github.event.inputs.community-operators-prod-organization }}
109+
110+
- name: Adjust Compatibility Matrix in readme
111+
run: |
112+
sed -i -E "s/(.*CodeFlare Operator.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.version }}\2/" README.md
113+
sed -i -E "s/(.*Multi-Cluster App Dispatcher.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.mcad-version }}\2/" README.md
114+
sed -i -E "s/(.*CodeFlare-SDK.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.codeflare-sdk-version }}\2/" README.md
115+
sed -i -E "s/(.*InstaScale.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" README.md
116+
117+
- name: Adjust MCAD and InstaScale dependencies in the code
118+
run: |
119+
sed -i -E "s/(.*MCAD_VERSION \?= )v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.mcad-version }}\2/" Makefile
120+
sed -i -E "s/(.*INSTASCALE_VERSION \?= )v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" Makefile
121+
sed -i -E "s/(.*instascale-controller:)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" controllers/testdata/instascale_test_results/case_1/deployment.yaml
122+
sed -i -E "s/(.*instascale-controller:)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" controllers/testdata/instascale_test_results/case_2/deployment.yaml
123+
124+
- name: Commit readme changes back to repository
125+
uses: stefanzweifel/git-auto-commit-action@v4
126+
with:
127+
commit_message: Update dependency versions for release ${{ github.event.inputs.version }}
128+
file_pattern: 'README.md controllers/defaults.go *.yaml *.tmpl Makefile'
57129

58-
- name: Image Push
130+
- name: Creates a release in GitHub
59131
run: |
60-
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG}
61-
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:latest
132+
gh release create ${{ github.event.inputs.version }} --target ${{ github.ref }} --generate-notes
133+
# Edit notes to add there compatibility matrix
134+
sed --null-data -E "s/(.*<\!-- Compatibility Matrix start -->)(.*)(<\!-- Compatibility Matrix end -->.*)/\2/" README.md > release-notes.md
135+
echo "" >> release-notes.md
136+
echo "$(gh release view --json body --jq .body)" >> release-notes.md
137+
gh release edit ${{ github.event.inputs.version }} --notes-file release-notes.md
138+
rm release-notes.md
62139
env:
63-
SOURCE_TAG: ${{ github.event.inputs.version }}
140+
GITHUB_TOKEN: ${{ github.TOKEN }}
141+
shell: bash

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For building and pushing a new version of the bundled operator image:
4444
- `make bundle-push -e IMAGE_TAG_BASE=<image-repo/image-name> VERSION=<new semver> PREVIOUS_VERSION=<semver to replace>`
4545

4646
To create a new openshift-community-operator-release:
47-
- `make openshift-community-operator-release -e IMAGE_TAG_BASE=<image-repo/image-name> VERSION=<new semver> PREVIOUS_VERSION=<semver to replace>`
47+
- `make openshift-community-operator-release -e IMAGE_TAG_BASE=<image-repo/image-name> VERSION=<new semver> PREVIOUS_VERSION=<semver to replace> GH_TOKEN=<GitHub token for pushing bundle content to forked repository>`
4848

4949
## Testing
5050
The CodeFlare Operator currently has unit tests and pre-commit checks

Makefile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# VERSION defines the project version for the bundle.
22
# Update this value when you upgrade the version of your project.
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
4-
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
5-
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
4+
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=v0.0.2)
5+
# - use environment variables to overwrite this value (e.g export VERSION=v0.0.2)
66
# best if we could detect this. If we cannot, we need to document it somewhere.
77
# then we can add a patch in the `PHONY: bundle`
8+
# BUNDLE_VERSION is declared as bundle versioning doesn't use semver
89

9-
PREVIOUS_VERSION ?= 0.0.0-dev
10-
VERSION ?= 0.0.0-dev
10+
PREVIOUS_VERSION ?= v0.0.0-dev
11+
VERSION ?= v0.0.0-dev
12+
BUNDLE_VERSION ?= $(VERSION:v%=%)
1113

1214
# INSTASCALE_VERSION defines the default version of the InstaScale controller
1315
INSTASCALE_VERSION ?= v0.0.4
@@ -19,6 +21,11 @@ MCAD_REF ?= release-${MCAD_VERSION}
1921
MCAD_REPO ?= github.com/project-codeflare/multi-cluster-app-dispatcher
2022
MCAD_CRD ?= ${MCAD_REPO}/config/crd?ref=${MCAD_REF}
2123

24+
# OPERATORS_REPO_ORG points to GitHub repository organization where bundle PR is opened against
25+
# OPERATORS_REPO_FORK_ORG points to GitHub repository fork organization where bundle build is pushed to
26+
OPERATORS_REPO_ORG ?= redhat-openshift-ecosystem
27+
OPERATORS_REPO_FORK_ORG ?= project-codeflare
28+
2229
# CHANNELS define the bundle channels used in the bundle.
2330
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
2431
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -48,15 +55,18 @@ IMAGE_ORG_BASE ?= quay.io/project-codeflare
4855
# codeflare.dev/codeflare-operator-bundle:$VERSION and codeflare.dev/codeflare-operator-catalog:$VERSION.
4956
IMAGE_TAG_BASE ?= $(IMAGE_ORG_BASE)/codeflare-operator
5057

58+
# MCAD_IMAGE defines the default container image for the MCAD controller
59+
MCAD_IMAGE ?= $(IMAGE_ORG_BASE)/mcad-controller:$(MCAD_REF)
60+
5161
# INSTASCALE_IMAGE defines the default container image for the InstaScale controller
5262
INSTASCALE_IMAGE ?= $(IMAGE_ORG_BASE)/instascale-controller:$(INSTASCALE_VERSION)
5363

5464
# BUNDLE_IMG defines the image:tag used for the bundle.
5565
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
56-
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
66+
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)
5767

5868
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
59-
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
69+
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS)
6070

6171
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
6272
# You can enable this value if you would like to use SHA Based Digests
@@ -67,7 +77,7 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
6777
endif
6878

6979
# Image URL to use all building/pushing image targets
70-
IMG ?= ${IMAGE_TAG_BASE}:v${VERSION}
80+
IMG ?= ${IMAGE_TAG_BASE}:${VERSION}
7181
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
7282
ENVTEST_K8S_VERSION = 1.24.2
7383

@@ -117,6 +127,7 @@ defaults:
117127
@echo "// ***********************" >> $(DEFAULTS_FILE)
118128
@echo "" >> $(DEFAULTS_FILE)
119129
@echo "const (" >> $(DEFAULTS_FILE)
130+
@echo " MCADImage = \"$(MCAD_IMAGE)\"" >> $(DEFAULTS_FILE)
120131
@echo " InstaScaleImage = \"$(INSTASCALE_IMAGE)\"" >> $(DEFAULTS_FILE)
121132
@echo "" >> $(DEFAULTS_FILE)
122133
@echo ")" >> $(DEFAULTS_FILE)
@@ -308,7 +319,7 @@ bundle: defaults manifests kustomize install-operator-sdk ## Generate bundle man
308319
$(KUSTOMIZE) fn run config/crd/mcad --image gcr.io/kpt-fn/apply-setters:v0.2.0 -- MCAD_CRD=$(MCAD_CRD)
309320
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
310321
cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/metadata/annotations/containerImage", "value": "$(IMG)" }]' --kind ClusterServiceVersion
311-
cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/spec/replaces", "value": "codeflare-operator.v$(PREVIOUS_VERSION)" }]' --kind ClusterServiceVersion
322+
cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/spec/replaces", "value": "codeflare-operator.$(PREVIOUS_VERSION)" }]' --kind ClusterServiceVersion
312323
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
313324
$(MAKE) validate-bundle
314325
git restore config/*
@@ -321,13 +332,13 @@ bundle-build: bundle ## Build the bundle image.
321332
bundle-push: ## Push the bundle image.
322333
$(MAKE) image-push IMG=$(BUNDLE_IMG)
323334

324-
.PHONY: openshift-community-operator-releases
335+
.PHONY: openshift-community-operator-release
325336
openshift-community-operator-release: install-gh-cli bundle ## build bundle and create PR in OpenShift community operators repository
326-
gh repo clone git@github.com:project-codeflare/community-operators-prod.git
327-
cd community-operators-prod && git pull upstream main && git push origin main
328-
cp -r bundle community-operators-prod/operators/codeflare-operator/$(VERSION)
329-
cd community-operators-prod && git checkout -b codeflare-release-$(VERSION) && git add operators/codeflare-operator/$(VERSION)/* && git commit -s -m "add bundle manifests codeflare version $(VERSION)" && git push origin codeflare-release-$(VERSION)
330-
gh pr create --repo redhat-openshift-ecosystem/community-operators-prod --title "CodeFlare $(VERSION)" --body "New release of codeflare operator" --head project-codeflare:codeflare-release-$(VERSION) --base main
337+
git clone https://$(GH_TOKEN)@github.com/$(OPERATORS_REPO_FORK_ORG)/community-operators-prod.git
338+
cd community-operators-prod && git remote add upstream https://github.com/$(OPERATORS_REPO_ORG)/community-operators-prod.git && git pull upstream main && git push origin main
339+
cp -r bundle community-operators-prod/operators/codeflare-operator/$(BUNDLE_VERSION)
340+
cd community-operators-prod && git checkout -b codeflare-release-$(BUNDLE_VERSION) && git add operators/codeflare-operator/$(BUNDLE_VERSION)/* && git commit -m "add bundle manifests codeflare version $(BUNDLE_VERSION)" && git push origin codeflare-release-$(BUNDLE_VERSION)
341+
gh pr create --repo $(OPERATORS_REPO_FORK_ORG)/community-operators-prod --title "CodeFlare $(BUNDLE_VERSION)" --body "New release of codeflare operator" --head $(OPERATORS_REPO_ORG):codeflare-release-$(BUNDLE_VERSION) --base main
331342
rm -rf community-operators-prod
332343

333344
.PHONY: opm
@@ -352,7 +363,7 @@ endif
352363
BUNDLE_IMGS ?= $(BUNDLE_IMG)
353364

354365
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
355-
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
366+
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(VERSION)
356367

357368
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
358369
ifneq ($(origin CATALOG_BASE_IMG), undefined)

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# codeflare-operator
22
Operator for installation and lifecycle management of CodeFlare distributed workload stack, starting with MCAD and InstaScale
33

4+
<!-- Don't delete these comments, they are used to generate Compatibility Matrix table for release automation -->
5+
<!-- Compatibility Matrix start -->
46
CodeFlare Stack Compatibility Matrix
57

68
| Component | Version |
@@ -10,3 +12,26 @@ CodeFlare Stack Compatibility Matrix
1012
| CodeFlare-SDK | v0.4.4 |
1113
| InstaScale | v0.0.4 |
1214
| KubeRay | v0.5.0 |
15+
<!-- Compatibility Matrix end -->
16+
17+
## Release process
18+
19+
Prerequisite:
20+
- Build and release [MCAD](https://github.com/project-codeflare/multi-cluster-app-dispatcher)
21+
- Build and release [InstaScale](https://github.com/project-codeflare/instascale)
22+
- Build and release [CodeFlare-SDK](https://github.com/project-codeflare/codeflare-sdk)
23+
24+
Release steps:
25+
1. Invoke [tag-and-build.yml](https://github.com/project-codeflare/codeflare-operator/actions/workflows/tag-and-build.yml) GitHub action, this action will create a repository tag, build and push operator image.
26+
27+
2. Check result of [tag-and-build.yml](https://github.com/project-codeflare/codeflare-operator/actions/workflows/tag-and-build.yml) GitHub action, it should pass.
28+
29+
3. Verify that compatibility matrix in [README](https://github.com/project-codeflare/codeflare-operator/blob/main/README.md) was properly updated.
30+
31+
4. Verify that opened pull request to [OpenShift community operators repository](https://github.com/redhat-openshift-ecosystem/community-operators-prod) has proper content.
32+
33+
5. Once PR is merged, update component stable tags to point at the latest image release.
34+
35+
6. Announce the new release in slack and mail lists, if any.
36+
37+
7. Update the Distributed Workloads component in ODH (also copy/update the compatibility matrix).

api/codeflare/v1alpha1/mcad_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ type MCADSpec struct {
5353
// ControllerResources defines the cpu and memory resource requirements for the MCAD Controller
5454
// +kubebuilder:default={}
5555
ControllerResources v1.ResourceRequirements `json:"controllerResources,omitempty" protobuf:"bytes,8,opt"`
56+
57+
// The container image for the MCAD controller deployment.
58+
// If specified, the provided container image must be compatible with the running CodeFlare operator.
59+
// Using an incompatible, or unrelated container image, will result in an undefined behavior.
60+
// A CodeFlare operator upgrade will not upgrade the MCAD controller, that'll keep running this
61+
// specified container image.
62+
// If not specified, the latest version compatible with the running CodeFlare operator is used.
63+
// A CodeFlare operator upgrade may upgrade the MCAD controller to a newer container image.
64+
//
65+
// +optional
66+
ControllerImage string `json:"controllerImage,omitempty"`
5667
}
5768

5869
// MCADStatus defines the observed state of MCAD

config/crd/bases/codeflare.codeflare.dev_mcads.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ spec:
3939
description: AgentConfigs determine paths to agent config file:deploymentName
4040
separated by commas(,).
4141
type: string
42+
controllerImage:
43+
description: The container image for the MCAD controller deployment.
44+
If specified, the provided container image must be compatible with
45+
the running CodeFlare operator. Using an incompatible, or unrelated
46+
container image, will result in an undefined behavior. A CodeFlare
47+
operator upgrade will not upgrade the MCAD controller, that'll keep
48+
running this specified container image. If not specified, the latest
49+
version compatible with the running CodeFlare operator is used.
50+
A CodeFlare operator upgrade may upgrade the MCAD controller to
51+
a newer container image.
52+
type: string
4253
controllerResources:
4354
description: ControllerResources defines the cpu and memory resource
4455
requirements for the MCAD Controller

config/internal/instascale/clusterrole.yaml.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ rules:
2121
- delete
2222
- patch
2323

24+
- apiGroups:
25+
- ""
26+
resourceNames:
27+
- instascale-ocm-secret
28+
resources:
29+
- secrets
30+
verbs:
31+
- get
32+
33+
- apiGroups:
34+
- config.openshift.io
35+
resources:
36+
- clusterversions
37+
verbs:
38+
- get
39+
- list
40+
2441
- apiGroups:
2542
- apps
2643
resources:

config/internal/instascale/deployment.yaml.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,15 @@ spec:
2121
image: {{.ControllerImage}}
2222
name: instascale
2323
resources: {{.ControllerResources}}
24+
livenessProbe:
25+
httpGet:
26+
path: /healthz
27+
port: 8081
28+
periodSeconds: 5
29+
timeoutSeconds: 5
30+
readinessProbe:
31+
httpGet:
32+
path: /readyz
33+
port: 8081
34+
periodSeconds: 10
2435
serviceAccountName: instascale-{{.Name}}-sa

0 commit comments

Comments
 (0)