Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 60019db7da | |||
| 2a35f97071 | |||
| d8a5d2717b | |||
| 5e17a009dc | |||
| 7e76950690 | |||
| 27f8f20275 | |||
| 98f86092a2 | |||
| 459838dfcd | |||
| 6553b4400c | |||
| b4007504b7 | |||
| a482ef9ef9 | |||
| 1bfa31acc0 | |||
| 2ab41bdce5 | |||
| 01f842323e | |||
| d6ea94f20d | |||
| 6d65f29674 | |||
| 4c098708f4 | |||
| 3301e2463e |
Vendored
+164
-16
@@ -1,40 +1,188 @@
|
|||||||
// CI pipeline for Scrap-Web (SSW 590, Continuous Integration with Jenkins).
|
// Scrap-Web pipeline: Chapter 4 CI checks + Chapter 6 secure delivery.
|
||||||
// Runs for every pull request through the Multibranch Pipeline job and reports
|
//
|
||||||
// its result to Gitea as a commit status. Uses only the Python 3 standard
|
// Trust boundary:
|
||||||
// library, so no packages are downloaded during the build.
|
// * Every build (branches and pull requests) runs the Chapter 4 checks on the
|
||||||
|
// controller's built-in node. No credentials, no Docker socket.
|
||||||
|
// * Delivery stages run only for trusted branches, on the 'delivery' agent,
|
||||||
|
// which holds the Docker socket and the registry/deploy credentials.
|
||||||
|
// TODO before submission: remove the feature branch from TRUSTED_BRANCH so
|
||||||
|
// only reviewed code on main can deliver.
|
||||||
|
|
||||||
|
def TRUSTED_BRANCH = 'main'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
// Builds run on the Jenkins controller executor (see the IT manual for the
|
agent none
|
||||||
// documented risk). python3 must be installed in the Jenkins container.
|
|
||||||
agent any
|
|
||||||
|
|
||||||
options {
|
options {
|
||||||
skipDefaultCheckout()
|
skipDefaultCheckout()
|
||||||
timeout(time: 10, unit: 'MINUTES')
|
disableConcurrentBuilds() // no competing releases
|
||||||
|
timeout(time: 30, unit: 'MINUTES')
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '50'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
REGISTRY = 'git.ssw590-08.me'
|
||||||
|
IMAGE = 'git.ssw590-08.me/ssw-590-08/pricing'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
// ---------------- Chapter 4 CI (all builds, controller) ----------------
|
||||||
|
stage('CI checks') {
|
||||||
|
agent { label 'built-in' }
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
sh 'git rev-parse HEAD'
|
||||||
|
sh 'python3 --version'
|
||||||
|
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
|
||||||
|
sh 'python3 -m unittest discover -s tests -v'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- Chapter 6 delivery (trusted branches, agent) ---------
|
||||||
|
stage('Delivery') {
|
||||||
|
when { beforeAgent true; branch pattern: TRUSTED_BRANCH, comparator: 'REGEXP' }
|
||||||
|
agent { label 'delivery' }
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps {
|
steps {
|
||||||
checkout scm
|
checkout scm
|
||||||
// Record exactly which commit is being tested, for traceability.
|
script {
|
||||||
sh 'git rev-parse HEAD'
|
env.APP_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
sh 'python3 --version'
|
env.IMAGE_TAG = "${env.IMAGE}:${env.APP_COMMIT}"
|
||||||
|
}
|
||||||
|
echo "Source commit: ${env.APP_COMMIT}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Syntax check') {
|
|
||||||
|
stage('Unit tests') {
|
||||||
steps {
|
steps {
|
||||||
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
|
dir('pricing') {
|
||||||
|
sh '''
|
||||||
|
python3 -m venv .venv
|
||||||
|
.venv/bin/pip install -q --require-hashes -r requirements.txt
|
||||||
|
.venv/bin/python -m py_compile app.py test_app.py
|
||||||
|
.venv/bin/python -m unittest -v
|
||||||
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test') {
|
}
|
||||||
|
|
||||||
|
// 6.4.5 (kholmes): dependency + secret checks on the source.
|
||||||
|
stage('Security scan: source') {
|
||||||
steps {
|
steps {
|
||||||
sh 'python3 -m unittest discover -s tests -v'
|
sh '''
|
||||||
|
if [ -x security/scan.sh ]; then
|
||||||
|
security/scan.sh source
|
||||||
|
else
|
||||||
|
echo "security/scan.sh not added yet (6.4.5)"
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build image') {
|
||||||
|
steps {
|
||||||
|
dir('pricing') {
|
||||||
|
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" .'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6.4.5 (kholmes): image vulnerability scan before publishing.
|
||||||
|
stage('Security scan: image') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
if [ -x security/scan.sh ]; then
|
||||||
|
security/scan.sh image "$IMAGE_TAG"
|
||||||
|
else
|
||||||
|
echo "security/scan.sh not added yet (6.4.5)"
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Publish') {
|
||||||
|
steps {
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'gitea-registry-push',
|
||||||
|
usernameVariable: 'REG_USER',
|
||||||
|
passwordVariable: 'REG_TOKEN')]) {
|
||||||
|
// Push, then delete the local copy and pull it back from the
|
||||||
|
// registry, so the recorded digest is the registry's, not a local ID.
|
||||||
|
sh '''
|
||||||
|
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
|
||||||
|
docker push "$IMAGE_TAG"
|
||||||
|
docker image rm "$IMAGE_TAG"
|
||||||
|
docker pull "$IMAGE_TAG"
|
||||||
|
docker logout "$REGISTRY"
|
||||||
|
docker image inspect "$IMAGE_TAG" --format '{{index .RepoDigests 0}}' > image-digest.txt
|
||||||
|
echo "Published: $(cat image-digest.txt)"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
script { env.IMAGE_DIGEST = readFile('image-digest.txt').trim() }
|
||||||
|
writeFile file: 'build-record.txt', text: """source_commit: ${env.APP_COMMIT}
|
||||||
|
image_tag: ${env.IMAGE_TAG}
|
||||||
|
image_digest: ${env.IMAGE_DIGEST}
|
||||||
|
jenkins_build: ${env.BUILD_URL}
|
||||||
|
"""
|
||||||
|
archiveArtifacts artifacts: 'image-digest.txt, build-record.txt', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6.4.6: deploy the digest just published to staging with Ansible,
|
||||||
|
// then rerun unchanged and require changed=0 (idempotence).
|
||||||
|
stage('Deploy staging') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Expected behaviour comes from the source, not from config.
|
||||||
|
def version = sh(script: "sed -n 's/^VERSION = \"\\(.*\\)\"/\\1/p' pricing/app.py", returnStdout: true).trim()
|
||||||
|
def unit = sh(script: "sed -n 's/^UNIT_PRICE = //p' pricing/app.py", returnStdout: true).trim()
|
||||||
|
env.APP_VERSION = version
|
||||||
|
writeFile file: "release-${version}-staging.yml", text: """target_env: staging
|
||||||
|
release_image: ${env.IMAGE_DIGEST}
|
||||||
|
expected_version: ${version}
|
||||||
|
expected_commit: ${env.APP_COMMIT}
|
||||||
|
expected_total: ${3 * (unit as Integer)}
|
||||||
|
public_url: https://staging.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
archiveArtifacts artifacts: "release-${env.APP_VERSION}-staging.yml", fingerprint: true
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||||
|
sh '''
|
||||||
|
export PATH=/opt/ansible-venv/bin:$PATH
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Staging idempotence') {
|
||||||
|
steps {
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||||
|
sh '''
|
||||||
|
export PATH=/opt/ansible-venv/bin:$PATH
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml | tee rerun.log
|
||||||
|
grep -E 'startup +: .*changed=0 +unreachable=0 +failed=0' rerun.log \
|
||||||
|
|| { echo "Second run changed something: not idempotent"; exit 1; }
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 6.4.7 (kholmes): approval + production deploy.
|
||||||
|
stage('Approve and deploy production') {
|
||||||
|
steps { echo 'Not implemented yet (6.4.7).' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success { echo 'All checks passed.' }
|
success { echo 'All stages passed.' }
|
||||||
failure { echo 'A stage failed: see the stage view for which one.' }
|
failure { echo 'A stage failed: see the stage view for which one.' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Secrets and host-specific values stay on the Droplet
|
||||||
|
jenkins-agent.secret
|
||||||
|
agent.secrets.env
|
||||||
|
.env
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Trusted Jenkins delivery agent for Chapter 6.
|
||||||
|
# Build context is the repository root (see agent/compose.yaml).
|
||||||
|
FROM jenkins/inbound-agent:latest-jdk21
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Python 3 + venv for tests, pip-audit and Ansible; curl for checks
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Docker CLI + buildx plugin (client only; the daemon is the host's, via the mounted socket)
|
||||||
|
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker
|
||||||
|
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
# Trivy scanner (image vulnerabilities + secret scanning)
|
||||||
|
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy
|
||||||
|
|
||||||
|
# Ansible in its own virtual environment, plus the community.docker collection
|
||||||
|
ENV ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections
|
||||||
|
COPY ansible/requirements.yml /tmp/ansible-requirements.yml
|
||||||
|
RUN python3 -m venv /opt/ansible-venv \
|
||||||
|
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core \
|
||||||
|
&& /opt/ansible-venv/bin/ansible-galaxy collection install -r /tmp/ansible-requirements.yml -p /opt/ansible-collections \
|
||||||
|
&& rm /tmp/ansible-requirements.yml
|
||||||
|
|
||||||
|
# pip-audit in a separate tools venv
|
||||||
|
RUN python3 -m venv /opt/tools-venv \
|
||||||
|
&& /opt/tools-venv/bin/pip install --no-cache-dir pip-audit
|
||||||
|
|
||||||
|
USER jenkins
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Trusted delivery agent. Connects to the existing Jenkins controller over the
|
||||||
|
# internal gitea-net network (WebSocket), so no new port is published.
|
||||||
|
services:
|
||||||
|
jenkins-agent:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: agent/Dockerfile
|
||||||
|
image: ssw590/jenkins-delivery-agent:1
|
||||||
|
container_name: jenkins-agent
|
||||||
|
restart: unless-stopped
|
||||||
|
# Start agent.jar directly. The secret is read from a file (-secret @file),
|
||||||
|
# so it never appears in the process list, docker inspect, or Git.
|
||||||
|
entrypoint:
|
||||||
|
- java
|
||||||
|
- -jar
|
||||||
|
- /usr/share/jenkins/agent.jar
|
||||||
|
- -url
|
||||||
|
- http://jenkins:8080/
|
||||||
|
- -webSocket
|
||||||
|
- -name
|
||||||
|
- delivery-agent
|
||||||
|
- -workDir
|
||||||
|
- /home/jenkins/agent
|
||||||
|
- -secret
|
||||||
|
- "@/run/secrets/jenkins-agent-secret"
|
||||||
|
# Host Docker socket: needed to build/push images. This is effectively root
|
||||||
|
# on the Droplet, so only reviewed main-branch delivery jobs may use this agent.
|
||||||
|
group_add: ["${DOCKER_GID:?set DOCKER_GID in .env}"]
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./jenkins-agent.secret:/run/secrets/jenkins-agent-secret:ro
|
||||||
|
- agent_home:/home/jenkins # workspace, known_hosts, registry login
|
||||||
|
networks: [gitea-net]
|
||||||
|
|
||||||
|
networks:
|
||||||
|
gitea-net:
|
||||||
|
external: true
|
||||||
|
name: gitea-net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent_home:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Print tool versions inside the agent. From the repo root on the Droplet:
|
||||||
|
# docker exec -i jenkins-agent sh -s < agent/versions.sh
|
||||||
|
echo "== java"; java -version 2>&1 | head -1
|
||||||
|
echo "== python"; python3 --version
|
||||||
|
echo "== docker"; docker version --format 'client {{.Client.Version}} / server {{.Server.Version}}'
|
||||||
|
echo "== buildx"; docker buildx version
|
||||||
|
echo "== trivy"; trivy --version | head -1
|
||||||
|
echo "== pip-audit"; /opt/tools-venv/bin/pip-audit --version
|
||||||
|
echo "== ansible"; /opt/ansible-venv/bin/ansible --version | head -3
|
||||||
|
echo "== collections"; /opt/ansible-venv/bin/ansible-galaxy collection list community.docker 2>/dev/null | tail -2
|
||||||
|
echo "== os"; . /etc/os-release; echo "$PRETTY_NAME $(uname -m)"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
- name: Deploy a selected immutable pricing release
|
||||||
|
hosts: delivery
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
project_dir: "/opt/startup/pricing-{{ target_env }}"
|
||||||
|
tasks:
|
||||||
|
- name: Validate release selection
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- target_env in ['staging', 'production']
|
||||||
|
- "'@sha256:' in release_image"
|
||||||
|
- expected_version in ['v1', 'v2']
|
||||||
|
- expected_total | int > 0
|
||||||
|
- public_url.startswith('https://')
|
||||||
|
- proxy_network | length > 0
|
||||||
|
- name: Create deployment directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ project_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0750'
|
||||||
|
- name: Render selected Compose configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: compose.yaml.j2
|
||||||
|
dest: "{{ project_dir }}/compose.yaml"
|
||||||
|
mode: '0640'
|
||||||
|
- name: Converge application without rebuilding
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ project_dir }}"
|
||||||
|
project_name: "pricing-{{ target_env }}"
|
||||||
|
state: present
|
||||||
|
build: never
|
||||||
|
pull: missing
|
||||||
|
wait: true
|
||||||
|
wait_timeout: 90
|
||||||
|
- name: Verify health through public TLS endpoint
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/health"
|
||||||
|
return_content: true
|
||||||
|
validate_certs: true
|
||||||
|
register: health
|
||||||
|
until: health.status == 200 and health.json.status == 'ok'
|
||||||
|
retries: 12
|
||||||
|
delay: 5
|
||||||
|
changed_when: false
|
||||||
|
- name: Read release identity
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/"
|
||||||
|
return_content: true
|
||||||
|
register: identity
|
||||||
|
changed_when: false
|
||||||
|
- name: Exercise business behavior
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/price?quantity=3"
|
||||||
|
return_content: true
|
||||||
|
register: price
|
||||||
|
changed_when: false
|
||||||
|
- name: Check release identity and calculation
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- identity.json.version == expected_version
|
||||||
|
- identity.json.commit == expected_commit
|
||||||
|
- price.json.total | int == expected_total | int
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[delivery]
|
||||||
|
# Target: the existing Droplet, reached over SSH as the dedicated deploy account.
|
||||||
|
# Host key must be verified and pinned in the agent's known_hosts before first use.
|
||||||
|
startup ansible_host=147.182.179.191 ansible_user=deploy
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
collections:
|
||||||
|
- name: community.docker
|
||||||
|
version: ">=4.8.0,<6.0.0"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: "{{ release_image }}"
|
||||||
|
restart: unless-stopped
|
||||||
|
read_only: true
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
|
cap_drop:
|
||||||
|
- ALL
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
aliases:
|
||||||
|
- "pricing-{{ target_env }}"
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
external: true
|
||||||
|
name: "{{ proxy_network }}"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Pinned image versions only. No passwords in this file.
|
||||||
|
PROMETHEUS_TAG=v3.13.5
|
||||||
|
GRAFANA_TAG=13.2.5
|
||||||
|
NODE_EXPORTER_TAG=v1.12.1
|
||||||
|
BLACKBOX_TAG=v0.29.0
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Secrets stay on the Droplet only
|
||||||
|
grafana.secrets.env
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# SSW 590 Monitoring Runbook
|
||||||
|
|
||||||
|
Dashboard: https://metrics.ssw590-08.me/d/ssw590-sre
|
||||||
|
Contact point: `team-alerts` (email). Times are America/New_York.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ServiceUnavailable – Gitea or Jenkins HTTPS probe failing
|
||||||
|
|
||||||
|
**Owner:** samahk13 (primary), kholmes (backup)
|
||||||
|
**Severity:** critical
|
||||||
|
**Fires when:** `probe_success{job="https"}` is 0 for an instance for at least 1 minute,
|
||||||
|
or the probe series is missing (no data) / the query errors.
|
||||||
|
|
||||||
|
### 1. Acknowledge
|
||||||
|
Reply to the alert email (or post in the team chat) with "ack" and your name, and
|
||||||
|
note the time. This is the acknowledgement time in the incident timeline.
|
||||||
|
|
||||||
|
### 2. Is it the service or the monitoring?
|
||||||
|
- Open the dashboard. Check the **Scrape health (up)** row.
|
||||||
|
- `blackbox` or `https` shows DOWN / no data → the **monitoring** is broken,
|
||||||
|
not necessarily the service. Go to step 5.
|
||||||
|
- `up` is 1 but panel 4 or 5 shows DOWN → the probed request failed. Continue.
|
||||||
|
- Open the URL in a browser:
|
||||||
|
- Gitea: https://git.ssw590-08.me/user/login
|
||||||
|
- Jenkins: https://ci.ssw590-08.me/login
|
||||||
|
|
||||||
|
### 3. Check the container (SSH to the Droplet as root)
|
||||||
|
```
|
||||||
|
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
|
||||||
|
docker logs --tail=50 jenkins # or: gitea
|
||||||
|
docker logs --tail=50 caddy # proxy / TLS problems
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Restore
|
||||||
|
- Container stopped/exited:
|
||||||
|
```
|
||||||
|
docker start jenkins # or: docker start gitea
|
||||||
|
```
|
||||||
|
- Container running but unhealthy: `docker restart jenkins`
|
||||||
|
- Certificate/proxy error: check `docker logs caddy`; validate with
|
||||||
|
`docker exec caddy caddy validate --config /etc/caddy/Caddyfile`.
|
||||||
|
- **Never** use `docker compose down -v` (deletes data volumes).
|
||||||
|
|
||||||
|
Wait for the next probes (~30–60 s). The alert resolves when `probe_success` is 1
|
||||||
|
again; confirm the "Resolved" email arrives.
|
||||||
|
|
||||||
|
### 5. Monitoring itself is failing (no data / error)
|
||||||
|
```
|
||||||
|
cd /root/Scrap-Web/monitoring
|
||||||
|
docker compose ps
|
||||||
|
docker compose logs --tail=50 prometheus blackbox-exporter
|
||||||
|
docker compose start prometheus blackbox-exporter
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. After recovery
|
||||||
|
- Jenkins: run **Build Now** on `main` and confirm it passes.
|
||||||
|
- Gitea: confirm the web login and that Jenkins can still post commit statuses.
|
||||||
|
- Record the timeline in the incident issue.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## HostDiskLow – root filesystem below 15 % free
|
||||||
|
|
||||||
|
**Owner:** kholmes — *(partner to complete)*
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Step 1 baseline - run on the Droplet BEFORE starting the monitoring stack.
|
||||||
|
# Output contains no secrets; paste it into the Gitea issue.
|
||||||
|
echo "== date"; date -Is
|
||||||
|
echo "== OS"; cat /etc/os-release | head -4; uname -r
|
||||||
|
echo "== CPU"; nproc; grep -m1 "model name" /proc/cpuinfo; uname -m
|
||||||
|
echo "== memory (bytes)"; free -b
|
||||||
|
echo "== root disk"; df -B1 /; df -h /
|
||||||
|
echo "== docker"; docker version --format '{{.Server.Version}}'; docker compose version
|
||||||
|
echo "== containers"; docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
|
||||||
|
echo "== container usage"; docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
|
||||||
|
echo "== load"; uptime
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
modules:
|
||||||
|
http_2xx:
|
||||||
|
prober: http
|
||||||
|
timeout: 10s
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
preferred_ip_protocol: ip4
|
||||||
|
valid_status_codes: [] # empty = any 2xx is success
|
||||||
|
follow_redirects: true
|
||||||
|
fail_if_not_ssl: true
|
||||||
|
tls_config:
|
||||||
|
insecure_skip_verify: false
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# SSW 590 - Monitoring stack (Prometheus, Grafana OSS, Node Exporter, Blackbox Exporter)
|
||||||
|
# Only Grafana joins gitea-net so the existing Caddy container can proxy it.
|
||||||
|
# No host ports are published; Prometheus and the exporters stay on the private network.
|
||||||
|
services:
|
||||||
|
prometheus:
|
||||||
|
image: prom/prometheus:${PROMETHEUS_TAG:?choose a release}
|
||||||
|
container_name: prometheus
|
||||||
|
restart: unless-stopped
|
||||||
|
command:
|
||||||
|
- --config.file=/etc/prometheus/prometheus.yml
|
||||||
|
- --storage.tsdb.path=/prometheus
|
||||||
|
- --storage.tsdb.retention.time=7d
|
||||||
|
- --storage.tsdb.retention.size=5GB
|
||||||
|
volumes:
|
||||||
|
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||||
|
- prometheus_data:/prometheus
|
||||||
|
networks: [monitoring]
|
||||||
|
|
||||||
|
grafana:
|
||||||
|
image: grafana/grafana:${GRAFANA_TAG:?choose a release}
|
||||||
|
container_name: grafana
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on: [prometheus]
|
||||||
|
env_file: [grafana.secrets.env]
|
||||||
|
environment:
|
||||||
|
GF_SERVER_ROOT_URL: "https://metrics.ssw590-08.me/"
|
||||||
|
GF_SERVER_DOMAIN: "metrics.ssw590-08.me"
|
||||||
|
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
||||||
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||||
|
GF_DATE_FORMATS_DEFAULT_TIMEZONE: "America/New_York"
|
||||||
|
volumes:
|
||||||
|
- grafana_data:/var/lib/grafana
|
||||||
|
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
||||||
|
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||||
|
networks: [monitoring, gitea-net]
|
||||||
|
|
||||||
|
node-exporter:
|
||||||
|
image: quay.io/prometheus/node-exporter:${NODE_EXPORTER_TAG:?choose a release}
|
||||||
|
container_name: node-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
pid: host
|
||||||
|
command:
|
||||||
|
- --path.rootfs=/host
|
||||||
|
- --path.procfs=/host/proc
|
||||||
|
- --path.sysfs=/host/sys
|
||||||
|
volumes:
|
||||||
|
- /:/host:ro,rslave
|
||||||
|
networks: [monitoring]
|
||||||
|
|
||||||
|
blackbox-exporter:
|
||||||
|
image: quay.io/prometheus/blackbox-exporter:${BLACKBOX_TAG:?choose a release}
|
||||||
|
container_name: blackbox-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
command: ["--config.file=/config/blackbox.yml"]
|
||||||
|
volumes:
|
||||||
|
- ./blackbox/blackbox.yml:/config/blackbox.yml:ro
|
||||||
|
networks: [monitoring]
|
||||||
|
|
||||||
|
networks:
|
||||||
|
monitoring:
|
||||||
|
gitea-net:
|
||||||
|
external: true
|
||||||
|
name: gitea-net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
prometheus_data:
|
||||||
|
grafana_data:
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Copy to grafana.secrets.env on the Droplet and fill in. Never commit the real file.
|
||||||
|
GF_SECURITY_ADMIN_PASSWORD=CHANGE_ME
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
groups:
|
||||||
|
- orgId: 1
|
||||||
|
name: availability
|
||||||
|
folder: SSW 590
|
||||||
|
interval: 30s
|
||||||
|
rules:
|
||||||
|
- uid: fg2n29o6c9a80d
|
||||||
|
title: ServiceUnavailable
|
||||||
|
condition: C
|
||||||
|
data:
|
||||||
|
- refId: A
|
||||||
|
relativeTimeRange:
|
||||||
|
from: 600
|
||||||
|
to: 0
|
||||||
|
datasourceUid: prometheus
|
||||||
|
model:
|
||||||
|
editorMode: code
|
||||||
|
expr: probe_success{job="https"}
|
||||||
|
instant: true
|
||||||
|
intervalMs: 1000
|
||||||
|
legendFormat: __auto
|
||||||
|
maxDataPoints: 43200
|
||||||
|
range: false
|
||||||
|
refId: A
|
||||||
|
- refId: C
|
||||||
|
queryType: expression
|
||||||
|
datasourceUid: __expr__
|
||||||
|
model:
|
||||||
|
conditions:
|
||||||
|
- evaluator:
|
||||||
|
params:
|
||||||
|
- 1
|
||||||
|
type: lt
|
||||||
|
operator:
|
||||||
|
type: and
|
||||||
|
query:
|
||||||
|
params:
|
||||||
|
- C
|
||||||
|
reducer:
|
||||||
|
params: []
|
||||||
|
type: last
|
||||||
|
type: query
|
||||||
|
datasource:
|
||||||
|
type: __expr__
|
||||||
|
uid: __expr__
|
||||||
|
expression: A
|
||||||
|
intervalMs: 1000
|
||||||
|
maxDataPoints: 43200
|
||||||
|
refId: C
|
||||||
|
type: threshold
|
||||||
|
noDataState: Alerting
|
||||||
|
execErrState: Alerting
|
||||||
|
for: 1m
|
||||||
|
annotations:
|
||||||
|
runbook_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
|
||||||
|
summary: '{{ $labels.instance }} HTTPS probe failing for 1m'
|
||||||
|
labels:
|
||||||
|
owner: samahk13
|
||||||
|
severity: critical
|
||||||
|
team: ssw590
|
||||||
|
isPaused: false
|
||||||
|
notification_settings:
|
||||||
|
receiver: team-alerts
|
||||||
|
- orgId: 1
|
||||||
|
name: infrastructure-alerts
|
||||||
|
folder: SSW 590
|
||||||
|
interval: 30s
|
||||||
|
rules:
|
||||||
|
- uid: bg2tu8l6pb20wc
|
||||||
|
title: HostDiskLow
|
||||||
|
condition: C
|
||||||
|
data:
|
||||||
|
- refId: A
|
||||||
|
relativeTimeRange:
|
||||||
|
from: 600
|
||||||
|
to: 0
|
||||||
|
datasourceUid: prometheus
|
||||||
|
model:
|
||||||
|
editorMode: code
|
||||||
|
expr: |-
|
||||||
|
100 *
|
||||||
|
node_filesystem_avail_bytes{
|
||||||
|
mountpoint="/",
|
||||||
|
fstype!="rootfs",
|
||||||
|
device="/dev/vda1"
|
||||||
|
}
|
||||||
|
/
|
||||||
|
node_filesystem_size_bytes{
|
||||||
|
mountpoint="/",
|
||||||
|
fstype!="rootfs",
|
||||||
|
device="/dev/vda1"
|
||||||
|
}
|
||||||
|
instant: true
|
||||||
|
intervalMs: 1000
|
||||||
|
legendFormat: __auto
|
||||||
|
maxDataPoints: 43200
|
||||||
|
range: false
|
||||||
|
refId: A
|
||||||
|
- refId: C
|
||||||
|
queryType: expression
|
||||||
|
datasourceUid: __expr__
|
||||||
|
model:
|
||||||
|
conditions:
|
||||||
|
- evaluator:
|
||||||
|
params:
|
||||||
|
- 15
|
||||||
|
type: lt
|
||||||
|
operator:
|
||||||
|
type: and
|
||||||
|
query:
|
||||||
|
params:
|
||||||
|
- C
|
||||||
|
reducer:
|
||||||
|
params: []
|
||||||
|
type: last
|
||||||
|
type: query
|
||||||
|
datasource:
|
||||||
|
type: __expr__
|
||||||
|
uid: __expr__
|
||||||
|
expression: A
|
||||||
|
intervalMs: 1000
|
||||||
|
maxDataPoints: 43200
|
||||||
|
refId: C
|
||||||
|
type: threshold
|
||||||
|
noDataState: Alerting
|
||||||
|
execErrState: Alerting
|
||||||
|
for: 5m
|
||||||
|
annotations:
|
||||||
|
description: Investigate root filesystem capacity on the monitored Droplet. Check disk usage and Docker logs before taking action. Do not delete Docker volumes or container data as an emergency response.
|
||||||
|
runbook_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
|
||||||
|
summary: Root filesystem free space below 15% on {{ $labels.instance }}
|
||||||
|
labels:
|
||||||
|
owner: kholmes7
|
||||||
|
severity: warning
|
||||||
|
team: ssw590
|
||||||
|
isPaused: false
|
||||||
|
notification_settings:
|
||||||
|
receiver: team-alerts
|
||||||
@@ -0,0 +1,547 @@
|
|||||||
|
{
|
||||||
|
"uid": "ssw590-sre",
|
||||||
|
"title": "SSW 590 \u2013 Gitea & Jenkins Reliability",
|
||||||
|
"tags": [
|
||||||
|
"ssw590",
|
||||||
|
"sre"
|
||||||
|
],
|
||||||
|
"timezone": "America/New_York",
|
||||||
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"refresh": "30s",
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"version": 1,
|
||||||
|
"editable": true,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "1. Droplet CPU utilization (all CPUs)",
|
||||||
|
"description": "Percent of CPU time not idle, averaged across all CPUs over a 2-minute rate window. Whole-droplet: includes Gitea, Jenkins, Caddy and monitoring; does not attribute CPU to a container.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[2m])))",
|
||||||
|
"legendFormat": "CPU busy %",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "percent",
|
||||||
|
"min": 0,
|
||||||
|
"max": 100,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 90
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "line"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "2. Available host memory",
|
||||||
|
"description": "MemAvailable: the kernel's estimate of memory available to start new applications without swapping (bytes, IEC). Not the same as unused RAM.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 0,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "node_memory_MemAvailable_bytes{job=\"node\"}",
|
||||||
|
"legendFormat": "MemAvailable",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "bytes",
|
||||||
|
"min": 0,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 209715200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 419430400
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "line"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "3. Root filesystem available space (/dev/vda1)",
|
||||||
|
"description": "Available bytes divided by size bytes for the host root filesystem only (device /dev/vda1, mounted at /). Alert threshold is 15%.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 8,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "100 * node_filesystem_avail_bytes{job=\"node\",mountpoint=\"/\",device=\"/dev/vda1\"} / node_filesystem_size_bytes{job=\"node\",mountpoint=\"/\",device=\"/dev/vda1\"}",
|
||||||
|
"legendFormat": "root available %",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "percent",
|
||||||
|
"min": 0,
|
||||||
|
"max": 100,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "orange",
|
||||||
|
"value": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 25
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "line"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "6. HTTPS probe duration",
|
||||||
|
"description": "Total time for each Blackbox HTTPS probe (DNS + connect + TLS + request, following redirects), one line per service.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 8,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "probe_duration_seconds{job=\"https\"}",
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "s",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "off"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "4. Gitea HTTPS availability",
|
||||||
|
"description": "1 = Blackbox Exporter's HTTPS probe of https://git.ssw590-08.me/user/login succeeded (DNS, valid TLS, 2xx after redirects); 0 = failed. Sampled every 30 s.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 16,
|
||||||
|
"w": 12,
|
||||||
|
"h": 7
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "probe_success{job=\"https\",instance=\"https://git.ssw590-08.me/user/login\"}",
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "none",
|
||||||
|
"min": 0,
|
||||||
|
"max": 1,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "line"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10,
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineInterpolation": "stepAfter"
|
||||||
|
},
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"type": "value",
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "DOWN",
|
||||||
|
"color": "red"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "UP",
|
||||||
|
"color": "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"decimals": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "5. Jenkins HTTPS availability",
|
||||||
|
"description": "1 = Blackbox Exporter's HTTPS probe of https://ci.ssw590-08.me/login succeeded (DNS, valid TLS, 2xx after redirects); 0 = failed. Sampled every 30 s.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 16,
|
||||||
|
"w": 12,
|
||||||
|
"h": 7
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "probe_success{job=\"https\",instance=\"https://ci.ssw590-08.me/login\"}",
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "none",
|
||||||
|
"min": 0,
|
||||||
|
"max": 1,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "line"
|
||||||
|
},
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10,
|
||||||
|
"drawStyle": "line",
|
||||||
|
"lineInterpolation": "stepAfter"
|
||||||
|
},
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"type": "value",
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "DOWN",
|
||||||
|
"color": "red"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "UP",
|
||||||
|
"color": "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"decimals": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Scrape health (up)",
|
||||||
|
"description": "1 = Prometheus scraped the target successfully. A target can be up while its probe_success is 0.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 23,
|
||||||
|
"w": 24,
|
||||||
|
"h": 5
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "up",
|
||||||
|
"legendFormat": "{{job}} {{instance}}",
|
||||||
|
"instant": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"type": "value",
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "DOWN",
|
||||||
|
"color": "red"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "UP",
|
||||||
|
"color": "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "none"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"colorMode": "background",
|
||||||
|
"graphMode": "none",
|
||||||
|
"textMode": "value_and_name",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"annotations": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": {
|
||||||
|
"type": "grafana",
|
||||||
|
"uid": "-- Grafana --"
|
||||||
|
},
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
providers:
|
||||||
|
- name: ssw590
|
||||||
|
folder: SSW 590
|
||||||
|
type: file
|
||||||
|
allowUiUpdates: true
|
||||||
|
options:
|
||||||
|
path: /var/lib/grafana/dashboards
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
datasources:
|
||||||
|
- name: Prometheus
|
||||||
|
uid: prometheus
|
||||||
|
type: prometheus
|
||||||
|
access: proxy
|
||||||
|
url: http://prometheus:9090
|
||||||
|
isDefault: true
|
||||||
|
editable: false
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
global:
|
||||||
|
scrape_interval: 30s
|
||||||
|
evaluation_interval: 30s
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: prometheus
|
||||||
|
static_configs:
|
||||||
|
- targets: ["prometheus:9090"]
|
||||||
|
|
||||||
|
- job_name: node
|
||||||
|
static_configs:
|
||||||
|
- targets: ["node-exporter:9100"]
|
||||||
|
|
||||||
|
- job_name: blackbox
|
||||||
|
static_configs:
|
||||||
|
- targets: ["blackbox-exporter:9115"]
|
||||||
|
|
||||||
|
- job_name: https
|
||||||
|
metrics_path: /probe
|
||||||
|
params:
|
||||||
|
module: [http_2xx]
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- https://git.ssw590-08.me/user/login
|
||||||
|
- https://ci.ssw590-08.me/login
|
||||||
|
relabel_configs:
|
||||||
|
- source_labels: [__address__]
|
||||||
|
target_label: __param_target
|
||||||
|
- source_labels: [__param_target]
|
||||||
|
target_label: instance
|
||||||
|
- target_label: __address__
|
||||||
|
replacement: blackbox-exporter:9115
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__
|
||||||
|
.venv
|
||||||
|
.ansible-venv
|
||||||
|
.git
|
||||||
|
*.pyc
|
||||||
|
requirements.in
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Base image pinned by digest (python:3.13-slim, linux/amd64 for the Droplet).
|
||||||
|
FROM python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90
|
||||||
|
ARG APP_COMMIT=development
|
||||||
|
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt .
|
||||||
|
# Exact, hash-checked dependency versions (direct + transitive) from requirements.txt
|
||||||
|
RUN pip install --no-cache-dir --require-hashes -r requirements.txt
|
||||||
|
COPY app.py .
|
||||||
|
USER 10001:10001
|
||||||
|
EXPOSE 8000
|
||||||
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
VERSION = "v1"
|
||||||
|
UNIT_PRICE = 10
|
||||||
|
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||||
|
|
||||||
|
|
||||||
|
def total_price(quantity):
|
||||||
|
if quantity < 1 or quantity > 1000:
|
||||||
|
raise ValueError("quantity must be between 1 and 1000")
|
||||||
|
return UNIT_PRICE * quantity
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def index():
|
||||||
|
return jsonify(service="Startup Pricing", version=VERSION, commit=COMMIT)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return jsonify(status="ok", version=VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/price")
|
||||||
|
def price():
|
||||||
|
try:
|
||||||
|
quantity = int(request.args.get("quantity", "1"))
|
||||||
|
total = total_price(quantity)
|
||||||
|
except ValueError as error:
|
||||||
|
return jsonify(error=str(error)), 400
|
||||||
|
return jsonify(quantity=quantity, total=total, currency="USD")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Flask>=3.1,<3.2
|
||||||
|
gunicorn>=23,<24
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
# This file was autogenerated by uv via the following command:
|
||||||
|
# uv pip compile requirements.in --universal --python-version 3.13 --generate-hashes -o requirements.txt
|
||||||
|
blinker==1.9.0 \
|
||||||
|
--hash=sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf \
|
||||||
|
--hash=sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc
|
||||||
|
# via flask
|
||||||
|
click==8.5.1 \
|
||||||
|
--hash=sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37 \
|
||||||
|
--hash=sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4
|
||||||
|
# via flask
|
||||||
|
flask==3.1.3 \
|
||||||
|
--hash=sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb \
|
||||||
|
--hash=sha256:f4bcbefc124291925f1a26446da31a5178f9483862233b23c0c96a20701f670c
|
||||||
|
# via -r requirements.in
|
||||||
|
gunicorn==23.0.0 \
|
||||||
|
--hash=sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d \
|
||||||
|
--hash=sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec
|
||||||
|
# via -r requirements.in
|
||||||
|
itsdangerous==2.2.0 \
|
||||||
|
--hash=sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef \
|
||||||
|
--hash=sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173
|
||||||
|
# via flask
|
||||||
|
jinja2==3.1.6 \
|
||||||
|
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
|
||||||
|
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
|
||||||
|
# via flask
|
||||||
|
markupsafe==3.0.4 \
|
||||||
|
--hash=sha256:007e1ffd9bf65bb6ee96df7b258fc632a4868dd5566037986c64781f35a36e98 \
|
||||||
|
--hash=sha256:02fa4acbc6a3fc5c693c34d4dd8c1130b7fe99cc915181b0ddd6f72aeb296002 \
|
||||||
|
--hash=sha256:03470d1a8268e692ecf79ecd565593e59d44219377a7ead61f1f1b94c1f7ff6b \
|
||||||
|
--hash=sha256:04e7902ba80ee4bac1d50a549606527a1dcf0476cd81403db41099d3b60ec653 \
|
||||||
|
--hash=sha256:051417f74bcaaefa316276e0ff723f541616ca51043d070da00249d9bddd3e3c \
|
||||||
|
--hash=sha256:05295589e619b9bed252a86b532b8e27350abc372d18ba89b59375325e91ec1e \
|
||||||
|
--hash=sha256:06de8ef6331f6e822c28d577dc8bf43fe398800477c49498f38fc38b67ff33fc \
|
||||||
|
--hash=sha256:0764a13d34cae40db7bbf3a09b7e9b491bf4603e20b263a7a9d6b8e324975d0a \
|
||||||
|
--hash=sha256:077293e425f28ec737dbcad442a71752e28f8ae27cde3d68acd1fb212091cd92 \
|
||||||
|
--hash=sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f \
|
||||||
|
--hash=sha256:0cee7cb0f9a1b6892ea482237d9403b3d1b4603aee057d0ff01f0fac2d019a97 \
|
||||||
|
--hash=sha256:0d9c47709875fdb321452056622e930c52afbc07a7d780762fbb8b4d91ce6fa4 \
|
||||||
|
--hash=sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7 \
|
||||||
|
--hash=sha256:12a606a492de952afcb43b59a14aaaaad120e708d3663dd0fdf2d738d427a691 \
|
||||||
|
--hash=sha256:14bd2d845d62ab678eaf81da89d7b621b51756c72346745c1a594c09d49207a2 \
|
||||||
|
--hash=sha256:15ba9e28640feef770374b116a6f019c21f52404aeabe516aa7f800587b98cfc \
|
||||||
|
--hash=sha256:18a801868a884f216e784d7d14db2a4077143ce7610440aee2ce8f734e7cfcde \
|
||||||
|
--hash=sha256:1c0df495a977d10460a94941799c72d5b5ab03d3858d949b55b5a66c8f371c99 \
|
||||||
|
--hash=sha256:1caa2fa5a6184fb233153b35f654e6687bd555476f6170f29d8ee9be1a8b0af9 \
|
||||||
|
--hash=sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df \
|
||||||
|
--hash=sha256:1f1f9477e174582b0a1b583d60b66e1f2cf5d3fe12cee985e4aedf44766600e5 \
|
||||||
|
--hash=sha256:2628d3a8cb648ecebb3c5d6b0a1052d400e4d8b7ac0fb786be8d285b50040d17 \
|
||||||
|
--hash=sha256:26e9867520db70d37f7fb421a7f0d8adb40171011fb84ce869afa1a83370dfa8 \
|
||||||
|
--hash=sha256:2a6ef68ae94aed8721934072b27a3b654ea2100b97e4ab864cf1489c90926fbc \
|
||||||
|
--hash=sha256:2b2b1e18af909b448bb3cf9e3433366f7a8726271fc214e8b10e0f62a78c724b \
|
||||||
|
--hash=sha256:2cb3dd71fc6be918ad4264346a8ed69485f9b7ed7bf35495d8e22807cd6b8bea \
|
||||||
|
--hash=sha256:2d1b7d9308288661f56672b1b157d75fc536714d3638487bbea17b6318a78248 \
|
||||||
|
--hash=sha256:2dad610540cb2e6272855c178f08ae9a1c7ac258a7fb71660553a5f104b42741 \
|
||||||
|
--hash=sha256:2e5a7cd7fdd14fcb1ae5d7d8bf23d24fbd1daefd1fbca2580132e1ea75f098b5 \
|
||||||
|
--hash=sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6 \
|
||||||
|
--hash=sha256:340cbb1957ba99929cbf19a75626d36ba1ae21d1730b287d1cf7f824a20c4fc7 \
|
||||||
|
--hash=sha256:34bdde374c5932765d7dc685c4a1d191a3207852d67e8e0a9eb6ea85156181f1 \
|
||||||
|
--hash=sha256:353bd63081912ab8cfa6a0c7d185934cdf8426f04c618bba6bc4b394f2069b67 \
|
||||||
|
--hash=sha256:387d8cd30e69b3f0a72877b9ae717033396404e19095b17fe89753a981fda44f \
|
||||||
|
--hash=sha256:3882fb412298575bae3b9c46868251f15cc69307359f87bb1b382e53d6e5a2c9 \
|
||||||
|
--hash=sha256:38fc55594dab834470b6733dead2ee9e3f657fb0608c769dcafa0ba5ab52f45c \
|
||||||
|
--hash=sha256:396ec4e65cc889f69786b3b89478b471cee5a3bcf468b9d9bb03e1a30fb291fc \
|
||||||
|
--hash=sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba \
|
||||||
|
--hash=sha256:3a93d9616ddecfb393727a0041a562cf0b15a244e20f2bd25efc7949be4c4f17 \
|
||||||
|
--hash=sha256:3d23795802fc8bd72534836d64489bbf0f67c088959091bdb22e10735a5107bf \
|
||||||
|
--hash=sha256:434139499bb20b502ed3baa1f169e618f924a97e7a777fea1a49446d80106cf6 \
|
||||||
|
--hash=sha256:436e3ffc6310d3c41878c601db29098102fe5d8a467c49da4a4125254e0980f2 \
|
||||||
|
--hash=sha256:489505b03f692c3f376394e49194fa7a7f9e8558d6e293a7056a0032b0c38163 \
|
||||||
|
--hash=sha256:4a540e2d3192792fc84eced57bef37851ccb2b41f73291bb17408eea77bcd278 \
|
||||||
|
--hash=sha256:4a7cdc2a420ca01058182da4253329764d4bfa055564d1eced90e6ba1e8b1d3d \
|
||||||
|
--hash=sha256:4bced6e2a6dba6a28f7dd3c6ce14df1b2dd495923f16ea484cad03decd463b2b \
|
||||||
|
--hash=sha256:4cf3468d5ec187ffffcaca8e61929a37448f215dafc1386a12c750a72fe53634 \
|
||||||
|
--hash=sha256:4e2c4809c14559aa7ef426f27fb35afbb38104c349a903bf8f3600456764bb38 \
|
||||||
|
--hash=sha256:4ed644d75aa94a2baf7ec3a96eaa160ea58c742eb9d27c6506053c5c40fc84ed \
|
||||||
|
--hash=sha256:4f6e0852a0283b1b1fd776eeb7b766a5f440b3e2bd31ab51af3b400585f3965c \
|
||||||
|
--hash=sha256:5066b244f576f91afc8ee3ba029a89f99d39c79b1853fe9d39bea9f0afbec148 \
|
||||||
|
--hash=sha256:5086f9975abb1ab531ee6afca1761e4b59a19b446f3f6522ed776963228cfe5a \
|
||||||
|
--hash=sha256:50b5bedc9ed8a94fc8857a42ef4f84a81ea88f8d4f05dc8705fb23ee6d8dcca7 \
|
||||||
|
--hash=sha256:52704c5d36eb6dda8866493decd61111fff86244c9b1ad225ca01b9e91e5970f \
|
||||||
|
--hash=sha256:55ffd6ce583d97dc71dc92e930324c8c0d25aea7e3ade6ae54ef77cedb096811 \
|
||||||
|
--hash=sha256:569d65055d367e3dcdf30c3f41119467b73d9ee9faf332bdf40402644f5ac08e \
|
||||||
|
--hash=sha256:57f9947a7e57a081c1e3e0a2dd0d2dcf290a4531450e6f611e30084c222a7295 \
|
||||||
|
--hash=sha256:5989cb26b2e1efc6a42216a9f6b5ee495ce5ace2e5b352a9af489976b32d1ee2 \
|
||||||
|
--hash=sha256:5c22873ad1f0532ba40fa1727f3c0fc1bbbaab6d373d4cbe3f0dc74b2e2521c7 \
|
||||||
|
--hash=sha256:5e8b3d0b18fd623afa12ecb2ce8d8becef69f9b5440c6330c7972200e0bb84b0 \
|
||||||
|
--hash=sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6 \
|
||||||
|
--hash=sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed \
|
||||||
|
--hash=sha256:6669c1bf34080161ce49c589cc512ef24d4c704ac9d2b2d3667f519c60418378 \
|
||||||
|
--hash=sha256:672d207103e6b16ca098611b0f9efad6bc00afd47c03d6ef62186495ca677dc0 \
|
||||||
|
--hash=sha256:6768d67d1bce64270e0fdc2e69309d68b9b18ae56ddf6c711d168e9d051c2cac \
|
||||||
|
--hash=sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b \
|
||||||
|
--hash=sha256:6bd9e1788e15bfcf6a9082de42e30387e7b85d211ab21e57a939bb8cfaaf8d96 \
|
||||||
|
--hash=sha256:6d2a9efe686f9de00d0d1ea32a4a5a86d558a2277501bd78d964214eab625e59 \
|
||||||
|
--hash=sha256:6da83a088f8ef93b2d483a8232a4dbf4d69d3d8496b568a03c56becac43e1808 \
|
||||||
|
--hash=sha256:7018d4af1cd272e847aa5917983ab5e83e4f6579f9dbfecd4a79c0ca80b144c2 \
|
||||||
|
--hash=sha256:71f88e749ea29f67f21f3b36433c1dc54c7729ed2a6d9e2da2e0d9e0d7b224eb \
|
||||||
|
--hash=sha256:737c9c3981998eba27f11786f84fddcbabc74068b72a4a1f454ea02094b57b65 \
|
||||||
|
--hash=sha256:73e77980c7207854f00fc4e71fb1626868d5740ab4012623d55c7a99ad122a72 \
|
||||||
|
--hash=sha256:799c39bdf5e2f1292fedd3009f7b3c9e760f10b2420cb9638d56920840ff6db8 \
|
||||||
|
--hash=sha256:7a83aa6e4805df46fed18e989d3d16f86ef60cb50bbc8d9ce3a6be89165fbf6e \
|
||||||
|
--hash=sha256:7d3391b2188d18737cb2fa147028b1096236eaa7e156446c650a489fa2cadc91 \
|
||||||
|
--hash=sha256:7e1636da3d8dfc220b6dd10264db5f2b165e4888c4518594898fbe381049af8a \
|
||||||
|
--hash=sha256:805c8b84534fa10891890f0e4be39f3a99e94615d93e8836bf9fa1fdca2feeb2 \
|
||||||
|
--hash=sha256:811d02d5122171c1941357efd8f9bf4ffe907b7f0a1a4e729a880e4be3f46e3e \
|
||||||
|
--hash=sha256:8138eb83940ec7299024d92d4dee45f601b9e6c5ffde9d25f4e35e326203c707 \
|
||||||
|
--hash=sha256:83b3944fea42a8400edf92fd1770fb8d0d4f7de651353bd2d8525a92dba69a21 \
|
||||||
|
--hash=sha256:849dd2bb0e5e4ab2b71c7191726a4a8d5aa8a610daa584728cbee0b710ddc4ef \
|
||||||
|
--hash=sha256:8698d70a8081ee8c090dbb394768b5789a1da8b131b5499f89d071dd3cfaf6be \
|
||||||
|
--hash=sha256:8781a792a070cf2bd1b86d3aa943894115faaba6e88122a7bf32d62072742453 \
|
||||||
|
--hash=sha256:88d59b473bfb03259722600839af9bbd7fa13a2eb514beefeedb95997882f69a \
|
||||||
|
--hash=sha256:8909c2f1c6dd65e054ac4b573a91c8384d1492281e55d82d159d653f7a13adf6 \
|
||||||
|
--hash=sha256:8965520ac587c94a4ac48b729be3d8b8de00af39699b17585dfb599babe77977 \
|
||||||
|
--hash=sha256:8b5d563170ff8ba3181caa967c99a3c804d1dedb702c7cb93a6a7c32247da978 \
|
||||||
|
--hash=sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581 \
|
||||||
|
--hash=sha256:8f0fac8b13d14bb06c68195f849371924ae53dd7b1c00fed24650f704383b692 \
|
||||||
|
--hash=sha256:9240187afb63d2f9ddc3e032c670356fe941f6e20662ea168a5dc3f1f317e1b3 \
|
||||||
|
--hash=sha256:925f929d6b59a8b3f8b8c6ac363cd0af7eecc81efb3071770b3c6717c450a369 \
|
||||||
|
--hash=sha256:9348cbb300d224fe3b89793262cb093504d4ae927004468463f745188a193e4a \
|
||||||
|
--hash=sha256:9388003072b95f2f1e3fd908604194d653ba21330d811961a78b7da1a77e9e36 \
|
||||||
|
--hash=sha256:9438a2648b2195980cb2dd8e53ed7b8df91319e2d0b70ae61a9e1d1bc8d3bec9 \
|
||||||
|
--hash=sha256:94e4c421742086aeee4c32a506eec8859d7634aad943f7e6aacf70f813478768 \
|
||||||
|
--hash=sha256:94f5407f7bc64fa6463906b896f9904beeeb7dd8dc116ee8e9056c8714ff9916 \
|
||||||
|
--hash=sha256:971a3bbb75d97ae4e2e8f7d4834236f86f85f0c85e04ab2e191db1123b04f80b \
|
||||||
|
--hash=sha256:9e227f3dbe6bde7491cf0a9965d00b88c6b1a4a95d11480ddf88bb96d397c19f \
|
||||||
|
--hash=sha256:9e25feb9e330b63edb0278a0acdf85e50d0cb0fbf49c3084abbe4e24ae195346 \
|
||||||
|
--hash=sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c \
|
||||||
|
--hash=sha256:a18f38cafc329bac5e3c2b96c765b4c96d3d103421ed22ab7988c1e3fce27464 \
|
||||||
|
--hash=sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9 \
|
||||||
|
--hash=sha256:a5fcffb37e602b0b3c1638a97746b9b96125caa9bcf6fa41d337a9261de231ee \
|
||||||
|
--hash=sha256:a8e9f292fcda89b324f2f5c91d13f1424a153e40fc2756f38ee23b15835ff300 \
|
||||||
|
--hash=sha256:a9f54054101545a9a9cccefddf54316aa6e4491611fcbef9e91b3b6bebec04f6 \
|
||||||
|
--hash=sha256:aa2c838cc024642cc04c6854232f32b43e5e22833dd11119c1766c7873b8370d \
|
||||||
|
--hash=sha256:ac0c7c9f1609b0c4c114feb1d7a3409564c7fb77e360bed9e97e5d25dfeaf868 \
|
||||||
|
--hash=sha256:add96447a86d205ab616665d53b2950ee81083757f56e6ea833c8b2917646b46 \
|
||||||
|
--hash=sha256:ae9dcb8fbe244cb82f8a6458b455b927a03685e383d9bacf1ea5ce180b96dc97 \
|
||||||
|
--hash=sha256:b4a635a0487774f841cb1fb62e907e7195cc95bc761e053184b8acc3ceb20733 \
|
||||||
|
--hash=sha256:b4d12837e0203bbace818ff4a7461afdcd78bcd782351cea148139180d7bcffe \
|
||||||
|
--hash=sha256:b61687d0828e72bf5cda24a2690188f37170bd31c9359ac97e4e66569f120a16 \
|
||||||
|
--hash=sha256:b807e598953730f82e4eae3bd30f6a122cf6b31c398c6b504c0e04c13c170429 \
|
||||||
|
--hash=sha256:b8cd1f918b26fd7b1832ece557cc18f2d8747309ff8b3f0ef9d4250c5ad67a39 \
|
||||||
|
--hash=sha256:b91cc9d336957239ff200f30097e6fea2dc6d6fb3c81e853eaa09eac904fd894 \
|
||||||
|
--hash=sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c \
|
||||||
|
--hash=sha256:be6cb0c799abb0e2ba3e618e6d28ddddf7e485f6c2ce938dfa237daf3905072c \
|
||||||
|
--hash=sha256:befb4158af32106b9a93db8d6d1d1cbbd418c0d5aca0cabb7b1780abf0c89169 \
|
||||||
|
--hash=sha256:bf053da3c97a4bc5ecfbb218cdd2983febd91c617be8367d139882aa11e490aa \
|
||||||
|
--hash=sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77 \
|
||||||
|
--hash=sha256:c1bc67752d5f21013cfe430df4062441714eab79f65a6a05e01505957e9c35fe \
|
||||||
|
--hash=sha256:c61750fadcd119d0825bcb7d7d675dd264dcc89cc05292aab5be68ebdbb374ad \
|
||||||
|
--hash=sha256:c90d5b3d4e944e065a301d741b3c1d784f6bd1f503aa68b4967e32b2ba313d85 \
|
||||||
|
--hash=sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e \
|
||||||
|
--hash=sha256:cb96e6e088d6cf71c1ea977510948320234824cf226e32f6f6e044f7a9c82b34 \
|
||||||
|
--hash=sha256:cf63c214fe879a65e69a386f915e36104fc84254ab141240f8854602d8e0be2a \
|
||||||
|
--hash=sha256:d1aca03ede943eb80ab3d63bb082c84b7aab85ea83bd0fd0c200260945fb49d9 \
|
||||||
|
--hash=sha256:d2e56fd3b00222722abfb3f5f0759ddbae4b90811b5ad4343c64030ad1bde70c \
|
||||||
|
--hash=sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749 \
|
||||||
|
--hash=sha256:d882a373d8093c2941e01291b7ced96e9cbe4781da9a7751ca7e6c70385e5214 \
|
||||||
|
--hash=sha256:d920abdfa61279ba1a2ef9484aab07bf03331f8c08a10120fa332353d06e6932 \
|
||||||
|
--hash=sha256:da2af0d7aebfc2074080d72efa6ab8317c62481ef1f896f65d9999c1c01f4494 \
|
||||||
|
--hash=sha256:dd8ea6ebee7aedbf7c749fa80521d9ccf1ba473e0d1e14805caafbaad281c889 \
|
||||||
|
--hash=sha256:de8b364c423ef0a4bad9069657d617f9a5d2b2062457a89b1fa16ee199c399c1 \
|
||||||
|
--hash=sha256:df1ae86ff54725a01fa1a0510b914ca53a161b7050be74f6204e24aded5971d0 \
|
||||||
|
--hash=sha256:dff05cb7016dff1e9fd68f4122c127b65dfc59de5306cfb7ad92f956f230bee2 \
|
||||||
|
--hash=sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786 \
|
||||||
|
--hash=sha256:e49fb0d1ce92cfa0cb198cc5b1b11cdf9d0638658e2a2db2687e39db7c87fc78 \
|
||||||
|
--hash=sha256:e5c802729725bd07e2bc3ab7b76dc7e0bbfc53129d8f1eb1c002c24cf774717e \
|
||||||
|
--hash=sha256:e841068dc0be4cb6dfb5c890eb88cbdcff2f4a332393c7ec94e8e618bd32c1a8 \
|
||||||
|
--hash=sha256:e916035e3e9930cbdfdd10abf48861340221857f45509565898e012263f7b289 \
|
||||||
|
--hash=sha256:eba154571c16e032112afac0dc2dfe9e63c2ceb7aedd07bb7eecf2ce26d4dd4c \
|
||||||
|
--hash=sha256:f03460ff076f70ab595bb45a0205ccea1971443575b6920c52e755dec2b3fbfe \
|
||||||
|
--hash=sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237 \
|
||||||
|
--hash=sha256:f291bcf42ae98eb5107edb162c3c998b4a89648fd8e99ed4cbd12705292788cd \
|
||||||
|
--hash=sha256:f61efe1d2fe0de16158a5fe1d1cf3c14bdb6aecd54d8938fd26512c525c1f624 \
|
||||||
|
--hash=sha256:f68edfc67aabac33708941f26f22a7b8e9f81429bc0cf249fcf7d66b23af8d19 \
|
||||||
|
--hash=sha256:fa95848c929b6a75f6848d3c9793e59db365ee436776e57db835cdbfa79ba977 \
|
||||||
|
--hash=sha256:fd9f8797427910198f95bced71ddfed61130d7e349213bfb8466c9c99e2c46a8 \
|
||||||
|
--hash=sha256:fdb4ca07ab75ffadab4a8b135ad59cdbb3156b99310f3d565370da74a15d6bd3
|
||||||
|
# via
|
||||||
|
# flask
|
||||||
|
# jinja2
|
||||||
|
# werkzeug
|
||||||
|
packaging==26.3 \
|
||||||
|
--hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \
|
||||||
|
--hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
|
||||||
|
# via gunicorn
|
||||||
|
werkzeug==3.1.9 \
|
||||||
|
--hash=sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060 \
|
||||||
|
--hash=sha256:6392e50c78460ba618e5b21f08a71f59c99ce99cdc6cf6e3dd7e6ccca8754fab
|
||||||
|
# via flask
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import unittest
|
||||||
|
from app import app, total_price
|
||||||
|
|
||||||
|
|
||||||
|
class PricingTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.client = app.test_client()
|
||||||
|
|
||||||
|
def test_price(self):
|
||||||
|
self.assertEqual(total_price(3), 30)
|
||||||
|
response = self.client.get("/price?quantity=3")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual(response.json["total"], 30)
|
||||||
|
|
||||||
|
def test_invalid_quantity(self):
|
||||||
|
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||||
|
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||||
|
|
||||||
|
def test_release_identity(self):
|
||||||
|
self.assertEqual(self.client.get("/").json["version"], "v1")
|
||||||
|
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Release records
|
||||||
|
|
||||||
|
One file per environment and release, e.g. `v1-staging.yml`, `v1-production.yml`.
|
||||||
|
Each holds metadata only (image digest, full source commit, expected version and
|
||||||
|
total, public URL, proxy network) - never credentials. Production uses the same
|
||||||
|
image digest as staging. Keep old records for rollback.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copy to a release-specific file and replace EVERY placeholder.
|
||||||
|
target_env: staging
|
||||||
|
release_image: gitea.example.edu/team/pricing@sha256:REPLACE_DIGEST
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: REPLACE_FULL_GIT_COMMIT
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.example.edu
|
||||||
|
proxy_network: REPLACE_EXISTING_PROXY_NETWORK
|
||||||
Reference in New Issue
Block a user