diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0234dd0..7858687 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,52 +1,13 @@ name: release on: - workflow_dispatch: - inputs: - tag: - description: 'Tag to be released' - required: true - prerelease: - description: "Is the release a GA?" - required: false - default: false - type: boolean - -jobs: release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildk - uses: docker/setup-buildx-action@v1 + types: [published] - - name: Login to ghcr - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - push: true - tags: | - ghcr.io/scality/artifacts:${{ inputs.tag }} - - - name: Create Release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: Release ${{ github.event.inputs.tag }} - tag_name: ${{ github.event.inputs.tag }} - generate_release_notes: true - target_commitish: ${{ github.sha }} +jobs: + docker: + uses: scality/workflows/.github/workflows/docker-build.yaml@v1 + with: + name: artifacts + namespace: scality + tag: ${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile index 8a28077..8afc497 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,7 +84,7 @@ RUN make install # Install start scripts COPY full_listing_cache_update.sh /full_listing_cache_update.sh COPY github_auth_cache_cleaner.sh /github_auth_cache_cleaner.sh -COPY start.sh /start.sh +COPY start.sh stop.sh / # Install HTML browse includes COPY include/browse_header.html /etc/nginx/browse_header.html diff --git a/charts/artifacts/templates/autoscaler.yaml b/charts/artifacts/templates/autoscaler.yaml index 931c368..1a4c206 100644 --- a/charts/artifacts/templates/autoscaler.yaml +++ b/charts/artifacts/templates/autoscaler.yaml @@ -1,4 +1,4 @@ -apiVersion: autoscaling/v1 +apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: {{ template "fullname" $ }} @@ -13,4 +13,16 @@ spec: name: {{ template "fullname" $ }} minReplicas: {{ .Values.deployment.minReplicas }} maxReplicas: {{ .Values.deployment.maxReplicas }} -{{ toYaml .Values.deployment.autoscalerSpec | indent 2 }} + metrics: + - type: Resource + resource: + name: memory + target: + type: AverageValue + averageValue: {{ .Values.deployment.autoscalerSpec.memoryUtilization }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.deployment.autoscalerSpec.cpuUtilization }} diff --git a/charts/artifacts/templates/deployment.yaml b/charts/artifacts/templates/deployment.yaml index debe6d9..df23ab9 100644 --- a/charts/artifacts/templates/deployment.yaml +++ b/charts/artifacts/templates/deployment.yaml @@ -9,7 +9,6 @@ metadata: release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: - replicas: 1 selector: matchLabels: app: {{ template "fullname" $ }} @@ -19,6 +18,10 @@ spec: app: {{ template "fullname" $ }} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }} {{- if .Values.image.pullSecrets }} @@ -53,6 +56,10 @@ spec: path: /_healthz port: http {{ toYaml .Values.deployment.artifacts.livenessProbe | indent 10 }} + lifecycle: + preStop: + exec: + command: ["/stop.sh"] volumes: - name: cache emptyDir: {} diff --git a/charts/artifacts/values.yaml b/charts/artifacts/values.yaml index 2bcff40..da378e2 100644 --- a/charts/artifacts/values.yaml +++ b/charts/artifacts/values.yaml @@ -7,6 +7,8 @@ nameOverride: "artifacts" ## fullnameOverride allows to change the full name of resources fullnameOverride: +podAnnotations: {} + githubApiBasicAuth: ## githubApiUrl contains the api url to check the auth connection ## @@ -84,7 +86,8 @@ deployment: ## of criterias to meet to scale up and down. ## autoscalerSpec: - targetCPUUtilizationPercentage: 90 + cpuUtilization: 50 + memoryUtilization: 500Mi artifacts: ## Configure resource requests and limits diff --git a/stop.sh b/stop.sh new file mode 100755 index 0000000..2edb13a --- /dev/null +++ b/stop.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +echo "Stopping nginx..." +# Wait a bit before signaling the process to stop +sleep 5 +PID=$(cat /run/nginx.pid) +nginx -s quit + +echo "Waiting for nginx PID: ${PID} to stop..." +while [ -d /proc/$PID ]; do + sleep 0.1 +done diff --git a/tests/requirements.txt b/tests/requirements.txt index a86a3d7..362f342 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,3 @@ -pytest==7.4.2 -boto3==1.28.53 +pytest==7.4.4 +boto3==1.28.68 requests==2.31.0 -buildbot-worker==3.9.2