Skip to content

Commit 5566a01

Browse files
authored
Improve developer experience by minimizing local changes (#2421)
* Improve developer experience Signed-off-by: Pavol Loffay <[email protected]> * Fix Signed-off-by: Pavol Loffay <[email protected]> * handle e2e tests Signed-off-by: Pavol Loffay <[email protected]> * Fix Signed-off-by: Pavol Loffay <[email protected]> --------- Signed-off-by: Pavol Loffay <[email protected]>
1 parent c3b3cc2 commit 5566a01

5 files changed

+54
-19
lines changed

CONTRIBUTING.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ git commit -sam "Add feature X"
2020
gh pr create
2121
```
2222

23+
#### Make changes to the project manifests
24+
25+
The following command should be run to make sure the project manifests are up-to-date:
26+
27+
```bash
28+
make generate manifests bundle api-docs reset
29+
```
30+
31+
The local changes after running the command should be added to the pull request:
32+
33+
The following `make` target is run on CI to verify the project structure:
34+
35+
```bash
36+
make ensure-generate-is-noop
37+
```
38+
2339
### Pre-requisites
2440
* Install [Go](https://golang.org/doc/install).
2541
* Install [Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/).
@@ -37,7 +53,7 @@ Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/
3753

3854
Build the manifests, install the CRD and run the operator as a local process:
3955
```bash
40-
make bundle install run
56+
make install run
4157
```
4258

4359
### Deployment with webhooks
@@ -58,16 +74,16 @@ The environment variable `CERTMANAGER_VERSION` can be used to override the cert-
5874
CERTMANAGER_VERSION=1.60 make cert-manager
5975
```
6076

61-
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:
77+
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:
6278

6379
* `IMG_PREFIX`, to override the registry, namespace and image name
64-
* `USER`, to override the namespace
80+
* `DOCKER_USER`, to override the namespace
6581
* `IMG_REPO`, to override the repository (`opentelemetry-operator`)
6682
* `VERSION`, to override only the version part
6783
* `IMG`, to override the entire image specification
6884

6985
```bash
70-
IMG=docker.io/${USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate bundle container container-push deploy
86+
IMG=docker.io/${DOCKER_USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate container container-push deploy
7187
```
7288

7389
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
108124

109125
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.
110126

127+
To evert the changes made by the `make prepare-e2e` run `make reset`.
128+
111129
### OpenShift End to End tests
112130
To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster.
113131

@@ -188,7 +206,7 @@ BUNDLE_IMG=docker.io/${USER}/opentelemetry-operator-bundle:latest IMG=docker.io/
188206
### Install the operator
189207

190208
```bash
191-
operator-sdk run bundle docker.io/${USER}/opentelemetry-operator-bundle:latest
209+
operator-sdk run bundle docker.io/${DOCKER_USER}/opentelemetry-operator-bundle:latest
192210
```
193211

194212
### Uninstall the operator

Makefile

+14-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ OPERATOR_LDFLAGS ?= -X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.build
1818
ARCH ?= $(shell go env GOARCH)
1919

2020
# Image URL to use all building/pushing image targets
21-
IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator
21+
DOCKER_USER ?= open-telemetry
22+
IMG_PREFIX ?= ghcr.io/${DOCKER_USER}/opentelemetry-operator
2223
IMG_REPO ?= opentelemetry-operator
2324
IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION}
2425
BUNDLE_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-bundle:${VERSION}
@@ -82,7 +83,7 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)
8283

8384
.PHONY: ensure-generate-is-noop
8485
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION)
85-
ensure-generate-is-noop: USER=open-telemetry
86+
ensure-generate-is-noop: DOCKER_USER=open-telemetry
8687
ensure-generate-is-noop: set-image-controller generate bundle
8788
@# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check
8889
@git restore config/manager/kustomization.yaml
@@ -178,7 +179,7 @@ lint: golangci-lint
178179

179180
# Generate code
180181
.PHONY: generate
181-
generate: controller-gen api-docs
182+
generate: controller-gen
182183
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
183184

184185
# end-to-tests
@@ -442,6 +443,16 @@ bundle: kustomize operator-sdk manifests set-image-controller
442443
$(OPERATOR_SDK) bundle validate ./bundle
443444
./hack/ignore-createdAt-bundle.sh
444445

446+
.PHONY: reset
447+
reset: kustomize operator-sdk manifests
448+
$(MAKE) VERSION=${OPERATOR_VERSION} set-image-controller
449+
$(OPERATOR_SDK) generate kustomize manifests -q
450+
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version ${OPERATOR_VERSION} $(BUNDLE_METADATA_OPTS)
451+
$(OPERATOR_SDK) bundle validate ./bundle
452+
./hack/ignore-createdAt-bundle.sh
453+
git checkout config/manager/kustomization.yaml
454+
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
455+
445456
# Build the bundle image, used only for local dev purposes
446457
.PHONY: bundle-build
447458
bundle-build:

RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Steps to release a new version of the OpenTelemetry Operator:
44

55
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.
66
2. Change the `autoinstrumentation-*` versions in `versions.txt` as per the latest supported versions in `autoinstrumentation/`.
7-
3. Run `make bundle USER=open-telemetry VERSION=0.38.0`, using the version that will be released.
7+
3. Run `make bundle DOCKER_USER=open-telemetry VERSION=0.38.0`, using the version that will be released.
88
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.
99
5. Add the changes to the changelog. Manually add versions of all operator components.
1010
6. Check the OpenTelemetry Collector's changelog and ensure migration steps are present in `pkg/collector/upgrade`

hack/ignore-createdAt-bundle.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
# This code checks if only the createdAt field. If is the only change, it is ignored.
66
# Else, it will do nothing.
77
# https://github.com/operator-framework/operator-sdk/issues/6285#issuecomment-1415350333
8-
git diff --quiet -I'^ createdAt: ' bundle
9-
if ((! $?)) ; then
10-
git checkout bundle
11-
fi
8+
git diff --quiet -I'^ createdAt: ' bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml
9+
ret=$?
10+
changes=$(git diff --numstat bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml)
11+
if [ $ret = 0 ] && [ "$changes" = '1 1 bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml' ] ; then
12+
git checkout bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml
13+
fi

hack/modify-test-images.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
SED_BIN=${SED_BIN:-sed}
44

5-
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/*.yaml
6-
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml
7-
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/prometheus-config-validation/*.yaml
8-
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-prometheuscr/*.yaml
5+
DEFAULT_TARGETALLOCATOR_IMG=${DEFAULT_TARGETALLOCATOR_IMG:-local/opentelemetry-operator-targetallocator:e2e}
6+
DEFAULT_OPERATOROPAMPBRIDGE_IMG=${DEFAULT_OPERATOROPAMPBRIDGE_IMG:-local/opentelemetry-operator-opamp-bridge:e2e}
7+
DEFAULT_OPERATOR_IMG=${DEFAULT_OPERATOR_IMG:-local/opentelemetry-operator:e2e}
98

10-
${SED_BIN} -i "s#local/opentelemetry-operator:e2e#${OPERATOR_IMG}#g" tests/e2e-multi-instrumentation/*.yaml
9+
${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/*.yaml
10+
${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml
11+
${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/prometheus-config-validation/*.yaml
12+
${SED_BIN} -i "s#${DEFAULT_TARGETALLOCATOR_IMG}#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-prometheuscr/*.yaml
1113

12-
${SED_BIN} -i "s#local/opentelemetry-operator-opamp-bridge:e2e#${OPERATOROPAMPBRIDGE_IMG}#g" tests/e2e-opampbridge/opampbridge/*.yaml
14+
${SED_BIN} -i "s#${DEFAULT_OPERATOR_IMG}#${OPERATOR_IMG}#g" tests/e2e-multi-instrumentation/*.yaml
15+
16+
${SED_BIN} -i "s#${DEFAULT_OPERATOROPAMPBRIDGE_IMG}#${OPERATOROPAMPBRIDGE_IMG}#g" tests/e2e-opampbridge/opampbridge/*.yaml

0 commit comments

Comments
 (0)