Skip to content

Commit b5c7be9

Browse files
authored
Merge pull request #864 from snyk/fix/upgrade_operator_publishing
[RUN-1671] Use the new operator repos
2 parents 0e62431 + 672842d commit b5c7be9

14 files changed

+242
-100
lines changed

.circleci/config.yml

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ jobs:
382382
Deploys a previously released version of the snyk-operator.
383383
Subsequently upgrades the Operator with a new version that is intended
384384
to be released. If the Operator reaches the running state in both cases,
385-
we can aassume that it's able to upgrade.
385+
we can assume that it's able to upgrade.
386386
executor: redhat-openshift/default
387387
steps:
388388
- checkout
@@ -413,9 +413,11 @@ jobs:
413413
source $BASH_ENV
414414
set -xeo pipefail
415415
416-
OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py)
416+
OPERATOR_REPO_URL="https://raw.githubusercontent.com/redhat-openshift-ecosystem/community-operators-prod/main/operators/snyk-operator/snyk-operator.package.yaml"
417417
418-
echo "Currently released version is: ${OPERATOR_VERSION}"
418+
OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py $OPERATOR_REPO_URL)
419+
420+
echo "Currently released embedded version is: ${OPERATOR_VERSION}"
419421
echo "export OPERATOR_VERSION=${OPERATOR_VERSION}" >> $BASH_ENV
420422
name: Get last released Operator version
421423
- run:
@@ -446,10 +448,7 @@ jobs:
446448
OPERATOR_DIR=$(python scripts/operator/package_operator_bundle.py $OPERATOR_VERSION $SNYK_OPERATOR_IMAGE_TAG $SNYK_MONITOR_IMAGE_TAG)
447449
448450
python scripts/operator/create_operator_bundle_and_index_and_push.py $OPERATOR_DIR $OPERATOR_VERSION $DOCKERHUB_USER $DOCKERHUB_PASSWORD
449-
description: |
450-
Even though the Operator is released to the community-operators repo,
451-
we can reproduce it locally using our packaged scripts. This also helps us
452-
test the upgrade by pushing all tested Operators to our Quay repo.
451+
description: "Even though the Operator is released to the\nredhat-openshift-ecosystem/community-operators-prod repo, we can \nreproduce it locally using our packaged scripts. This also helps us\ntest the upgrade by pushing all tested Operators to our Quay repo.\n"
453452
name: Package Operator Bundle and push to Docker Hub
454453
- run:
455454
command: |
@@ -650,7 +649,7 @@ jobs:
650649
push_operator_to_community_operators:
651650
description: |
652651
Packages a new Operator and pushes it to Snyk's fork of
653-
the OpenShift community-operators.
652+
the OpenShift k8s-operatorhub/community-operators.
654653
executor: redhat-openshift/default
655654
steps:
656655
- checkout
@@ -665,7 +664,9 @@ jobs:
665664
- run:
666665
command: |
667666
set -xeo pipefail
668-
LAST_OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py)
667+
OPERATOR_REPO_URL="https://raw.githubusercontent.com/k8s-operatorhub/community-operators/main/operators/snyk-operator/snyk-operator.package.yaml"
668+
669+
LAST_OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py $OPERATOR_REPO_URL)
669670
echo "export LAST_OPERATOR_VERSION=${LAST_OPERATOR_VERSION}" >> $BASH_ENV
670671
name: Get last released Operator version
671672
- run:
@@ -693,15 +694,15 @@ jobs:
693694
COMMUNITY_FOLDER_LOCATION="community-operators"
694695
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
695696
echo "export COMMUNITY_FOLDER_LOCATION=${COMMUNITY_FOLDER_LOCATION}" >> $BASH_ENV
696-
name: Push new Operator to the fork of the community-operators repository
697+
name: Push new Operator to the fork of the k8s-operatorhub/community-operators repository
697698
- run:
698699
command: |
699700
SLACK_PR_URL=$(python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
700701
echo "export SLACK_PR_URL=${SLACK_PR_URL}" >> $BASH_ENV
701-
name: Open a Pull Request to the operator-framework/community-operators repository for community-operators
702+
name: Open a Pull Request to the k8s-operatorhub/community-operators repository
702703
- run:
703704
command: |
704-
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
705+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "community/operators/${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
705706
name: Notify Slack on new branch in snyk/community-operators
706707
- run:
707708
command: |
@@ -711,10 +712,10 @@ jobs:
711712
name: Notify Slack on failure
712713
when: on_fail
713714
working_directory: ~/kubernetes-monitor
714-
push_operator_to_upstream_community_operators:
715+
push_operator_to_embedded_community_operators:
715716
description: |
716717
Packages a new Operator and pushes it to Snyk's fork of
717-
the OpenShift upstream-community-operators.
718+
the redhat-openshift-ecosystem/community-operators-prod.
718719
executor: redhat-openshift/default
719720
steps:
720721
- checkout
@@ -729,7 +730,9 @@ jobs:
729730
- run:
730731
command: |
731732
set -xeo pipefail
732-
LAST_OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py)
733+
OPERATOR_REPO_URL="https://raw.githubusercontent.com/redhat-openshift-ecosystem/community-operators-prod/main/operators/snyk-operator/snyk-operator.package.yaml"
734+
735+
LAST_OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py $OPERATOR_REPO_URL)
733736
echo "export LAST_OPERATOR_VERSION=${LAST_OPERATOR_VERSION}" >> $BASH_ENV
734737
name: Get last released Operator version
735738
- run:
@@ -754,19 +757,19 @@ jobs:
754757
- run:
755758
command: |
756759
CURRENT_DIRECTORY=$(pwd)
757-
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
760+
COMMUNITY_FOLDER_LOCATION="community-operators-prod"
758761
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
759762
echo "export COMMUNITY_FOLDER_LOCATION=${COMMUNITY_FOLDER_LOCATION}" >> $BASH_ENV
760-
name: Push new Operator to the fork of the upstream-community-operators repository
763+
name: Push new Operator to the fork of the redhat-openshift-ecosystem/community-operators-prod repository
761764
- run:
762765
command: |
763-
SLACK_PR_URL=$(python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
766+
SLACK_PR_URL=$(python ./scripts/operator/raise_pr_to_embedded_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
764767
echo "export SLACK_PR_URL=${SLACK_PR_URL}" >> $BASH_ENV
765-
name: Open a Pull Request to the operator-framework/community-operators repository for upstream-community-operators
768+
name: Open a Pull Request to the redhat-openshift-ecosystem/community-operators-prod repository
766769
- run:
767770
command: |
768771
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
769-
name: Notify Slack on new branch in snyk/upstream-community-operators
772+
name: Notify Slack on new branch in snyk/community-operators-prod
770773
- run:
771774
command: |
772775
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
@@ -796,12 +799,44 @@ jobs:
796799
git clone https://github.com/snyk/community-operators.git "${COMMUNITY_FOLDER_LOCATION}"
797800
cd "${COMMUNITY_FOLDER_LOCATION}"
798801
799-
# Sync snyk/community-operators repo from operator-framework/community-operators repo
800-
git remote add upstream https://github.com/operator-framework/community-operators.git
802+
# Sync snyk/community-operators repo from k8s-operatorhub/community-operators repo
803+
git remote add upstream https://github.com/k8s-operatorhub/community-operators.git
804+
git fetch upstream
805+
git merge upstream/main
806+
git push origin main
807+
name: Sync k8s-operatorhub/community-operators with snyk/community-operators
808+
- run:
809+
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
810+
name: Notify Slack on failure
811+
when: on_fail
812+
working_directory: ~/kubernetes-monitor
813+
sync_embedded_community_operators_with_snyk_fork:
814+
docker:
815+
- auth:
816+
password: $DOCKERHUB_PASSWORD
817+
username: $DOCKERHUB_USER
818+
image: cimg/python:3.9.5
819+
steps:
820+
- checkout
821+
- install_python_requests
822+
- add_ssh_keys:
823+
fingerprints:
824+
- 06:c3:d4:10:0d:ef:37:6c:ec:b9:fb:6e:ed:09:e7:40
825+
- run:
826+
command: |
827+
CURRENT_DIRECTORY=$(pwd)
828+
COMMUNITY_FOLDER_LOCATION="${CURRENT_DIRECTORY}/community-operators-prod"
829+
830+
# Clone Community Operators repo from Snyk
831+
git clone https://github.com/snyk/community-operators-prod.git "${COMMUNITY_FOLDER_LOCATION}"
832+
cd "${COMMUNITY_FOLDER_LOCATION}"
833+
834+
# Sync snyk/community-operators repo from redhat-openshift-ecosystem/community-operators-prod repo
835+
git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod.git
801836
git fetch upstream
802-
git merge upstream/master
803-
git push origin master
804-
name: Sync operator-framework/community-operators with snyk/community-operators
837+
git merge upstream/main
838+
git push origin main
839+
name: Sync redhat-openshift-ecosystem/community-operators-prod with snyk/community-operators-prod
805840
- run:
806841
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
807842
name: Notify Slack on failure
@@ -920,21 +955,28 @@ workflows:
920955
- master
921956
requires:
922957
- hold
923-
- sync_community_operators_with_snyk_fork:
958+
- sync_embedded_community_operators_with_snyk_fork:
924959
filters:
925960
branches:
926961
only:
927962
- master
928963
requires:
929964
- operator_upgrade_tests
930-
- push_operator_to_community_operators:
965+
- push_operator_to_embedded_community_operators:
931966
filters:
932967
branches:
933968
only:
934969
- master
935970
requires:
936-
- sync_community_operators_with_snyk_fork
937-
- push_operator_to_upstream_community_operators:
971+
- sync_embedded_community_operators_with_snyk_fork
972+
- sync_community_operators_with_snyk_fork:
973+
filters:
974+
branches:
975+
only:
976+
- master
977+
requires:
978+
- push_operator_to_embedded_community_operators
979+
- push_operator_to_community_operators:
938980
filters:
939981
branches:
940982
only:
@@ -1058,10 +1100,10 @@ workflows:
10581100
MONTHLY:
10591101
jobs:
10601102
- operator_upgrade_tests
1061-
- push_operator_to_community_operators:
1103+
- push_operator_to_embedded_community_operators:
10621104
requires:
10631105
- operator_upgrade_tests
1064-
- push_operator_to_upstream_community_operators:
1106+
- push_operator_to_community_operators:
10651107
requires:
10661108
- operator_upgrade_tests
10671109
triggers:

.circleci/config/@config.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ workflows:
132132
- master
133133
jobs:
134134
- operator_upgrade_tests
135-
- push_operator_to_community_operators:
135+
- push_operator_to_embedded_community_operators:
136136
requires:
137137
- operator_upgrade_tests
138-
- push_operator_to_upstream_community_operators:
138+
- push_operator_to_community_operators:
139139
requires:
140140
- operator_upgrade_tests
141141

@@ -148,15 +148,19 @@ workflows:
148148
<<: *master_branch_only_filter
149149
requires:
150150
- hold
151-
- sync_community_operators_with_snyk_fork:
151+
- sync_embedded_community_operators_with_snyk_fork:
152152
<<: *master_branch_only_filter
153153
requires:
154154
- operator_upgrade_tests
155-
- push_operator_to_community_operators:
155+
- push_operator_to_embedded_community_operators:
156156
<<: *master_branch_only_filter
157157
requires:
158-
- sync_community_operators_with_snyk_fork
159-
- push_operator_to_upstream_community_operators:
158+
- sync_embedded_community_operators_with_snyk_fork
159+
- sync_community_operators_with_snyk_fork:
160+
<<: *master_branch_only_filter
161+
requires:
162+
- push_operator_to_embedded_community_operators
163+
- push_operator_to_community_operators:
160164
<<: *master_branch_only_filter
161165
requires:
162166
- sync_community_operators_with_snyk_fork

.circleci/config/jobs/integration_tests_operator_on_k8s.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ steps:
99
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
1010
name: Create temporary directory for logs
1111
- run:
12+
name: Operator integration tests on vanilla Kubernetes
1213
command: |
1314
export OPERATOR_VERSION="0.0.1-${CIRCLE_SHA1}"
1415
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
1516
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
16-
name: Operator integration tests on vanilla Kubernetes
1717
- run:
18-
command: |
19-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
2018
name: Notify Slack on failure
2119
when: on_fail
20+
command: |
21+
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
2222
- store_artifacts:
2323
path: /tmp/logs/test/integration/kind-olm-operator
2424
working_directory: ~/kubernetes-monitor

.circleci/config/jobs/operator_upgrade_tests.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ description: |
22
Deploys a previously released version of the snyk-operator.
33
Subsequently upgrades the Operator with a new version that is intended
44
to be released. If the Operator reaches the running state in both cases,
5-
we can aassume that it's able to upgrade.
5+
we can assume that it's able to upgrade.
66
77
executor: redhat-openshift/default
88

@@ -29,6 +29,7 @@ steps:
2929
- install_python_requests
3030

3131
- setup_remote_docker
32+
3233
- run: docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD}
3334

3435
- run:
@@ -43,9 +44,11 @@ steps:
4344
source $BASH_ENV
4445
set -xeo pipefail
4546
46-
OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py)
47+
OPERATOR_REPO_URL="https://raw.githubusercontent.com/redhat-openshift-ecosystem/community-operators-prod/main/operators/snyk-operator/snyk-operator.package.yaml"
48+
49+
OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py $OPERATOR_REPO_URL)
4750
48-
echo "Currently released version is: ${OPERATOR_VERSION}"
51+
echo "Currently released embedded version is: ${OPERATOR_VERSION}"
4952
echo "export OPERATOR_VERSION=${OPERATOR_VERSION}" >> $BASH_ENV
5053
5154
- run:
@@ -70,8 +73,9 @@ steps:
7073
- run:
7174
name: Package Operator Bundle and push to Docker Hub
7275
description: |
73-
Even though the Operator is released to the community-operators repo,
74-
we can reproduce it locally using our packaged scripts. This also helps us
76+
Even though the Operator is released to the
77+
redhat-openshift-ecosystem/community-operators-prod repo, we can
78+
reproduce it locally using our packaged scripts. This also helps us
7579
test the upgrade by pushing all tested Operators to our Quay repo.
7680
command: |
7781
source $BASH_ENV
@@ -218,6 +222,7 @@ steps:
218222
219223
- run:
220224
name: Cleanup
225+
when: always
221226
command: |
222227
set +e
223228
@@ -233,12 +238,11 @@ steps:
233238
kubectl delete ns snyk-monitor
234239
# Force a success status code, otherwise Bash will implicitly return the last command's code, which can be 1.
235240
true
236-
when: always
237241
238242
- run:
239243
name: Notify Slack on failure
244+
when: on_fail
240245
command: |
241246
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
242247
./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
243248
fi
244-
when: on_fail

0 commit comments

Comments
 (0)