|
| 1 | +# Downstream CI |
| 2 | + |
| 3 | +The CI configuration for each release branch can be found [here](https://github.com/openshift/release/tree/master/ci-operator/config/openshift/operator-framework-olm). |
| 4 | +From `4.11` (`master` as of this writing) we've updated the configuration to able to influence CI on a PR basis. An overview of the `ci-operator` (the system used for ci) |
| 5 | +can be found [here](https://docs.ci.openshift.org/docs/architecture/ci-operator/). |
| 6 | + |
| 7 | +### Structure |
| 8 | + |
| 9 | + * `.ci-operator.yaml` defines the `build_root_image`. To be ART compliant, the image should come from the [ocp-build-data](https://github.com/openshift/ocp-build-data/) repo |
| 10 | + * [openshift-operator-framework-olm-master.yaml](https://github.com/openshift/release/blob/master/ci-operator/config/openshift/operator-framework-olm/openshift-operator-framework-olm-master.yaml) defines the images that are used by ci, produced by ci, and the ci jobs the get executed. |
| 11 | + * `base.Dockerfile` defines the image used by ci to execute the ci jobs |
| 12 | + |
| 13 | +From [openshift-operator-framework-olm-master.yaml](https://github.com/openshift/release/blob/master/ci-operator/config/openshift/operator-framework-olm/openshift-operator-framework-olm-master.yaml), we see under the `images` stanza the `ci-image` definition. |
| 14 | +It goes from `src` (the `build_root_image`) to `ci-image` by building `base.Dockerfile` with `src` as the base image. |
| 15 | + |
| 16 | +``` |
| 17 | +- dockerfile_path: base.Dockerfile |
| 18 | + from: src |
| 19 | + to: ci-image |
| 20 | +``` |
| 21 | + |
| 22 | +The image is excluded from promotion, to never be posted up anywhere: |
| 23 | + |
| 24 | +``` |
| 25 | +promotion: |
| 26 | + excluded_images: |
| 27 | + - ci-image |
| 28 | +``` |
| 29 | + |
| 30 | +and each `test` references `ci-image` as the image to be used to the test, e.g.: |
| 31 | + |
| 32 | +``` |
| 33 | +tests: |
| 34 | +- as: verify |
| 35 | + commands: make verify |
| 36 | + container: |
| 37 | + from: ci-image |
| 38 | +``` |
| 39 | + |
| 40 | +### Updating go versions |
| 41 | + |
| 42 | +All we need to do is update the `build_root_image` referenced in `.ci-operator.yaml` and we may also need to update the `base_images` in [openshift-operator-framework-olm-master.yaml](https://github.com/openshift/release/blob/master/ci-operator/config/openshift/operator-framework-olm/openshift-operator-framework-olm-master.yaml). |
| 43 | + |
| 44 | +**NOTE**: I believe there is some automation that updates the base images, though I don't know. I'll leave this as a questions to the reviewer, and if no one knows, I'll go after it. |
| 45 | + |
| 46 | +### Downstream sync |
| 47 | + |
| 48 | +The complete information about the downstreaming process can be found [here](https://docs.google.com/document/d/139yXeOqAJbV1ndC7Q4NbaOtzbSdNpcuJan0iemORd3g/edit). |
| 49 | + |
| 50 | +TL;DR; |
| 51 | + |
| 52 | +We sync three upstream repositories ([api](https://github.com/operator-framework/api), [registry](https://github.com/operator-framework/operator-registry), [olm](https://github.com/operator-framework/operator-lifecycle-manager)) to the downstream [olm mono-repo](https://github.com/openshift/operator-framework-olm). Commits from the upstream repositories are cherry-picked to the appropriate `staging` directory in the downstream repository. Because this is a monorepo in the `Openshift` GitHub organization, two things need to be remembered: |
| 53 | + - we don't pull in upstream `vendor` folder changes |
| 54 | + - we don't pull in changes to `OWNERS` files |
| 55 | + - after each cherry-pick we execute: `make vendor` and `make manifest` to ensure a) the downstream dependencies are updated b) to ensure any manifest changes are picked up downstream |
| 56 | + |
| 57 | + While manual changes to the `staging` directory should be avoided, there could be instances where there drift between the downstream `staging` directory and the corresponding upstream repository. This can happen due to applying commits out-of-order, e.g. due to feature freeze, etc. |
| 58 | + |
| 59 | + Therefore, after a sync, it is important to manually verify the diff of `staging` and the upstream. Please note, though, that some downstream changes are downstream only. These are, however, few and far between and there are comments to indicate that a block of code is downstream only. |
| 60 | + |
| 61 | + The downstream sync process is facilitated by two scripts: `scripts/sync_get_candidates.sh` and `scripts/sync_pop_candidate.sh`, which compare the upstream remote with the appropriate `staging` directory and gets a stack of commits to sync, and cherry-pick those commits in reverse order. What does this look like in practice: |
| 62 | + |
| 63 | + ```bash |
| 64 | +# Clone downstream |
| 65 | +git clone [email protected]:openshift/operator-framework-olm.git && cd operator-framework-olm |
| 66 | + |
| 67 | +# Add and fetch upstream remotes |
| 68 | +git remote add api [email protected]:operator-framework/api.git && git fetch api |
| 69 | +git remote add operator-registry [email protected]:operator-framework/operator-registry.git && git fetch operator-registry |
| 70 | +git remote add operator-lifecycle-manager [email protected]:operator-framework/operator-lifecycle-manager.git && git fetch operator-lifecycle-manager |
| 71 | + |
| 72 | +# Get upstream commit candidates: ./scripts/sync_get_candidates.sh <api|operator-registry|operator-lifecycle-manager> <branch> |
| 73 | +# The shas will be found in ./<api|operator-registry|operator-lifecycle-manager>.cherrypick |
| 74 | +./scripts/sync_get_candidates.sh api master |
| 75 | +./scripts/sync_get_candidates.sh operator-registry master |
| 76 | +./scripts/sync_get_candidates.sh operator-lifecycle-manager master |
| 77 | + |
| 78 | +# Sync upstream commits: ./scripts/sync_pop_candidate.sh <api|operator-registry|operator-lifecycle-manager> [-a] |
| 79 | +# Without -a, you'll proceed one commit at a time. With -a the process will conclude once there are no more commits. |
| 80 | +# When a cherry pick encounters a conflict the script will stop so you can manually fix it. |
| 81 | +sync_pop_candidate.sh operator-lifecycle-manager -a |
| 82 | + |
| 83 | +# When finished |
| 84 | +sync_pop_candidate.sh api -a |
| 85 | + |
| 86 | +# When finished |
| 87 | +sync_pop_candidate.sh operator-registry -a |
| 88 | + |
| 89 | +# Depending on the changes being pulled in, the order of repos you sync _could_ matter and _could_ leave a commit in an unbuildable state |
| 90 | + ``` |
| 91 | + |
| 92 | + Example: |
| 93 | + |
| 94 | + ```bash |
| 95 | +$ sync_pop_candidate.sh operator-lifecycle-manager -a |
| 96 | + |
| 97 | +.github/workflows: Enable workflow_dispatch event triggers (#2464) |
| 98 | + Author: Tim Flannagan <[email protected]> |
| 99 | + Date: Mon Dec 20 15:13:33 2021 -0500 |
| 100 | + 9 files changed, 9 insertions(+), 1 deletion(-) |
| 101 | +66 picks remaining (pop_all=true) |
| 102 | +popping: 4daeb114ccd56cee7132883325da68c80ba70bed |
| 103 | +Auto-merging staging/operator-lifecycle-manager/go.mod |
| 104 | +CONFLICT (content): Merge conflict in staging/operator-lifecycle-manager/go.mod |
| 105 | +Auto-merging staging/operator-lifecycle-manager/go.sum |
| 106 | +CONFLICT (content): Merge conflict in staging/operator-lifecycle-manager/go.sum |
| 107 | +CONFLICT (modify/delete): staging/operator-lifecycle-manager/vendor/github.com/operator-framework/api/pkg/validation/doc.go deleted in HEAD and modified in 4daeb114c (chore(api): Vendor the new version of api repo (#2525)). Version 4daeb114c (chore(api): Vendor the new version of api repo (#2525)) of staging/operator-lifecycle-manager/vendor/github.com/operator-framework/api/pkg/validation/doc.go left in tree. |
| 108 | +CONFLICT (modify/delete): staging/operator-lifecycle-manager/vendor/modules.txt deleted in HEAD and modified in 4daeb114c (chore(api): Vendor the new version of api repo (#2525)). Version 4daeb114c (chore(api): Vendor the new version of api repo (#2525)) of staging/operator-lifecycle-manager/vendor/modules.txt left in tree. |
| 109 | +error: could not apply 4daeb114c... chore(api): Vendor the new version of api repo (#2525) |
| 110 | +hint: After resolving the conflicts, mark them with |
| 111 | +hint: "git add/rm <pathspec>", then run |
| 112 | +hint: "git cherry-pick --continue". |
| 113 | +hint: You can instead skip this commit with "git cherry-pick --skip". |
| 114 | +hint: To abort and get back to the state before "git cherry-pick", |
| 115 | +hint: run "git cherry-pick --abort". |
| 116 | + |
| 117 | +$ rm -rf staging/operator-lifecycle-manager/vendor |
| 118 | + |
| 119 | +# make sure there are no conflics in |
| 120 | +# staging/operator-lifecycle-manager/go.mod and go.sum |
| 121 | +$ cd staging/operator-lifecycle-manager |
| 122 | +$ go mod tidy |
| 123 | +$ cd ../../ |
| 124 | + |
| 125 | +# now that the conflict is fixed, advance again |
| 126 | +$ sync_pop_candidate.sh operator-lifecycle-manager -a |
| 127 | + ``` |
| 128 | +
|
| 129 | +### Troubleshooting |
| 130 | +
|
| 131 | +#### Running console test locally |
| 132 | +
|
| 133 | +The [console](https://github.com/openshift/console) repository contains all instructions you need to execute the console tests locally. The olm console tests can be found [here](https://github.com/openshift/console/tree/master/frontend/packages/operator-lifecycle-manager) |
0 commit comments