From 913cd2575236defc1cefa4afcf264de4fab7b13f Mon Sep 17 00:00:00 2001 From: Mateus Oliveira Date: Mon, 25 Mar 2024 10:28:24 -0300 Subject: [PATCH] fixup! fix: Add contribution documenation to project Signed-off-by: Mateus Oliveira --- .github/workflows/ci.yml | 7 +-- .../workflows/oadp-compatibility-check.yml | 46 ++++++++++++++++ Makefile | 50 ++++++++++++----- README.md | 54 +++++++------------ config/default/kustomization.yaml | 2 +- config/manager/kustomization.yaml | 2 +- 6 files changed, 110 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/oadp-compatibility-check.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04cf21e..e5c925a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: - master schedule: - - cron: '0 0 * * 1' # Every Monday at 00:00 UTC + - cron: '0 0 * * 1' # Every Monday at 00:00 UTC jobs: golang-check: @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ matrix.go-version }} - name: Install Go dependencies run: go mod download @@ -69,4 +69,5 @@ jobs: - name: Check all files format run: make ec - # TODO do not allow overwrite of production image + - name: Check if images are the same in Makefile and config/manager/kustomization.yaml + run: make check-images diff --git a/.github/workflows/oadp-compatibility-check.yml b/.github/workflows/oadp-compatibility-check.yml new file mode 100644 index 0000000..74dce96 --- /dev/null +++ b/.github/workflows/oadp-compatibility-check.yml @@ -0,0 +1,46 @@ +name: OADP version compatibility check + +on: + push: + branches: + - master + # add release branches + schedule: + - cron: '0 0 * * 1' # Every Monday at 00:00 UTC + # TODO remove, just for test + pull_request: + branches: + - master + +jobs: + golang-check: + runs-on: ubuntu-latest + strategy: + matrix: + oadp-version: [ + "master", + # add release branches + ] + + steps: + - name: Checkout OADP operator + uses: actions/checkout@v4 + with: + repository: openshift/oadp-operator + ref: ${{ matrix.oadp-version }} + + - uses: actions/setup-go@v5 + with: + go-version: "1.20" + + - name: Checkout Non Admin Controller (NAC) + uses: actions/checkout@v4 + with: + repository: migtools/oadp-non-admin + ref: ${{ matrix.oadp-version }} + path: oadp-non-admin + + - name: Check Non Admin Controller (NAC) manifests + run: | + NON_ADMIN_CONTROLLER_PATH=./oadp-non-admin make update-non-admin-manifests + test -z "$(git status --short)" || (echo "run 'make update-non-admin-manifests' in OADP repository to update Non Admin Controller (NAC) manifests" && exit 1) diff --git a/Makefile b/Makefile index 1821e6a..b01c450 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Image URL to use all building/pushing image targets -IMG ?= controller:latest +IMG ?= quay.io/konveyor/non-admin-controller:latest # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.29.0 @@ -116,11 +116,14 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform rm Dockerfile.cross .PHONY: build-installer -build-installer: DIR?=dist build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. - mkdir -p $(DIR) + mkdir -p dist + @if [ -d "config/crd" ]; then \ + $(KUSTOMIZE) build config/crd > dist/install.yaml; \ + fi + echo "---" >> dist/install.yaml # Add a document separator before appending cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build config/default > $(DIR)/install.yaml + $(KUSTOMIZE) build config/default >> dist/install.yaml ##@ Deployment @@ -221,7 +224,7 @@ editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. } .PHONY: ci -ci: simulation-test lint docker-build hadolint check-generate check-manifests ec ## Run all checks run by the project continuous integration (CI) locally. +ci: simulation-test lint docker-build hadolint check-generate check-manifests ec check-images ## Run all checks run by the project continuous integration (CI) locally. .PHONY: simulation-test simulation-test: envtest ## Run unit and integration tests. @@ -243,14 +246,37 @@ check-manifests: manifests ## Check if 'make manifests' was run. ec: editorconfig ## Run file formatter checks against all project's files. $(EC) +.PHONY: check-images +check-images: MANAGER_IMAGE:=$(shell grep -I 'newName: ' ./config/manager/kustomization.yaml | awk -F': ' '{print $$2}') +check-images: MANAGER_TAG:=$(shell grep -I 'newTag: ' ./config/manager/kustomization.yaml | awk -F': ' '{print $$2}') +check-images: ## Check if images are the same in Makefile and config/manager/kustomization.yaml + @if [ "$(MANAGER_IMAGE)" == "" ];then echo "No manager image found" && exit 1;fi + @if [ "$(MANAGER_TAG)" == "" ];then echo "No manager tag found" && exit 1;fi + @grep -Iq "IMG ?= $(MANAGER_IMAGE):$(MANAGER_TAG)" ./Makefile || (echo "Images differ" && exit 1) + +# A valid oadp-operator git repo fork (for example https://github.com/openshift/oadp-operator) +OADP_FORK ?= openshift +# A valid branch or tag from oadp-operator git repo +OADP_VERSION ?= master +# namespace to deploy development OADP operator +OADP_NAMESPACE ?= openshift-adp + .PHONY: deploy-dev +deploy-dev: TEMP:=$(shell mktemp -d) +deploy-dev: NAC_PATH:=$(shell pwd) deploy-dev: DEV_IMG?=ttl.sh/oadp-nac-controller-$(shell git rev-parse --short HEAD)-$(shell echo $$RANDOM):1h -deploy-dev: ## Build and push development controller image from current branch and deploy development controller to cluster - PROD_IMG=$(IMG) IMG=$(DEV_IMG) DIR=dev make docker-build docker-push build-installer - IMG=$(PROD_IMG) cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} && cd - - $(OC_CLI) apply -f dev/install.yaml +deploy-dev: ## Build and push development controller image from current branch and deploy development OADP operator using that image + IMG=$(DEV_IMG) make docker-build docker-push + git clone --depth=1 git@github.com:$(OADP_FORK)/oadp-operator.git -b $(OADP_VERSION) $(TEMP)/oadp-operator + cd $(TEMP)/oadp-operator && \ + NON_ADMIN_CONTROLLER_PATH=$(NAC_PATH) NON_ADMIN_CONTROLLER_IMG=$(DEV_IMG) OADP_TEST_NAMESPACE=$(OADP_NAMESPACE) \ + make update-non-admin-manifests deploy-olm && cd - + chmod -R 777 $(TEMP) && rm -rf $(TEMP) -# TODO prior delete CR instances, to avoid finalizers problem .PHONY: undeploy-dev -undeploy-dev: ## Undeploy development controller from cluster - $(OC_CLI) delete -f dev/install.yaml +undeploy-dev: ## Undeploy development OADP operator from cluster + git clone --depth=1 git@github.com:$(OADP_FORK)/oadp-operator.git -b $(OADP_VERSION) $(TEMP)/oadp-operator + cd $(TEMP)/oadp-operator && \ + OADP_TEST_NAMESPACE=$(OADP_NAMESPACE) \ + make undeploy-olm && cd - + chmod -R 777 $(TEMP) && rm -rf $(TEMP) diff --git a/README.md b/README.md index 389111f..e4eae44 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Non Admin Controller [![Continuos Integration](https://github.com/migtools/oadp-non-admin/actions/workflows/ci.yml/badge.svg)](https://github.com/migtools/oadp-non-admin/actions/workflows/ci.yml) +[![OADP version compatibility check](https://github.com/migtools/oadp-non-admin/actions/workflows/oadp-compatibility-check.yml/badge.svg)](https://github.com/migtools/oadp-non-admin/actions/workflows/oadp-compatibility-check.yml) @@ -18,54 +19,40 @@ This open source controller adds the non admin feature to [OADP operator](https: - go version v1.21.0+ - oc - Access to a OpenShift cluster -- [OADP operator](https://github.com/openshift/oadp-operator) installed in the cluster - - ### Install -To install latest OADP NAC in `oadp-nac-system` namespace in your cluster, run +To install OADP operator in your cluster, with OADP NAC from current branch, run ```sh -make deploy +make deploy-dev ``` -To check the deployment, run +The command can be customized by setting the following environment variables ```sh -oc get all -n oadp-nac-system -``` - -you should have an output similar to this: -``` -NAME READY STATUS RESTARTS AGE -pod/oadp-nac-controller-manager-74bbf4577b-nssw4 2/2 Running 0 3m7s - -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -service/oadp-nac-controller-manager-metrics-service ClusterIP 172.30.201.185 8443/TCP 3m8s - -NAME READY UP-TO-DATE AVAILABLE AGE -deployment.apps/oadp-nac-controller-manager 1/1 1 1 3m7s - -NAME DESIRED CURRENT READY AGE -replicaset.apps/oadp-nac-controller-manager-74bbf4577b 1 1 1 3m7s +OADP_FORK= +OADP_VERSION= +OADP_NAMESPACE= ``` ### Testing -To test NAC functionality, create non admin CRs. For example, run -```sh -oc apply -f config/samples/nac_v1alpha1_nonadminbackup.yaml -``` +To test NAC functionality: +- create DPA with non admin feature enabled +- create non admin CRs. For example, run + ```sh + oc apply -f config/samples/nac_v1alpha1_nonadminbackup.yaml + ``` To create a non admin user to test NAC, check [non admin user documentation](docs/non_admin_user.md). ### Uninstall -To uninstall the previously installed OADP NAC in your cluster, run +To uninstall the previously installed OADP operator in your cluster, run ```sh -make undeploy +make undeploy-dev ``` -> **NOTE:** make sure there are no running instances of CRDs. Finalizers in those objects can fail the `undeploy` command. +> **NOTE:** make sure there are no running instances of CRDs. Finalizers in those objects can fail `undeploy-dev` command. ## Contributing @@ -77,12 +64,11 @@ For a better understanding of the project, check our [architecture documentation ## OADP version compatibility -OADP NAC needs OADP operator to work. The relationship between compatible versions is presented below. +OADP NAC needs OADP operator to work. The relationship between compatible branches is presented below. -| NAC version | OADP version | -|-------------|--------------| -| master | master | -| v0.1.0 | v1.4.0 | +| NAC branch | OADP branch | +|------------|-------------| +| master | master | ## License diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index fad9d72..dc2c7d2 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,5 +1,5 @@ # Adds namespace to all resources. -namespace: oadp-nac-system # TODO change +namespace: oadp-nac-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index ad13e96..ce08398 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: controller + newName: quay.io/konveyor/non-admin-controller newTag: latest