Skip to content

Commit bf6f286

Browse files
adwk67razvan
andauthored
fix: changes made while testing non-custom scc (#86)
* fix: changes made while testing non-custom scc * fix(build-bundles.sh): use two channels stable and <major>.<minor> * fix(build-manifests.py): add stable to the list of channels * fix(build-manifests.sh): channels * feat(csv): add olm.skipRange * added not about repo branch * fix(annotations.yaml): use the same name as the csv * Revert "fix(annotations.yaml): use the same name as the csv" This reverts commit 07e23f5. --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent 2ec7aa9 commit bf6f286

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed

olm/build-bundles.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
# - There is a clone of the openshift-certified-operators repository in the folder passed as -c argument.
1313
# This is the same as the build-manifests.sh script.
14+
# Ensure the openshift-certified-operators repo is located on the correct branch (this is not supplied as an arguments).
1415
#
1516
# - The operator manifests for the given version have been generated with the build-manifests.sh script
1617
# and are available in that repository under operators/<operator>/version/manifests.
@@ -77,7 +78,7 @@ bundle-clean() {
7778
}
7879

7980
build-bundle() {
80-
opm alpha bundle generate --directory manifests --package "${OPERATOR}-package" --output-dir bundle --channels stable --default stable
81+
opm alpha bundle generate --directory manifests --package "${OPERATOR}-package" --output-dir bundle --channels "stable,$CHANNEL" --default "$CHANNEL"
8182
cp metadata/*.yaml bundle/metadata/
8283
docker build -t "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" -f bundle.Dockerfile .
8384
docker push "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
@@ -104,18 +105,25 @@ catalog() {
104105

105106
echo "Initiating package: ${OPERATOR}"
106107
opm init "stackable-${OPERATOR}-operator" \
107-
--default-channel=stable \
108+
--default-channel="$CHANNEL" \
108109
--output yaml >"catalog/stackable-${OPERATOR}-operator.yaml"
109110
##--description="TODO: add description here" \
110111

111112
echo "Add operator to package: ${OPERATOR}"
112113
{
114+
echo "---"
115+
echo "schema: olm.channel"
116+
echo "package: stackable-${OPERATOR}-operator"
117+
echo "name: \"$CHANNEL\""
118+
echo "entries:"
119+
echo "- name: ${OPERATOR}-operator.v${VERSION}"
113120
echo "---"
114121
echo "schema: olm.channel"
115122
echo "package: stackable-${OPERATOR}-operator"
116123
echo "name: stable"
117124
echo "entries:"
118125
echo "- name: ${OPERATOR}-operator.v${VERSION}"
126+
119127
} >>"catalog/stackable-${OPERATOR}-operator.yaml"
120128
echo "Render operator: ${OPERATOR}"
121129
opm render "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" --output=yaml >>"catalog/stackable-${OPERATOR}-operator.yaml"
@@ -152,7 +160,7 @@ catalog() {
152160
echo "metadata:"
153161
echo " name: stackable-${OPERATOR}-subscription"
154162
echo "spec:"
155-
echo " channel: stable"
163+
echo " channel: '$CHANNEL'"
156164
echo " name: stackable-${OPERATOR}-operator" # this is the package name NOT the operator-name
157165
echo " source: stackable-${OPERATOR}-catalog"
158166
echo " sourceNamespace: stackable-operators"
@@ -194,6 +202,8 @@ main() {
194202
exit 1
195203
fi
196204

205+
CHANNEL="$(echo "$VERSION"|sed 's/\.[^.]*$//')"
206+
197207
if [ "$OPERATOR" == "spark-k8s" ]; then
198208
echo "Renaming operator from spark-k8s to spark"
199209
OPERATOR="spark"
@@ -206,10 +216,10 @@ main() {
206216
bundle-clean
207217
build-bundle
208218

209-
#catalog-clean
210-
#catalog
219+
catalog-clean
220+
catalog
211221

212-
#deploy
222+
deploy
213223
}
214224

215225
main "$@"

olm/build-manifests.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
165165
f"Certification repository path not found: {args.repo_certified_operators} or it's not a certified operator repository"
166166
)
167167

168-
### Set bundle channel
168+
### Set bundle default channel
169169
if not args.channel:
170170
if args.release == "0.0.0-dev":
171171
args.channel = "alpha"
@@ -333,11 +333,14 @@ def write_manifests(args: argparse.Namespace, manifests: list[dict]) -> None:
333333
)
334334
# Only the product cluster role and the product configmap are dumped as individual files
335335
# The other objects are embedded in the CSV. These are:
336-
# - the operator cluster role
336+
# - the operator cluster role (N.B. some products have more than one cluster role e.g. HDFS)
337337
# - the operator deployment
338338
elif (
339339
m["kind"] == "ClusterRole"
340-
and m["metadata"]["name"] == f"{args.product}-clusterrole"
340+
and (
341+
m["metadata"]["name"] == f"{args.product}-clusterrole"
342+
or m["metadata"]["name"] == f"{args.product}-clusterrole-nodes"
343+
)
341344
):
342345
dest_file = (
343346
args.dest_dir / "manifests" / f"{m['metadata']['name']}.yaml"
@@ -406,6 +409,8 @@ def generate_csv(
406409

407410
result = load_resource("csv.yaml")
408411

412+
# In case of spark, -k8s is still in the product name but the bundle name
413+
# in the certification repository is without -k8s. See previous comment on this.
409414
csv_name = (
410415
"spark-operator" if args.op_name == "spark-k8s-operator" else args.op_name
411416
)
@@ -423,6 +428,7 @@ def generate_csv(
423428
result["metadata"]["annotations"]["repository"] = (
424429
f"https://github.com/stackabletech/{args.op_name}"
425430
)
431+
result["metadata"]["annotations"]["olm.skipRange"] = f'< {args.release}'
426432

427433
### 1. Add list of owned crds
428434
result["spec"]["customresourcedefinitions"]["owned"] = owned_crds
@@ -488,7 +494,7 @@ def generate_helm_templates(args: argparse.Namespace) -> list[dict]:
488494
{
489495
"apiGroups": ["security.openshift.io"],
490496
"resources": ["securitycontextconstraints"],
491-
"resourceNames": ["stackable-products-scc"],
497+
"resourceNames": ["nonroot-v2"],
492498
"verbs": ["use"],
493499
}
494500
)
@@ -579,17 +585,19 @@ def write_metadata(args: argparse.Namespace) -> None:
579585

580586
annos = load_resource("annotations.yaml")
581587

588+
bundle_package_name = (
589+
"spark-operator" if args.op_name == "spark-k8s-operator" else args.op_name
590+
)
591+
582592
annos["annotations"]["operators.operatorframework.io.bundle.package.v1"] = (
583-
f"stackable-{args.op_name}"
593+
f"stackable-{bundle_package_name}"
584594
)
585595
annos["annotations"]["com.redhat.openshift.versions"] = args.openshift_versions
586596

587597
annos["annotations"][
588598
"operators.operatorframework.io.bundle.channel.default.v1"
589599
] = args.channel
590-
annos["annotations"]["operators.operatorframework.io.bundle.channels.v1"] = (
591-
args.channel
592-
)
600+
annos["annotations"]["operators.operatorframework.io.bundle.channels.v1"] = f"stable,{args.channel}"
593601

594602
anno_file = metadata_dir / "annotations.yaml"
595603
logging.info(f"Writing {anno_file}")

olm/build-manifests.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ generate_metadata() {
5050
cat >annotations.yaml <<-ANNOS
5151
---
5252
annotations:
53-
operators.operatorframework.io.bundle.channel.default.v1: stable
54-
operators.operatorframework.io.bundle.channels.v1: stable
53+
operators.operatorframework.io.bundle.channel.default.v1: "${RELEASE}"
54+
operators.operatorframework.io.bundle.channels.v1: "stable,${RELEASE}"
5555
operators.operatorframework.io.bundle.manifests.v1: manifests/
5656
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
5757
operators.operatorframework.io.bundle.metadata.v1: metadata/
5858
operators.operatorframework.io.bundle.package.v1: stackable-${OPERATOR}
5959
60-
com.redhat.openshift.versions: v4.11-v4.15
60+
com.redhat.openshift.versions: v4.12-v4.15
6161
ANNOS
6262

6363
cat >dependencies.yaml <<-DEPS
@@ -97,6 +97,7 @@ parse_inputs() {
9797
case $1 in
9898
-r)
9999
RELEASE_VERSION="$2"
100+
RELEASE="$(cut -d'.' -f1,2 <<<"$RELEASE_VERSION")"
100101
shift
101102
;;
102103
-o)
@@ -150,14 +151,14 @@ HELP
150151
patch_cluster_roles() {
151152
pushd "$MANIFESTS_DIR"
152153

153-
# Add product SCC to product cluster role
154+
# Add nonroot-v2 SCC to product cluster role
154155
if [ -f "$PRODUCT-clusterrole.yml" ]; then
155-
yq -i '.rules += { "apiGroups": [ "security.openshift.io" ], "resources": [ "securitycontextconstraints" ], "resourceNames": ["stackable-products-scc" ], "verbs": ["use"]}' "$PRODUCT-clusterrole.yml"
156+
yq -i '.rules += { "apiGroups": [ "security.openshift.io" ], "resources": [ "securitycontextconstraints" ], "resourceNames": ["nonroot-v2" ], "verbs": ["use"]}' "$PRODUCT-clusterrole.yml"
156157
fi
157158

158-
# Add hostmount-anyuid SCC to operator cluster role
159+
# Add nonroot-v2 SCC to operator cluster role
159160
if [ -f "$OPERATOR-clusterrole.yml" ]; then
160-
yq -i '.rules += { "apiGroups": [ "security.openshift.io" ], "resources": [ "securitycontextconstraints" ], "resourceNames": ["hostmount-anyuid" ], "verbs": ["use"]}' "$OPERATOR-clusterrole.yml"
161+
yq -i '.rules += { "apiGroups": [ "security.openshift.io" ], "resources": [ "securitycontextconstraints" ], "resourceNames": ["nonroot-v2" ], "verbs": ["use"]}' "$OPERATOR-clusterrole.yml"
161162
fi
162163

163164
popd

olm/resources/csv.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ metadata:
1919
description: Stackable Operator for placeholder
2020
repository: https://github.com/stackabletech/placeholder
2121
containerImage: placeholder
22+
olm.skipRange: placeholder
2223
spec:
2324
displayName: placeholder
2425
description: |

0 commit comments

Comments
 (0)