Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBC22-2085: Backup Media and improve log handling #417

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,27 @@ jobs:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}

build-logprocessing:
build-openshiftjobs:
runs-on: ubuntu-latest
name: Build & Push Docker Log Processing Image
name: Build & Push Docker OpenShift Jobs Image
environment:
name: dev

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Build Log Processing
- name: Build OpenShift Jobs
id: build_image
uses: redhat-actions/buildah-build@v2
with:
context: .
layers: true
image: drivebc-logprocessing
image: drivebc-openshiftjobs
tags: latest latest-dev ${{ github.sha }}
labels: |
app=drivebc
containerfiles: ./compose/logprocessing/DockerFile
containerfiles: ./compose/openshiftjobs/DockerFile

- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
Expand All @@ -138,7 +138,7 @@ jobs:
password: ${{ env.REGISTRY_PASSWORD }}

versionUpdate:
needs: [build-static, build-backend, build-redis, build-logprocessing]
needs: [build-static, build-backend, build-redis, build-openshiftjobs]
runs-on: ubuntu-latest
name: Deploy Latest Images
environment:
Expand All @@ -159,4 +159,4 @@ jobs:
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade dev-drivebc -f ./infrastructure/main/values-dev.yaml ./infrastructure/main --set django.image.tag="${{ github.sha }}" --set redis.image.tag="${{ github.sha }}" --set static.image.tag="${{ github.sha }}" --set tasks.image.tag="${{ github.sha }}" --set logprocessing.image.tag="${{ github.sha }}"
helm upgrade dev-drivebc -f ./infrastructure/main/values-dev.yaml ./infrastructure/main --set django.image.tag="${{ github.sha }}" --set redis.image.tag="${{ github.sha }}" --set static.image.tag="${{ github.sha }}" --set tasks.image.tag="${{ github.sha }}" --set openshiftjobs.image.tag="${{ github.sha }}"
6 changes: 3 additions & 3 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ jobs:
tags: |
latest-prod

- name: Add latest-uat tag to logprocessing image
- name: Add latest-uat tag to openshiftjobs image
uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: bcgov/drivebc-logprocessing
repository: bcgov/drivebc-openshiftjobs
target: ${{ needs.deploy-pre.outputs.tag }}
tags: |
latest-prod
Expand All @@ -90,4 +90,4 @@ jobs:
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade prod-drivebc -f ./infrastructure/main/values-prod.yaml ./infrastructure/main --set django.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set redis.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set static.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.deploy-pre.outputs.tag }}"
helm upgrade prod-drivebc -f ./infrastructure/main/values-prod.yaml ./infrastructure/main --set django.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set redis.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set static.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set openshiftjobs.image.tag="${{ needs.deploy-pre.outputs.tag }}"
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,25 @@ jobs:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}

build-logprocessing:
build-openshiftjobs:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Log-Processing Image
name: Build & Push Docker OpenShift Jobs Image
environment: test

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Build Log-Processing
- name: Build OpenShift Jobs
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: drivebc-logprocessing
image: drivebc-openshiftjobs
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/logprocessing/DockerFile
containerfiles: ./compose/openshiftjobs/DockerFile

- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
Expand All @@ -182,7 +182,7 @@ jobs:
password: ${{ env.REGISTRY_PASSWORD }}

versionUpdate:
needs: [build-pre, build-static, build-backend, build-redis, build-logprocessing]
needs: [build-pre, build-static, build-backend, build-redis, build-openshiftjobs]
runs-on: ubuntu-latest
name: Deploy Latest Images
environment:
Expand All @@ -205,4 +205,4 @@ jobs:
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade test-drivebc -f ./infrastructure/main/values-test.yaml ./infrastructure/main --set django.image.tag="${{ needs.build-pre.outputs.tag }}" --set redis.image.tag="${{ needs.build-pre.outputs.tag }}" --set static.image.tag="${{ needs.build-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.build-pre.outputs.tag }}" --set logprocessing.image.tag="${{ needs.build-pre.outputs.tag }}"
helm upgrade test-drivebc -f ./infrastructure/main/values-test.yaml ./infrastructure/main --set django.image.tag="${{ needs.build-pre.outputs.tag }}" --set redis.image.tag="${{ needs.build-pre.outputs.tag }}" --set static.image.tag="${{ needs.build-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.build-pre.outputs.tag }}" --set openshiftjobs.image.tag="${{ needs.build-pre.outputs.tag }}"
14 changes: 7 additions & 7 deletions .github/workflows/test_manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,25 @@ jobs:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}

build-logprocessing:
build-openshiftjobs:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Log-Processing Image
name: Build & Push Docker OpenShift Jobs Image
environment: test

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Build Log-Processing
- name: Build OpenShift Jobs
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: drivebc-logprocessing
image: drivebc-openshiftjobs
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/logprocessing/DockerFile
containerfiles: ./compose/openshiftjobs/DockerFile

- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
Expand All @@ -161,7 +161,7 @@ jobs:
password: ${{ env.REGISTRY_PASSWORD }}

versionUpdate:
needs: [build-pre, build-static, build-backend, build-redis, build-logprocessing]
needs: [build-pre, build-static, build-backend, build-redis, build-openshiftjobs]
runs-on: ubuntu-latest
name: Deploy Latest Images
environment:
Expand All @@ -184,4 +184,4 @@ jobs:
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade test-drivebc -f ./infrastructure/main/values-test.yaml ./infrastructure/main --set django.image.tag="${{ needs.build-pre.outputs.tag }}" --set redis.image.tag="${{ needs.build-pre.outputs.tag }}" --set static.image.tag="${{ needs.build-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.build-pre.outputs.tag }}" --set logprocessing.image.tag="${{ needs.build-pre.outputs.tag }}"
helm upgrade test-drivebc -f ./infrastructure/main/values-test.yaml ./infrastructure/main --set django.image.tag="${{ needs.build-pre.outputs.tag }}" --set redis.image.tag="${{ needs.build-pre.outputs.tag }}" --set static.image.tag="${{ needs.build-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.build-pre.outputs.tag }}" --set openshiftjobs.image.tag="${{ needs.build-pre.outputs.tag }}"
6 changes: 3 additions & 3 deletions .github/workflows/uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ jobs:
tags: |
latest-uat

- name: Add latest-uat tag to logprocessing image
- name: Add latest-uat tag to openshiftjobs image
uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: bcgov/drivebc-logprocessing
repository: bcgov/drivebc-openshiftjobs
target: ${{ needs.deploy-pre.outputs.tag }}
tags: |
latest-uat
Expand All @@ -92,4 +92,4 @@ jobs:
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade uat-drivebc -f ./infrastructure/main/values-uat.yaml ./infrastructure/main --set django.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set redis.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set static.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set logprocessing.image.tag="${{ needs.deploy-pre.outputs.tag }}"
helm upgrade uat-drivebc -f ./infrastructure/main/values-uat.yaml ./infrastructure/main --set django.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set redis.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set static.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set openshiftjobs.image.tag="${{ needs.deploy-pre.outputs.tag }}"
16 changes: 0 additions & 16 deletions compose/logprocessing/DockerFile

This file was deleted.

86 changes: 0 additions & 86 deletions compose/logprocessing/entrypoint.sh

This file was deleted.

23 changes: 23 additions & 0 deletions compose/openshiftjobs/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3
RUN apk update && apk upgrade
#Need goaccess 1.92 for a timezone fix. Once that version is in the regular branch, we can pull it from there.
RUN apk add goaccess --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main

RUN apk add --no-cache \
aws-cli \
bash \
coreutils \
tzdata

COPY ./compose/openshiftjobs/entrypoint.sh /
COPY ./compose/openshiftjobs/scripts/analyzeexportlogs.sh /scripts/
COPY ./compose/openshiftjobs/scripts/backupmediapvc.sh /scripts/
COPY ./compose/openshiftjobs/scripts/ziplogs.sh /scripts/

RUN sed -i 's/\r$//g' /entrypoint.sh && chmod +x /entrypoint.sh
RUN sed -i 's/\r$//g' /scripts/analyzeexportlogs.sh && chmod +x /scripts/analyzeexportlogs.sh
RUN sed -i 's/\r$//g' /scripts/backupmediapvc.sh && chmod +x /scripts/backupmediapvc.sh
RUN sed -i 's/\r$//g' /scripts/ziplogs.sh && chmod +x /scripts/ziplogs.sh


ENTRYPOINT ["/entrypoint.sh"]
28 changes: 28 additions & 0 deletions compose/openshiftjobs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Check the number of arguments
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <script_name> [args...]"
exit 1
fi

# Determine which script to run based on the first argument
case "$1" in
backupmediapvc)
# Run backupmediapvc.sh which will backup the data from the django-media pvc to s3 storage
/scripts/backupmediapvc.sh
;;
ziplogs)
# Run ziplogs.sh which will zip all files that were created in the previous hour or older in the nginx log storage pvc
/scripts/ziplogs.sh
;;
analyzeexportlogs)
# Run analyzeexportlogs with additional arguments which will send the specified days logs through goaccess and then upload to s3.
shift # Remove the first argument (script number)
/scripts/analyzeexportlogs.sh "$@"
;;
*)
echo "Invalid script"
exit 1
;;
esac
Loading
Loading