From 5771d0b73ece1ba1c7c728a6af134a6ea6631fb8 Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Mon, 19 Feb 2024 15:45:37 +0300 Subject: [PATCH 1/5] Use better defaults for poll interval and max reconcile rate Signed-off-by: Hasan Turken --- cmd/provider/main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/provider/main.go b/cmd/provider/main.go index 51850aa..39faed0 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -41,10 +41,6 @@ import ( template "github.com/crossplane-contrib/provider-helm/pkg/controller" ) -const ( - maxConcurrency = 10 -) - func main() { var ( app = kingpin.New(filepath.Base(os.Args[0]), "Helm support for Crossplane.").DefaultEnvars() @@ -53,7 +49,7 @@ func main() { timeout = app.Flag("timeout", "Controls how long helm commands may run before they are killed.").Default("10m").Duration() syncInterval = app.Flag("sync", "How often all resources will be double-checked for drift from the desired state.").Short('s').Default("1h").Duration() pollInterval = app.Flag("poll", "How often individual resources will be checked for drift from the desired state").Default("10m").Duration() - maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int() + maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("100").Int() ) kingpin.MustParse(app.Parse(os.Args[1:])) @@ -94,7 +90,7 @@ func main() { kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add Helm APIs to scheme") o := controller.Options{ Logger: log, - MaxConcurrentReconciles: maxConcurrency, + MaxConcurrentReconciles: *maxReconcileRate, PollInterval: *pollInterval, GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), Features: &feature.Flags{}, From ffdc25efb0727cc2e9c82b8a71fbb9edf37a712d Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Tue, 20 Feb 2024 14:23:33 +0300 Subject: [PATCH 2/5] Bump runtime to v1.14.4 Signed-off-by: Hasan Turken --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b96752d..5cc4041 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Azure/kubelogin v0.0.34 - github.com/crossplane/crossplane-runtime v1.14.3 + github.com/crossplane/crossplane-runtime v1.14.4 github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 github.com/google/go-cmp v0.6.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 49f4464..902b6a6 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/crossplane/crossplane-runtime v1.14.3 h1:YNGALph/UJTtQO+cJ9KGQ5NfALI5453PeE93Aqy9SWg= -github.com/crossplane/crossplane-runtime v1.14.3/go.mod h1:aOP+5W2wKpvthVs3pFNbVOe1jwrKYbJho0ThGNCVz9o= +github.com/crossplane/crossplane-runtime v1.14.4 h1:64zSZ75g1QXIMxR2zSQvz4+TTSq5qCUU5lmpiVovVKE= +github.com/crossplane/crossplane-runtime v1.14.4/go.mod h1:aOP+5W2wKpvthVs3pFNbVOe1jwrKYbJho0ThGNCVz9o= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= From ef80a209a9b71a2f809896f54d34226927341703 Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Tue, 20 Feb 2024 23:43:26 +0300 Subject: [PATCH 3/5] Bump build submodule to latest Signed-off-by: Hasan Turken --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 7233e36..75a9fe3 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 7233e36491dc8298d33f1feb1bf8c5056a960cac +Subproject commit 75a9fe3ae6b6de82c5f7ddc6a267617940f16b83 From ec239f6c10844ac9f502014f754f7a79c732f82f Mon Sep 17 00:00:00 2001 From: Hasan Turken Date: Tue, 20 Feb 2024 23:48:08 +0300 Subject: [PATCH 4/5] Use uptest for e2e testing Signed-off-by: Hasan Turken --- cluster/test/setup.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 cluster/test/setup.sh diff --git a/cluster/test/setup.sh b/cluster/test/setup.sh new file mode 100755 index 0000000..affa41b --- /dev/null +++ b/cluster/test/setup.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -aeuo pipefail + +echo "Running setup.sh" + +echo "Creating the provider config with cluster admin permissions in cluster..." +SA=$(${KUBECTL} -n crossplane-system get sa -o name | grep provider-helm | sed -e 's|serviceaccount\/|crossplane-system:|g') +${KUBECTL} create clusterrolebinding provider-helm-admin-binding --clusterrole cluster-admin --serviceaccount="${SA}" --dry-run=client -o yaml | ${KUBECTL} apply -f - + +cat < Date: Tue, 20 Feb 2024 23:48:22 +0300 Subject: [PATCH 5/5] Use uptest for e2e testing Signed-off-by: Hasan Turken --- Makefile | 28 ++- cluster/integration/integration_tests.sh | 213 ------------------ cluster/local/config/config.env | 1 - cluster/local/config/crossplane/.gitignore | 1 - cluster/local/config/crossplane/config.env | 8 - .../crossplane/value-overrides.yaml.tmpl | 3 - cluster/local/kind.yaml | 5 - 7 files changed, 20 insertions(+), 239 deletions(-) delete mode 100755 cluster/integration/integration_tests.sh delete mode 100644 cluster/local/config/config.env delete mode 100644 cluster/local/config/crossplane/.gitignore delete mode 100644 cluster/local/config/crossplane/config.env delete mode 100644 cluster/local/config/crossplane/value-overrides.yaml.tmpl delete mode 100644 cluster/local/kind.yaml diff --git a/Makefile b/Makefile index b25524d..2a8f2ea 100644 --- a/Makefile +++ b/Makefile @@ -86,14 +86,26 @@ cobertura: grep -v zz_generated.deepcopy | \ $(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml -# integration tests -e2e.run: test-integration - -# Run integration tests. -test-integration: $(KIND) $(KUBECTL) $(UP) $(HELM3) - @$(INFO) running integration tests using kind $(KIND_VERSION) - @KIND_NODE_IMAGE_TAG=${KIND_NODE_IMAGE_TAG} $(ROOT_DIR)/cluster/integration/integration_tests.sh || $(FAIL) - @$(OK) integration tests passed +# ==================================================================================== +# End to End Testing +CROSSPLANE_NAMESPACE = crossplane-system +-include build/makelib/local.xpkg.mk +-include build/makelib/controlplane.mk + +UPTEST_EXAMPLE_LIST ?= "examples/sample/release.yaml" +uptest: $(UPTEST) $(KUBECTL) $(KUTTL) + @$(INFO) running automated tests + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL) + @$(OK) running automated tests + +local-dev: controlplane.up +local-deploy: build controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME) + @$(INFO) running locally built provider + @$(KUBECTL) wait provider.pkg $(PROJECT_NAME) --for condition=Healthy --timeout 5m + @$(KUBECTL) -n crossplane-system wait --for=condition=Available deployment --all --timeout=5m + @$(OK) running locally built provider + +e2e: local-deploy uptest # Update the submodules, such as the common build scripts. submodules: diff --git a/cluster/integration/integration_tests.sh b/cluster/integration/integration_tests.sh deleted file mode 100755 index 523ff62..0000000 --- a/cluster/integration/integration_tests.sh +++ /dev/null @@ -1,213 +0,0 @@ -#!/usr/bin/env bash -set -e - -# setting up colors -BLU='\033[0;34m' -YLW='\033[0;33m' -GRN='\033[0;32m' -RED='\033[0;31m' -NOC='\033[0m' # No Color -echo_info(){ - printf "\n${BLU}%s${NOC}" "$1" -} -echo_step(){ - printf "\n${BLU}>>>>>>> %s${NOC}\n" "$1" -} -echo_sub_step(){ - printf "\n${BLU}>>> %s${NOC}\n" "$1" -} - -echo_step_completed(){ - printf "${GRN} [✔]${NOC}" -} - -echo_success(){ - printf "\n${GRN}%s${NOC}\n" "$1" -} -echo_warn(){ - printf "\n${YLW}%s${NOC}" "$1" -} -echo_error(){ - printf "\n${RED}%s${NOC}" "$1" - exit 1 -} - -# ------------------------------ -projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}")"/../.. && pwd )" - -# get the build environment variables from the special build.vars target in the main makefile -eval $(make --no-print-directory -C ${projectdir} build.vars) - -# ------------------------------ - -SAFEHOSTARCH="${SAFEHOSTARCH:-amd64}" -CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}" - -version_tag="$(cat ${projectdir}/_output/version)" -K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}" - -CROSSPLANE_NAMESPACE="crossplane-system" -PACKAGE_NAME="provider-helm" - -# cleanup on exit -if [ "$skipcleanup" != true ]; then - function cleanup { - echo_step "Cleaning up..." - export KUBECONFIG= - "${KIND}" delete cluster --name="${K8S_CLUSTER}" - } - - trap cleanup EXIT -fi - -# setup package cache -echo_step "setting up local package cache" -CACHE_PATH="${projectdir}/.work/inttest-package-cache" -mkdir -p "${CACHE_PATH}" -echo "created cache dir at ${CACHE_PATH}" -"${UP}" alpha xpkg xp-extract --from-xpkg "${OUTPUT_DIR}"/xpkg/"${HOSTOS}"_"${SAFEHOSTARCH}"/"${PACKAGE_NAME}"-"${VERSION}".xpkg -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz" - -# create kind cluster with extra mounts -KIND_NODE_IMAGE="kindest/node:${KIND_NODE_IMAGE_TAG}" -echo_step "creating k8s cluster using kind ${KIND_VERSION} and node image ${KIND_NODE_IMAGE}" -KIND_CONFIG="$( cat < $current ]]; then - echo_error "timeout of ${timeout}s has been reached" - fi - sleep $step; -done - -echo_success "Integration tests succeeded!" diff --git a/cluster/local/config/config.env b/cluster/local/config/config.env deleted file mode 100644 index c3c3e93..0000000 --- a/cluster/local/config/config.env +++ /dev/null @@ -1 +0,0 @@ -CROSSPLANE_VERSION="1.3.0" diff --git a/cluster/local/config/crossplane/.gitignore b/cluster/local/config/crossplane/.gitignore deleted file mode 100644 index e29f121..0000000 --- a/cluster/local/config/crossplane/.gitignore +++ /dev/null @@ -1 +0,0 @@ -value-overrides.yaml diff --git a/cluster/local/config/crossplane/config.env b/cluster/local/config/crossplane/config.env deleted file mode 100644 index 7c4275e..0000000 --- a/cluster/local/config/crossplane/config.env +++ /dev/null @@ -1,8 +0,0 @@ -REQUIRED_IMAGES+=("crossplane/crossplane:v${CROSSPLANE_VERSION}") - -HELM_REPOSITORY_NAME=crossplane-stable -HELM_REPOSITORY_URL=https://charts.crossplane.io/stable -HELM_CHART_VERSION="${CROSSPLANE_VERSION}" -HELM_RELEASE_NAME=crossplane -HELM_RELEASE_NAMESPACE=crossplane-system -HELM_REPOSITORY_FORCE_UPDATE=true \ No newline at end of file diff --git a/cluster/local/config/crossplane/value-overrides.yaml.tmpl b/cluster/local/config/crossplane/value-overrides.yaml.tmpl deleted file mode 100644 index 50c6f54..0000000 --- a/cluster/local/config/crossplane/value-overrides.yaml.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -image: - pullPolicy: Never - diff --git a/cluster/local/kind.yaml b/cluster/local/kind.yaml deleted file mode 100644 index e7992c7..0000000 --- a/cluster/local/kind.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: - - role: control-plane - image: kindest/node:v1.23.6 \ No newline at end of file