# Canary Steps & Background Analysis

How a rollout progresses, and how the [analysis templates](analysis-templates.md) get run during it.

## Canary steps

`rolloutStrategy.canary.steps` is a list of Argo Rollouts canary steps, rendered into the `Rollout`'s
`spec.strategy.canary.steps`. The chart supports the standard step types plus a custom one:

| Step | Purpose |
|------|---------|
| `setCanaryScale` | Scale the canary ReplicaSet (e.g. `weight: 100` to bring it to full capacity before traffic shifts). |
| `pause` | Wait (`duration: 10m`) so background analysis can observe the new version. |
| `analysis` | Run one or more `AnalysisTemplate`s as a **step** (blocks until the run finishes). |
| `setAccountWeight` | **Custom** — shift account traffic to the canary via the canary-request-job. See [Canary request job](canary-request-job.md). |

Example:

```yaml
rolloutStrategy:
  canary:
    steps:
      - setCanaryScale:
          weight: 100
      - setAccountWeight:
          weight: 20
          type: enterprise_trial
      - pause:
          duration: 10m
      - setAccountWeight:
          weight: 100
          type: enterprise_trial
      - pause:
          duration: 10m
```

`setCanaryScale: { weight: 100 }` ensures the canary has full capacity before any traffic routing
begins. Each `setAccountWeight` then shifts a percentage of accounts (of a given type) to the canary;
`pause` between weights gives analysis time to react.

## Background analysis

`rolloutStrategy.canary.backgroundAnalysis` runs analysis **continuously** alongside the steps (rather
than only at a specific step), for the whole rollout. It's rendered verbatim under `spec.strategy.canary`,
so you list the templates you want by name:

```yaml
rolloutStrategy:
  canary:
    backgroundAnalysis:
      analysis:
        templates:
          - templateName: "jfrog-cpu-usage-analysis"
          - templateName: "jfrog-memory-usage-analysis"
          - templateName: "jfrog-coralogix-alerts"   # the alerts gate
        startingStep: 1     # delay analysis until step index 1
```

- The `templateName`s must match the `name`s of the [analysis templates](analysis-templates.md) you've
  enabled.
- Argo merges all listed templates into a **single AnalysisRun** that runs side by side; if **any** of
  them fails, the rollout aborts/rolls back.
- `startingStep` delays the background analysis until the rollout reaches that step index (e.g. wait
  until the canary is scaled up before measuring).
- For background analysis, templates use `count: 0` so the metric runs for the full rollout.

**Step analysis vs background analysis:** use a `- analysis:` *step* to gate at one point and block
until it finishes (good for a one-shot check between weight changes); use `backgroundAnalysis` to watch
continuously for the entire rollout (good for the CPU/memory regression checks and the Coralogix active-cases gate).
