From 2904494ccdf67c936c77716a246be01ce5991556 Mon Sep 17 00:00:00 2001 From: Friedrich Date: Tue, 16 Jan 2024 16:31:06 +0100 Subject: [PATCH] Code cleanup (#399) * rename variables * rename make target The name `install-nats-module` is a little misleading, since this target does not work with modules, but with the CR and CRD of the NATS-manager. * remove unused make targets A lot of make targets have become obsolete since a release of eventing-manager or nats-manger does no longer generate a module-template. For that reason, all targets that work with modules can be removed. * remove module specific secitons in the readme * revert changes for make target name * make variables to consts --- README.md | 71 ---------------------------------------- hack/ci/Makefile | 61 ---------------------------------- testing/eventmeshmock.go | 9 ++--- 3 files changed, 5 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 96f8320d..2799d6e3 100644 --- a/README.md +++ b/README.md @@ -167,77 +167,6 @@ To delete the CRDs from the cluster: make uninstall ``` -### Deploy Eventing Manager module with [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main) - -1. Deploy the Lifecycle Manager to the Kubernetes cluster: - - ```shell - kyma alpha deploy - ``` - -2. Apply the Eventing module template to the Kubernetes cluster: - - > **NOTE:** You can get the latest released [module template](https://github.com/kyma-project/eventing-manager/releases/latest/download/module-template.yaml), or you can use the module template from the artifacts of `eventing-module-build` job either from the `main` branch or from your pull request. - - ```sh - kubectl apply -f module-template.yaml - ``` - -3. Enable the Eventing module: - - ```sh - kyma alpha enable module eventing -c fast -n kyma-system - ``` - -4. If you want to verify whether your Eventing module is deployed properly, perform the following checks: - - - Check if the Eventing resource has the `ready` state: - - ```shell - kubectl get -n kyma-system eventing - ``` - - - Check if the Kyma resource has the ready state: - - ```shell - kubectl get -n kyma-system kyma - ``` - -### Uninstall Eventing Manager module with [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main) - -1. Delete Eventing custom resource (CR) from the Kubernetes cluster (if exists): - - ```sh - kubectl delete -n kyma-system eventing eventing - ``` - -2. Disable the Eventing module: - - ```sh - kyma alpha disable module eventing - ``` - -3. Delete the Eventing module template: - - ```sh - kubectl get moduletemplates -A - kubectl delete moduletemplate -n - ``` - -4. Check whether your Eventing module is uninstalled properly: - - - Make sure that the Eventing CR does not exist. If it exists, check its status: - - ```shell - kubectl get -n kyma-system eventing eventing -o yaml - ``` - - - Check if the Kyma resource has the `ready` state: - - ```shell - kubectl get -n kyma-system kyma - ``` - ## End-to-End Tests See [hack/e2e/README.md](hack/e2e/README.md) diff --git a/hack/ci/Makefile b/hack/ci/Makefile index e4385d70..4aed26f8 100644 --- a/hack/ci/Makefile +++ b/hack/ci/Makefile @@ -3,75 +3,14 @@ KYMA_CLI ?= "${PROJECT_ROOT}/${KYMA}" CLUSTER_NAME ?= kyma REGISTRY_PORT ?= 5001 -ifndef MODULE_VERSION - include ${PROJECT_ROOT}/.version -endif - -ifndef MODULE_SHA - MODULE_SHA = ${shell git rev-parse --short HEAD} -endif - -.PHONY: module-build -module-build: ## Build the Module, push it to a registry and print it based on the commit hash. - @make -C ${PROJECT_ROOT} module-build \ - IMG=${IMG} \ - MODULE_REGISTRY=${MODULE_REGISTRY} \ - MODULE_VERSION=${MODULE_VERSION}-${MODULE_SHA} - cp -f ${PROJECT_ROOT}/module-template.yaml ${ARTIFACTS}/module-template.yaml - @echo "Added template to job artifacts: ${ARTIFACTS}/module-template.yaml" - @echo "\n~~~~~~~~~~~~BEGINNING OF MODULE TEMPLATE~~~~~~~~~~~~~~" - @cat ${ARTIFACTS}/module-template.yaml - @echo "\n~~~~~~~~~~~~~~~END OF MODULE TEMPLATE~~~~~~~~~~~~~~~~" - -.PHONY: download-module-template -download-module-template: ## Downloads the module-template from the module-build prow job. - export PROJECT_ROOT="${PROJECT_ROOT}" \ - && ../get_module_template_from_build_job.sh - -.PHONY: install-latest-module-template-fast -install-latest-module-template-fast: ## Downloads and applies the latest released module-template from fast channel. - kubectl apply -f https://github.com/kyma-project/eventing-manager/releases/latest/download/module-template.yaml - .PHONY: create-kyma-system-ns create-kyma-system-ns: ## Create kyma-system namespace. kubectl create ns kyma-system -.PHONY: install-module-template -install-module-template: ## Apply Eventing moduletemplate. - kubectl apply -f ${PROJECT_ROOT}/module-template.yaml - -.PHONY: enable-module-without-default-cr -enable-module-without-default-cr: ## Enable Eventing module without creating default Eventing CR. - "${KYMA_CLI}" alpha enable module eventing -c fast -n kyma-system -p Ignore - -.PHONY: install-lifecycle-manager -install-lifecycle-manager: ## Deploys lifecycle-manager. - "${KYMA_CLI}" alpha deploy \ - --ci \ - --force-conflicts - .PHONY: create-k3d create-k3d: ## Create k3d with kyma CRDs. "${KYMA_CLI}" provision k3d -p 8081:80@loadbalancer -p 8443:443@loadbalancer --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} --ci -.PHONY: install-lifecycle-manager -install-lifecycle-manager: ## Deploys lifecycle-manager. - "${KYMA_CLI}" alpha deploy \ - --ci \ - --force-conflicts - -.PHONY: install-latest-nats-module-template-fast -install-latest-nats-module-template-fast: ## Downloads and applies the latest nats-manager released module-template from fast channel. - kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/module-template.yaml - -.PHONY: enable-nats-module -enable-nats-module: - "${KYMA_CLI}" alpha enable module nats -c fast -f --ci -n kyma-system - -.PHONY: get-nats-via-lifecycle-manager -get-nats-via-lifecycle-manager: install-lifecycle-manager install-latest-nats-module-template-fast enable-nats-module - ./check-k8s-resource-is-ready.sh 180 nats kyma-system - .PHONY: install-nats-module install-nats-module: kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml diff --git a/testing/eventmeshmock.go b/testing/eventmeshmock.go index 134805c9..069ad5aa 100644 --- a/testing/eventmeshmock.go +++ b/testing/eventmeshmock.go @@ -26,6 +26,9 @@ import ( const ( TokenURLPath = "/auth" MessagingURLPath = "/messaging" + + fewAttempts = 2 + smallInterval = 3 ) // EventMeshMock implements a programmable mock for EventMesh. @@ -272,10 +275,8 @@ func (m *EventMeshMock) handleMessaging() func(w http.ResponseWriter, r *http.Re if err == nil { break } - two := 2 - three := 3 - if i < two { // Don't sleep after the last attempt - time.Sleep(time.Duration(three) * time.Second) + if i < fewAttempts { // Don't sleep after the last attempt. + time.Sleep(time.Duration(smallInterval) * time.Second) } else { panic(err) }