diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1832352fa1..495c20fa6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,22 @@ git commit -sam "Add feature X" gh pr create ``` +#### Make changes to the project manifests + +The following command should be run to make sure the project manifests are up-to-date: + +```bash +make generate manifests bundle api-docs reset +``` + +The local changes after running the command should be added to the pull request: + +The following `make` target is run on CI to verify the project structure: + +```bash +make ensure-generate-is-noop +``` + ### Pre-requisites * Install [Go](https://golang.org/doc/install). * Install [Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/). @@ -37,7 +53,7 @@ Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/ Build the manifests, install the CRD and run the operator as a local process: ```bash -make bundle install run +make install run ``` ### Deployment with webhooks @@ -58,16 +74,16 @@ The environment variable `CERTMANAGER_VERSION` can be used to override the cert- CERTMANAGER_VERSION=1.60 make cert-manager ``` -When deploying the operator into the cluster using `make deploy`, an image in the format `ghcr.io/${USER}/opentelemetry-operator` is generated. If this format isn't suitable, it can be overridden by: +When deploying the operator into the cluster using `make deploy`, an image in the format `ghcr.io/${DOCKER_USER}/opentelemetry-operator` is generated. If this format isn't suitable, it can be overridden by: * `IMG_PREFIX`, to override the registry, namespace and image name -* `USER`, to override the namespace +* `DOCKER_USER`, to override the namespace * `IMG_REPO`, to override the repository (`opentelemetry-operator`) * `VERSION`, to override only the version part * `IMG`, to override the entire image specification ```bash -IMG=docker.io/${USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate bundle container container-push deploy +IMG=docker.io/${DOCKER_USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate container container-push deploy ``` Your operator will be available in the `opentelemetry-operator-system` namespace. @@ -108,6 +124,8 @@ Once they are installed, the tests can be executed with `make prepare-e2e`, whic The tests are located under `tests/e2e` and are written to be used with `kuttl`. Refer to their documentation to understand how tests are written. +To evert the changes made by the `make prepare-e2e` run `make reset`. + ### OpenShift End to End tests To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster. @@ -188,7 +206,7 @@ BUNDLE_IMG=docker.io/${USER}/opentelemetry-operator-bundle:latest IMG=docker.io/ ### Install the operator ```bash -operator-sdk run bundle docker.io/${USER}/opentelemetry-operator-bundle:latest +operator-sdk run bundle docker.io/${DOCKER_USER}/opentelemetry-operator-bundle:latest ``` ### Uninstall the operator diff --git a/Makefile b/Makefile index 9185fee168..d14311a893 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,8 @@ OPERATOR_LDFLAGS ?= -X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.build ARCH ?= $(shell go env GOARCH) # Image URL to use all building/pushing image targets -IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator +DOCKER_USER ?= open-telemetry +IMG_PREFIX ?= ghcr.io/${DOCKER_USER}/opentelemetry-operator IMG_REPO ?= opentelemetry-operator IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION} BUNDLE_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-bundle:${VERSION} @@ -82,7 +83,7 @@ SED ?= $(shell which gsed 2>/dev/null || which sed) .PHONY: ensure-generate-is-noop ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION) -ensure-generate-is-noop: USER=open-telemetry +ensure-generate-is-noop: DOCKER_USER=open-telemetry ensure-generate-is-noop: set-image-controller generate bundle @# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check @git restore config/manager/kustomization.yaml @@ -178,7 +179,7 @@ lint: golangci-lint # Generate code .PHONY: generate -generate: controller-gen api-docs +generate: controller-gen $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." # end-to-tests @@ -442,6 +443,16 @@ bundle: kustomize operator-sdk manifests set-image-controller $(OPERATOR_SDK) bundle validate ./bundle ./hack/ignore-createdAt-bundle.sh +.PHONY: reset +reset: kustomize operator-sdk manifests + $(MAKE) VERSION=${OPERATOR_VERSION} set-image-controller + $(OPERATOR_SDK) generate kustomize manifests -q + $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version ${OPERATOR_VERSION} $(BUNDLE_METADATA_OPTS) + $(OPERATOR_SDK) bundle validate ./bundle + ./hack/ignore-createdAt-bundle.sh + git checkout config/manager/kustomization.yaml + OPERATOR_IMG=local/opentelemetry-operator:e2e TARGETALLOCATOR_IMG=local/opentelemetry-operator-targetallocator:e2e OPERATOROPAMPBRIDGE_IMG=local/opentelemetry-operator-opamp-bridge:e2e DEFAULT_OPERATOR_IMG=$(IMG) DEFAULT_TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) DEFAULT_OPERATOROPAMPBRIDGE_IMG=$(OPERATOROPAMPBRIDGE_IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh + # Build the bundle image, used only for local dev purposes .PHONY: bundle-build bundle-build: diff --git a/RELEASE.md b/RELEASE.md index 4582168819..8a664f1e16 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,7 +4,7 @@ Steps to release a new version of the OpenTelemetry Operator: 1. Change the `versions.txt`, so that it lists the target version of the OpenTelemetry Collector (operand), and the desired version for the target allocator and the operator. The `major.minor` should typically match, with the patch portion being possibly different. 2. Change the `autoinstrumentation-*` versions in `versions.txt` as per the latest supported versions in `autoinstrumentation/`. -3. Run `make bundle USER=open-telemetry VERSION=0.38.0`, using the version that will be released. +3. Run `make bundle DOCKER_USER=open-telemetry VERSION=0.38.0`, using the version that will be released. 4. Change the compatibility matrix in the [readme](./README.md) file, using the OpenTelemetry Operator version to be released and the current latest Kubernetes version as the latest supported version. Remove the oldest entry. 5. Add the changes to the changelog. Manually add versions of all operator components. 6. Check the OpenTelemetry Collector's changelog and ensure migration steps are present in `pkg/collector/upgrade` diff --git a/hack/ignore-createdAt-bundle.sh b/hack/ignore-createdAt-bundle.sh index ddc3df1918..d94a30a477 100755 --- a/hack/ignore-createdAt-bundle.sh +++ b/hack/ignore-createdAt-bundle.sh @@ -5,7 +5,9 @@ # This code checks if only the createdAt field. If is the only change, it is ignored. # Else, it will do nothing. # https://github.com/operator-framework/operator-sdk/issues/6285#issuecomment-1415350333 -git diff --quiet -I'^ createdAt: ' bundle -if ((! $?)) ; then - git checkout bundle -fi \ No newline at end of file +git diff --quiet -I'^ createdAt: ' bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +ret=$? +changes=$(git diff --numstat bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml) +if [ $ret = 0 ] && [ "$changes" = '1 1 bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml' ] ; then + git checkout bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml +fi diff --git a/hack/modify-test-images.sh b/hack/modify-test-images.sh index 3f4c72b883..5c98e53984 100755 --- a/hack/modify-test-images.sh +++ b/hack/modify-test-images.sh @@ -2,11 +2,15 @@ SED_BIN=${SED_BIN:-sed} -${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/*.yaml -${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml -${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/prometheus-config-validation/*.yaml -${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-prometheuscr/*.yaml +DEFAULT_TARGETALLOCATOR_IMG=${DEFAULT_TARGETALLOCATOR_IMG:-local/opentelemetry-operator-targetallocator:e2e} +DEFAULT_OPERATOROPAMPBRIDGE_IMG=${DEFAULT_OPERATOROPAMPBRIDGE_IMG:-local/opentelemetry-operator-opamp-bridge:e2e} +DEFAULT_OPERATOR_IMG=${DEFAULT_OPERATOR_IMG:-local/opentelemetry-operator:e2e} -${SED_BIN} -i "s#local/opentelemetry-operator:e2e#${OPERATOR_IMG}#g" tests/e2e-multi-instrumentation/*.yaml +${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/*.yaml +${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml +${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/prometheus-config-validation/*.yaml +${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-prometheuscr/*.yaml -${SED_BIN} -i "s#local/opentelemetry-operator-opamp-bridge:e2e#${OPERATOROPAMPBRIDGE_IMG}#g" tests/e2e-opampbridge/opampbridge/*.yaml \ No newline at end of file +${SED_BIN} -i "s#${DEFAULT_OPERATOR_IMG}#${OPERATOR_IMG}#g" tests/e2e-multi-instrumentation/*.yaml + +${SED_BIN} -i "s#${DEFAULT_OPERATOROPAMPBRIDGE_IMG}#${OPERATOROPAMPBRIDGE_IMG}#g" tests/e2e-opampbridge/opampbridge/*.yaml