Skip to content

Allow workers to be paused and scaled to zero when they are being man… - #177

Open
PedroMiguelFMoreira wants to merge 2 commits into
n8n-io:mainfrom
PedroMiguelFMoreira:pause-workers-setting
Open

Allow workers to be paused and scaled to zero when they are being man…#177
PedroMiguelFMoreira wants to merge 2 commits into
n8n-io:mainfrom
PedroMiguelFMoreira:pause-workers-setting

Conversation

@PedroMiguelFMoreira

@PedroMiguelFMoreira PedroMiguelFMoreira commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

Adds a keda.worker.pause setting to the n8n Helm chart so worker KEDA autoscaling can be paused and workers scaled to zero via ScaledObject annotations.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Example/configuration update
  • CI/CD improvements

Related Issues

Fixes # N/A
Relates to # N/A

Changes Made

  • Added keda.worker.pause (true/false, default false) to control KEDA worker autoscaling pause behavior
  • When pause is true, the worker ScaledObject sets autoscaling.keda.sh/paused: "true" and autoscaling.keda.sh/paused-replicas: "0" to scale workers to zero and pause autoscaling
  • Updated README and the KEDA autoscaling example to document the new setting

Testing Performed

  • Rendered the worker ScaledObject with keda.worker.pause enabled and disabled

Chart Validation

  • helm lint charts/n8n passes
  • ./scripts/validate-examples.sh passes
  • Template rendering works with all examples

Deployment Testing (if applicable)

  • Tested with minimal configuration
  • Tested with production configuration
  • Tested upgrade path from previous version
  • All pods start successfully
  • Application is accessible

Specific Testing for Changes

Describe any specific testing you performed for your changes:

  • Rendered the chart with keda.enabled=true and keda.worker.pause=false to confirm pause annotations are omitted.
  • Rendered the chart with keda.worker.pause=true to confirm both autoscaling.keda.sh/paused: "true" and autoscaling.keda.sh/paused-replicas: "0" are set on the worker ScaledObject.

Breaking Changes

If this includes breaking changes, describe what they are and provide migration instructions:

  • None. The new setting defaults to false, so existing KEDA worker ScaledObjects continue to behave as before.

Documentation Updates

  • Updated Chart.yaml version (if needed)
  • Updated CHANGELOG.md
  • Updated README.md (if needed)
  • Updated examples (if needed)
  • Updated CONTRIBUTING.md (if needed)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added examples that demonstrate the changes (if applicable)
  • All new and existing tests pass

Screenshots (if applicable)

Not applicable.

Additional Notes

This change is backward compatible because keda.worker.pause defaults to false and only adds pause annotations when explicitly enabled.


Summary by cubic

Adds keda.worker.pause to the Helm chart to pause KEDA worker autoscaling and scale workers to zero via ScaledObject annotations. This lets you temporarily stop workers without removing KEDA.

  • New Features
    • New value: keda.worker.pause (default false).
    • When true, adds autoscaling.keda.sh/paused: "true" and autoscaling.keda.sh/paused-replicas: "0" to the worker ScaledObject and merges with commonAnnotations.
    • Updated README and keda-autoscaling.yaml example.

Written for commit 48132a2. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Architecture diagram
sequenceDiagram
    participant Admin as Administrator
    participant Helm as Helm Chart
    participant K8s as Kubernetes
    participant KEDA as KEDA Operator
    participant Worker as Worker Pods

    Note over Admin,Worker: NEW: Worker Pause/Zero-Scale Flow
    
    Admin->>Helm: Set keda.worker.pause=true
    Helm->>K8s: Render ScaledObject template
    
    alt pause=true
        Helm->>K8s: NEW: Add annotations<br/>autoscaling.keda.sh/paused: "true"<br/>autoscaling.keda.sh/paused-replicas: "0"
    else pause=false (default)
        Helm->>K8s: Omit pause annotations<br/>(existing behavior)
    end
    
    K8s-->>KEDA: Watch ScaledObject
    KEDA->>KEDA: Detect pause annotation
    
    alt pause=true
        KEDA->>Worker: Scale to 0 replicas
        Worker-->>K8s: Terminate worker pods
        KEDA->>KEDA: Pause autoscaling triggers
    else pause=false
        KEDA->>K8s: Monitor queue (existing)
        K8s-->>KEDA: Queue depth
        KEDA->>KEDA: Normal autoscaling logic
    end
    
    Note over KEDA,Worker: Unpause Flow
    Admin->>Helm: Set keda.worker.pause=false
    Helm->>K8s: Remove pause annotations
    KEDA->>KEDA: Resume autoscaling
    KEDA->>Worker: Scale to minReplicaCount
Loading

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread charts/n8n/templates/scaledobject-worker.yaml Outdated
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant