diff --git a/.circleci/config.yml b/.circleci/config.yml index dcbdb1f86..8c7107847 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,6 +83,9 @@ references: size: 10Gi rabbitmq-ha: replicaCount: 1 + image: + repository: bitnamilegacy/rabbitmq + tag: "3.8.5" ulimitNofiles: 32768 qa_automation_image: &qa_automation_image @@ -327,9 +330,10 @@ references: steps: - <<: *attach_workspace - <<: *doctl_authenticate - - codacy/run_skip_ssh: - cmd_name: Install Codacy - cmd: make -e -C .do/ deploy_to_doks_from_chartmuseum VERSION=$(cat .version) + - run: + name: Install Codacy + no_output_timeout: 30m + command: make -e -C .do/ deploy_to_doks_from_chartmuseum VERSION=$(cat .version) helm_push: &helm_push steps: @@ -347,6 +351,8 @@ references: helm dep build ./codacy echo "Adding 'https://charts.codacy.com/${CHANNEL}'" helm repo add --username "${CHARTS_REPO_USER}" --password "${CHARTS_REPO_PASS}" ${HELM_REPOSITORY} https://charts.codacy.com/${CHANNEL} + echo "Removing existing chart version from chart museum (if present)..." + curl -s -u "${CHARTS_REPO_USER}:${CHARTS_REPO_PASS}" -X DELETE "https://charts.codacy.com/${CHANNEL}/api/charts/codacy/$(cat .version)" || true helm push ./codacy ${HELM_REPOSITORY} - <<: *persist_to_workspace @@ -507,6 +513,47 @@ jobs: command: cat .version - <<: *persist_to_workspace + tag_version_ssh: + <<: *default_doks_image + parameters: + version: + type: string + default: "" + force: + type: boolean + default: false + steps: + - <<: *attach_workspace + - add_ssh_keys: + fingerprints: + - "df:83:d7:c7:d5:79:06:c2:3b:d1:fd:e2:a3:d1:12:c5" + - run: + name: Setup SSH + command: ssh-keyscan github.com >> ~/.ssh/known_hosts + - run: + name: Set Git Config + command: | + git config --global user.email "circleci@codacy.com" + git config --global user.name "CircleCI" + git remote set-url origin git@github.com:codacy/chart.git + - run: + name: Fetch Tags + command: git fetch --tags + - run: + name: Tag + command: | + TAG="<< parameters.version >>" + if [ -z "$TAG" ]; then + TAG=$(cat .version) + fi + if [ "<< parameters.force >>" = "true" ]; then + git tag -f "$TAG" + git push origin -f "refs/tags/$TAG" + else + git tag "$TAG" + git push origin "refs/tags/$TAG" + fi + build_docs: docker: - image: circleci/python:3.8 @@ -806,7 +853,7 @@ workflows: requires: - manual_qa_hold - manual_solutions_eng_hold - - codacy/tag_version: + - tag_version_ssh: name: tag_version context: CodacyDO requires: @@ -820,7 +867,7 @@ workflows: target_charts_repo_url: "https://charts.codacy.com/stable" requires: - tag_version - - codacy/tag_version: + - tag_version_ssh: name: tag_version_latest context: CodacyDO version: latest diff --git a/.do/Makefile b/.do/Makefile index 6ecda9cf9..e01485530 100644 --- a/.do/Makefile +++ b/.do/Makefile @@ -13,7 +13,7 @@ define call_helm_install eval "extra_args=($$HELM_INSTALL_EXTRA_FLAGS)"; \ helm upgrade --install ${1} ${3} \ --atomic \ - --timeout=900s \ + --timeout=1500s \ -f ../codacy/values-production.yaml \ -f values.yaml \ --namespace ${2} \ @@ -85,10 +85,17 @@ update_ingress_values: deploy_to_doks_infrastructure: set_cluster_context update_dependencies helm_install_infrastructure .PHONY: deploy_to_doks_from_local_dir -deploy_to_doks_from_local_dir: set_cluster_context update_dependencies helm_install_from_local_dir +deploy_to_doks_from_local_dir: set_cluster_context update_dependencies clean_jobs helm_install_from_local_dir + +.PHONY: clean_jobs +clean_jobs: + -kubectl delete jobs -l app.kubernetes.io/instance=${RELEASE_NAME} --namespace ${NAMESPACE} --ignore-not-found=true + -kubectl delete jobs -l release=${RELEASE_NAME} --namespace ${NAMESPACE} --ignore-not-found=true .PHONY: deploy_to_doks_from_chartmuseum -deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos helm_install_from_chart_museum +deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos + -$(MAKE) clean_jobs + $(MAKE) helm_install_from_chart_museum || ($(MAKE) clean_jobs && $(MAKE) helm_install_from_chart_museum) .PHONY: set_cluster_context set_cluster_context: diff --git a/Makefile b/Makefile index e3f3dfe57..54ef0e9a1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ .PHONY: setup_helm_repos setup_helm_repos: # Add legacy Bitnami snapshot repo used by requirements.yaml (apiVersion v1) + helm repo add bitnami-pre-2022 https://raw.githubusercontent.com/bitnami/charts/defb094c658024e4aa8245622dab202874880cbc/bitnami # Github tag before bitnami truncated the index. Old link didn't work anymore helm repo add stable https://charts.helm.sh/stable helm repo add codacy-stable https://charts.codacy.com/stable helm repo add codacy-unstable https://charts.codacy.com/unstable diff --git a/codacy/requirements.lock b/codacy/requirements.lock new file mode 100644 index 000000000..3c802448c --- /dev/null +++ b/codacy/requirements.lock @@ -0,0 +1,48 @@ +dependencies: +- name: minio + repository: https://charts.helm.sh/stable + version: 5.0.33 +- name: rabbitmq + repository: https://raw.githubusercontent.com/bitnami/charts/defb094c658024e4aa8245622dab202874880cbc/bitnami + version: 7.5.7 +- name: postgresql + repository: https://raw.githubusercontent.com/bitnami/charts/defb094c658024e4aa8245622dab202874880cbc/bitnami + version: 8.6.4 +- name: log-router + repository: https://charts.codacy.com/external + version: 0.6.4 +- name: codacy-ingress-sh + repository: https://charts.codacy.com/stable + version: 0.2.3 +- name: portal-sh + repository: https://charts.codacy.com/stable + version: 1.1.8 +- name: ragnaros-sh + repository: https://charts.codacy.com/stable + version: 2.0.7 +- name: remote-provider-service-sh + repository: https://charts.codacy.com/stable + version: 1.1.4 +- name: listener-sh + repository: https://charts.codacy.com/stable + version: 1.1.10 +- name: engine-sh + repository: https://charts.codacy.com/stable + version: 1.2.1 +- name: codacy-tools-sh + repository: https://charts.codacy.com/stable + version: 1.2.21 +- name: codacy-api-sh + repository: https://charts.codacy.com/stable + version: 1.2.9 +- name: worker-manager-sh + repository: https://charts.codacy.com/stable + version: 2.0.2 +- name: crow-sh + repository: https://charts.codacy.com/stable + version: 1.0.6 +- name: codacy-spa-sh + repository: https://charts.codacy.com/stable + version: 1.2.4 +digest: sha256:d19e971e5160470800251d2660f063c96c00de20180c13c2f7c7e90375c52862 +generated: "2026-08-28T14:29:21.804571894+01:00" diff --git a/codacy/requirements.yaml b/codacy/requirements.yaml index eb6daa185..4c61ebaff 100644 --- a/codacy/requirements.yaml +++ b/codacy/requirements.yaml @@ -7,7 +7,7 @@ dependencies: - name: rabbitmq version: 7.5.7 - repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami + repository: https://raw.githubusercontent.com/bitnami/charts/defb094c658024e4aa8245622dab202874880cbc/bitnami condition: global.rabbitmq.create alias: rabbitmq-ha diff --git a/codacy/templates/fluentd/lifecycle-police-job.yaml b/codacy/templates/fluentd/lifecycle-police-job.yaml index 68e5167fc..5f4621a44 100644 --- a/codacy/templates/fluentd/lifecycle-police-job.yaml +++ b/codacy/templates/fluentd/lifecycle-police-job.yaml @@ -12,9 +12,9 @@ metadata: # Minio create bucket hook doesn't define any hook weight, # any positive value will ensure that the bucket is created before this "helm.sh/hook-weight": "10" - "helm.sh/hook-delete-policy": hook-succeeded + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: - backoffLimit: 100 + backoffLimit: 0 template: metadata: name: "{{ .Release.Name }}" @@ -30,14 +30,37 @@ spec: value: "{{ .Values.global.minio.accessKey }}" - name: AWS_SECRET_ACCESS_KEY value: "{{ .Values.global.minio.secretKey }}" - command: ["aws"] + command: ["/bin/sh", "-c"] args: - - s3api - - put-bucket-lifecycle-configuration - - --bucket - - {{ .Values.fluentdoperator.bucketName }} - - --endpoint-url - - http://{{ .Values.global.minio.location }}:{{ .Values.global.minio.port }} - - --lifecycle-configuration - - '{"Rules":[{"Expiration":{"Days": {{ .Values.fluentdoperator.expirationDays }} },"ID":"Delete old logs","Status":"Enabled"}]}' + - | + ENDPOINT="http://{{ .Values.global.minio.location }}:{{ .Values.global.minio.port }}" + BUCKET="{{ .Values.fluentdoperator.bucketName }}" + LIFECYCLE='{"Rules":[{"Expiration":{"Days": {{ .Values.fluentdoperator.expirationDays }} },"Filter":{},"ID":"Delete old logs","Status":"Enabled"}]}' + MAX_WAIT=1200 + ELAPSED=0 + echo "Waiting for MinIO bucket ${BUCKET} at ${ENDPOINT}..." + until aws s3api head-bucket --bucket "${BUCKET}" --endpoint-url "${ENDPOINT}" > /dev/null 2>&1; do + if [ "${ELAPSED}" -ge "${MAX_WAIT}" ]; then + echo "Timed out waiting for MinIO bucket after ${MAX_WAIT}s" + exit 1 + fi + echo "Bucket not ready yet (${ELAPSED}s elapsed), retrying in 10s..." + sleep 10 + ELAPSED=$((ELAPSED + 10)) + done + echo "MinIO bucket ${BUCKET} is ready. Setting lifecycle configuration..." + RETRY=0 + until aws s3api put-bucket-lifecycle-configuration \ + --bucket "${BUCKET}" \ + --endpoint-url "${ENDPOINT}" \ + --lifecycle-configuration "${LIFECYCLE}"; do + RETRY=$((RETRY + 1)) + if [ "${RETRY}" -ge 5 ]; then + echo "Failed to set lifecycle configuration after ${RETRY} attempts" + exit 1 + fi + echo "Lifecycle config failed, retrying in 10s (attempt ${RETRY}/5)..." + sleep 10 + done + echo "Lifecycle configuration set successfully." {{ end }} diff --git a/codacy/values-microk8s.yaml b/codacy/values-microk8s.yaml index 76505a1f4..1e6435e6b 100644 --- a/codacy/values-microk8s.yaml +++ b/codacy/values-microk8s.yaml @@ -57,7 +57,7 @@ rabbitmq-ha: replicaCount: 1 image: repository: bitnamilegacy/rabbitmq - tag: "3.8.35-debian-11-r5" + tag: "3.8.5" resources: limits: cpu: 0.5 diff --git a/codacy/values-production.yaml b/codacy/values-production.yaml index bddaed449..5d65214b2 100644 --- a/codacy/values-production.yaml +++ b/codacy/values-production.yaml @@ -313,6 +313,9 @@ codacy-spa: rabbitmq-ha: replicaCount: 1 + image: + repository: bitnamilegacy/rabbitmq + tag: "3.8.5" rabbitmqErlangCookie: <--- erlang-cookie ---> # Generate one with `openssl rand -base64 32 | tr -dc 'a-zA-Z0-9'` persistentVolume: enabled: true diff --git a/codacy/values.yaml b/codacy/values.yaml index 343286ff5..cad01db2f 100644 --- a/codacy/values.yaml +++ b/codacy/values.yaml @@ -28,9 +28,9 @@ global: # Trial license. Valid for 4 users until the end of 2030 license: "lV5QUFrZhlibdCP/MN8pZo76B3jhPeL/RAk4E2AL2WZlGI8Vno/LfvAwnSHm26uY817I3qvEjfhIZFCkDi8R6PngiB+UiT+h8W0Blica8Sp+d5ngnh9HuhTG6xAIf7gAQxyJpn3boV87CKTO+5nHYSeJccMd+s8esMxoS84Z2xI=" installation: - version: development + version: v17.0.0-RC-0 documentation: - version: development + version: v17.0 # github: # enabled: "false" @@ -101,7 +101,7 @@ global: workerManager: workers: config: - imageVersion: stable + imageVersion: sh-1.2.1 javaOpts: '-XX:MinRAMPercentage=50.0 -XX:MaxRAMPercentage=90.0' inactivityTimeout: 30 @@ -318,10 +318,10 @@ rabbitmq-ha: fullnameOverride: codacy-rabbitmq-ha global: imagePullSecrets: - - docker-credentials + - docker-credentials image: repository: bitnamilegacy/rabbitmq - tag: "3.8.35-debian-11-r5" + tag: "3.8.5" auth: username: rabbitmq-codacy password: CHANGEME