|
| 1 | +name: 🔁🐤 Scheduled onhost canary config rotation |
| 2 | + |
| 3 | +# Every 6 hours, deploy the *next* config version in an ordered set to the |
| 4 | +# canary fleet using test/onhost-canaries/scripts/fleet_deployment.sh. |
| 5 | +# Each run advances one step through the set; after the last entry it wraps |
| 6 | +# back to the first. This is a rotation (one deployment per run), not a matrix |
| 7 | +# fan-out. |
| 8 | + |
| 9 | +on: |
| 10 | + schedule: |
| 11 | + # Every 6 hours (UTC). Minute offset from :00 to dodge the top-of-hour |
| 12 | + # scheduler backlog that delays cron workflows on GitHub-hosted runners. |
| 13 | + - cron: "17 */6 * * *" |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +concurrency: |
| 19 | + # Never overlap rotation runs (each run already deploys every environment/platform combination). |
| 20 | + group: scheduled-onhost-canary-config-rotation |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +env: |
| 24 | + # AC Staging Account `host-canaries-staging` fleet |
| 25 | + FLEET_ID_STAGING: "MTIyMTMwNjh8TkdFUHxGTEVFVHwwMTlhZTNiNS01Yjg5LTdkNjYtYWU0MC1lNmZkOTY2ZDFhMDA" |
| 26 | + WINDOWS_FLEET_ID_STAGING: "MTIyMTMwNjh8TkdFUHxGTEVFVHwwMTljMjNjYy0yM2I2LTc1OTYtODBkNy0yMzAzYWIyYzcwMTA" |
| 27 | + # AC US Production Account `host-canaries-production` fleet |
| 28 | + FLEET_ID_PRODUCTION: "NjQyNTg2NXxOR0VQfEZMRUVUfDAxOWFlM2EyLTA3OTctNzczYS05Y2JjLWMzNzZkMjAwMWFkZg" |
| 29 | + WINDOWS_FLEET_ID_PRODUCTION: "NjQyNTg2NXxOR0VQfEZMRUVUfDAxOWMyMjljLWVhYTQtN2JmNi04YWIyLTU2ZWI0YjE2ZWZjZQ" |
| 30 | + |
| 31 | + # Ordered set of agent specs to rotate through, one per line: |
| 32 | + # <agentType>:<version>:<configVersionId> |
| 33 | + # Agent type, version and config version are paired here so they always rotate |
| 34 | + # together and stay matched. One deployment per run advances to the next entry, |
| 35 | + # wrapping to the first after the last. |
| 36 | + # We don't have 'latest' OCI packages, so I've set them to a fixed version. |
| 37 | + # First -> NRInfra 1.77.1 (canaries-infra-config) |
| 38 | + # Second -> NRDOT 1.19.0 (canaries-nrdot) |
| 39 | + AGENT_SPECS_LINUX: >- |
| 40 | + NRInfra:1.77.1:NjQyNTg2NXxOR0VQfEFHRU5UX0NPTkZJR1VSQVRJT05fVkVSU0lPTnwwMTlmNGM3Yi1lYjAyLTc1MmQtOGViOC0zNDYyMWM2ZDRkMzQ |
| 41 | + NRDOT:1.19.0:NjQyNTg2NXxOR0VQfEFHRU5UX0NPTkZJR1VSQVRJT05fVkVSU0lPTnwwMTlmNGM3Yy05M2Y3LTcyMjctODJmZS01OGYwMjcyMDViMDI |
| 42 | + # First -> NRInfra 1.77.1 (canaries-infra-config-windows) |
| 43 | + # Second -> NRDOT 1.19.0 (canaries-nrdot-windows) |
| 44 | + AGENT_SPECS_WINDOWS: >- |
| 45 | + NRInfra:1.77.1:NjQyNTg2NXxOR0VQfEFHRU5UX0NPTkZJR1VSQVRJT05fVkVSU0lPTnwwMTlmNGNjNC0zNmU1LTdmMmQtYjIyMS1mM2ZjY2QzOTAwOTg |
| 46 | + NRDOT:1.19.0:NjQyNTg2NXxOR0VQfEFHRU5UX0NPTkZJR1VSQVRJT05fVkVSU0lPTnwwMTlmNGNjNC1kMTE0LTdmMzktYWRmZS02ZTY4ZWFiYWZkY2Y |
| 47 | +
|
| 48 | +jobs: |
| 49 | + rotate-config-deployment: |
| 50 | + name: Deploy next config in rotation (${{ matrix.environment }} / ${{ matrix.platform }}) |
| 51 | + runs-on: linux-4-core-nr-control |
| 52 | + strategy: |
| 53 | + # Every run deploys all environment/platform combinations; a failure on one |
| 54 | + # must not skip the others. |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + environment: [staging, production] |
| 58 | + platform: [linux, windows] |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 61 | + |
| 62 | + - name: Resolve fleet and select agent spec (rotating) |
| 63 | + id: target |
| 64 | + env: |
| 65 | + PLATFORM: ${{ matrix.platform }} |
| 66 | + ENVIRONMENT: ${{ matrix.environment }} |
| 67 | + run: | |
| 68 | + # Pick this platform's fleet id (per environment) and its ordered spec list. |
| 69 | + if [ "${PLATFORM}" = "windows" ]; then |
| 70 | + SPECS_STR="${AGENT_SPECS_WINDOWS}" |
| 71 | + if [ "${ENVIRONMENT}" = "production" ]; then |
| 72 | + FLEET_ID="${WINDOWS_FLEET_ID_PRODUCTION}" |
| 73 | + else |
| 74 | + FLEET_ID="${WINDOWS_FLEET_ID_STAGING}" |
| 75 | + fi |
| 76 | + else |
| 77 | + SPECS_STR="${AGENT_SPECS_LINUX}" |
| 78 | + if [ "${ENVIRONMENT}" = "production" ]; then |
| 79 | + FLEET_ID="${FLEET_ID_PRODUCTION}" |
| 80 | + else |
| 81 | + FLEET_ID="${FLEET_ID_STAGING}" |
| 82 | + fi |
| 83 | + fi |
| 84 | +
|
| 85 | + # Split the whitespace-separated specs. Each entry is a full |
| 86 | + # <agentType>:<version>:<configVersionId> spec. |
| 87 | + read -ra SPECS <<< "${SPECS_STR}" |
| 88 | + COUNT=${#SPECS[@]} |
| 89 | +
|
| 90 | + # github.run_number increments on every run of this workflow, so |
| 91 | + # ((run_number - 1) % COUNT) walks the set in order starting at the |
| 92 | + # first entry and wraps back to the first after the last. Both platforms |
| 93 | + # share the same run number, so they rotate to the same position. |
| 94 | + RUN_NUMBER=${{ github.run_number }} |
| 95 | + INDEX=$(( (RUN_NUMBER - 1) % COUNT )) |
| 96 | + SPEC="${SPECS[$INDEX]}" |
| 97 | +
|
| 98 | + echo "[${PLATFORM}] rotation: run #${RUN_NUMBER} -> index ${INDEX} of ${COUNT} -> ${SPEC}" |
| 99 | + echo "fleet_id=${FLEET_ID}" >> "$GITHUB_OUTPUT" |
| 100 | + echo "spec=${SPEC}" >> "$GITHUB_OUTPUT" |
| 101 | +
|
| 102 | + - name: Create and deploy fleet deployment |
| 103 | + env: |
| 104 | + NEW_RELIC_API_KEY: ${{ matrix.environment == 'production' && secrets.AC_PROD_E2E_API_KEY || secrets.AC_FC_STAG_E2E_API_KEY }} |
| 105 | + FLEET_ID: ${{ steps.target.outputs.fleet_id }} |
| 106 | + ENVIRONMENT: ${{ matrix.environment }} |
| 107 | + run: | |
| 108 | + chmod +x test/onhost-canaries/scripts/fleet_deployment.sh |
| 109 | + test/onhost-canaries/scripts/fleet_deployment.sh \ |
| 110 | + "${{ steps.target.outputs.spec }}" |
0 commit comments