← Back to Pull requests

fix: Do not fail autoscaling when workerVersion is unset #20868

Open
PDGGK opened this pull request with 198 lines diff across 5 files
View on GitHub
PDGGK PDGGK commented on Nov 09, 2026 15:19 UTC
Author

Fixes #18511.

Description

The autoscaler does nothing if druid.indexer.autoscale.workerVersion is not set. The docs list that property with a default of null and describe it as "If set, will only create nodes of set version", but ProvisioningUtil.createValidWorkerPredicate throws ISE: No minVersion found! when it is null. As soon as one worker is registered, doProvision and doTerminate fail with that exception on every run. The exception is caught and logged as Uncaught exception., so the Overlord keeps running but no node is ever added or removed. The reporter worked around it by setting the property to a version string.

With this change an unset workerVersion falls back to the runner's druid.indexer.runner.minWorkerVersion, the version that WorkerSelectUtils assigns tasks by. With its default of "0" this is the same check that task assignment already makes, and a disabled worker is still not valid. After minWorkerVersion is raised for a rolling update, workers on the old version count as invalid, so the autoscaler can terminate them and provision new ones. It no longer counts them toward maxNumWorkers and stalls, as a review pointed out it would if an unset workerVersion meant no minimum at all. The runner config is only read when workerVersion is unset, so nothing changes when it is set. ImmutableWorkerInfo.isValidVersion itself does not change. EC2AutoScaler already handles a null workerVersion, so nothing else needed to change for this property to be optional. The docs row for the property now describes the fallback.

On master, doProvision and doTerminate throw ISE: No minVersion found! with the property unset, the message from the issue. PendingTaskBasedProvisioningStrategyTest has five tests for the unset case. testProvisioningWithoutWorkerVersion and testTerminatingWithoutWorkerVersion use the default runner minWorkerVersion and old-version workers; they fail if an unset workerVersion makes every worker invalid (AutoScaler.provision(): expected: 1, actual: 2, and markWorkersLazy called with 2 instead of 1). testProvisioningWithoutWorkerVersionUsesRunnerMinWorkerVersion and testTerminatingWithoutWorkerVersionUsesRunnerMinWorkerVersion raise the runner's minWorkerVersion, with one old worker and minNumWorkers = 1 (and maxNumWorkers = 1 for provisioning); they fail if an unset workerVersion accepts any version. testValidWorkerPredicateWithoutWorkerVersion covers both cases and a disabled worker. PendingTaskBasedProvisioningStrategyTest and SimpleProvisioningStrategyTest pass with 32 tests, and checkstyle, PMD and forbidden-apis pass on indexing-service.

The tests use a mocked runner and autoscaler. I did not run this on a cluster or against GCE or EC2.

Release note

Worker autoscaling no longer fails with No minVersion found! when druid.indexer.autoscale.workerVersion is not set. In that case druid.indexer.runner.minWorkerVersion decides which workers are valid.

<hr>

##### Key changed/added classes in this PR
ProvisioningUtil
PendingTaskBasedWorkerProvisioningStrategy
* SimpleWorkerProvisioningStrategy

<hr>

This PR has:

  • been self-reviewed.

  • a release note entry in the PR description.

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • Diff: 198 lines (+176 / -22) across 5 files Reviewer: amaechler Review duration: 7371m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.41) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 198 lines diff across 5 files
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 5 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.317
    Real PR Conversation Timeline
    12 items
    FrankChen021 FrankChen021 commented on Nov 10, 2026 12:21 UTC
    Reviewer

    🟢 Approval recommended

    No actionable issues found. The optional workerVersion now acts as an unconstrained minimum while disabled workers remain invalid. The shared predicate and both provisioning call paths were inspected.

    Reviewed 2 of 2 changed files.

    Validation: git diff --check passed. No builds or tests were run; this was a static review.

    <!-- mergelens:review -->

    ---

    This is an automated review by Codex GPT-5.6-Luna(max)

    amaechler amaechler commented on code on Nov 10, 2026 14:26 UTC
    Code Review
    indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java:1
    @@ -34,11 +33,9 @@ public static Predicate<ImmutableWorkerInfo> createValidWorkerPredicate(
           @Override
           public boolean apply(ImmutableWorkerInfo worker)
           {
    +        // workerVersion is optional. Without it no worker is too old, but a disabled worker is still not valid.
             final String minVersion = config.getWorkerVersion();
    -        if (minVersion == null) {
    -          throw new ISE("No minVersion found! It should be set in your runtime properties or configuration database.");
    -        }
    -        return worker.isValidVersion(minVersion);
    +        return worker.isValidVersion(minVersion == null ? "" : minVersion);

    One setup stays stuck, now silently: workerVersion unset, druid.indexer.runner.minWorkerVersion raised for a rolling update, and the running workers still on the old version. This predicate now counts those workers as valid, but WorkerSelectUtils won't assign them tasks because of the runner's min version. They count toward maxNumWorkers and never count as invalid in maxWorkersToTerminate, so with minNumWorkers == maxNumWorkers the autoscaler neither provisions nor terminates, and the only signal is the Unable to provision more workers warning. Before this PR the same setup failed with the ISE, so it isn't a regression, just a quieter failure.

    I checked it with a scratch test: workerVersion unset, runner minWorkerVersion "2", min = max = 1, one idle worker on version "1", one pending task. doProvision() and doTerminate() both return false. With workerVersion "2" the same setup provisions a node.

    Would you be open to one of these?

  • When workerVersion is null, fall back to the runner's getMinWorkerVersion(). getWorkersNeededToAssignTasks already uses it for the dummy workers, and runner.getConfig() is available in both provisioners, so it would mean passing it into createValidWorkerPredicate.

  • Or keep the code as is and update the druid.indexer.autoscale.workerVersion row in docs/configuration/index.md. It still says "Overrides dynamic configuration", but that fallback no longer exists, and docs/operations/rolling-updates.md already says to set the property for rolling updates. Something like: "If set, the autoscaler only creates nodes of this version and treats running workers with an older version as invalid, so they can be terminated. If unset, workers of any version count as valid."
  • amaechler amaechler commented on code on Nov 10, 2026 14:26 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -732,6 +733,69 @@ public void testDoSuccessfulTerminate()
         EasyMock.verify(autoScaler);
       }
     
    +  @Test
    +  public void testProvisioningWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();

    This passes even if an unset workerVersion made every worker invalid: with min 1 and max 2, an invalid old worker also leads to exactly one provision(), so the test only checks that nothing throws. With min 2 the two cases differ (one provision vs two). I tried it against return minVersion != null && worker.isValidVersion(minVersion); and it fails with AutoScaler.provision(): expected: 1, actual: 2, while the fix still passes.

        EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(2).anyTimes();
    

    amaechler amaechler commented on code on Nov 10, 2026 14:26 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -732,6 +733,69 @@ public void testDoSuccessfulTerminate()
         EasyMock.verify(autoScaler);
       }
     
    +  @Test
    +  public void testProvisioningWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();
    +    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2).anyTimes();
    +    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.anyObject())).andReturn(new ArrayList<>()).anyTimes();
    +    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Collections.singletonList("fake")));
    +    final HttpRemoteTaskRunner runner = EasyMock.createMock(HttpRemoteTaskRunner.class);
    +    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Collections.singletonList(NoopTask.create()));
    +    EasyMock.expect(runner.getWorkers()).andReturn(
    +        Collections.singletonList(workerWithTask(testTask, "http", "h1", "n1", INVALID_VERSION))
    +    );
    +    EasyMock.expect(runner.getConfig()).andReturn(new HttpRemoteTaskRunnerConfig());
    +    EasyMock.replay(runner, autoScaler);
    +
    +    final Provisioner provisioner = strategy.makeProvisioner(runner);
    +
    +    Assertions.assertTrue(provisioner.doProvision());
    +    Assertions.assertEquals(ScalingStats.EVENT.PROVISION, provisioner.getStats().toList().get(0).getEvent());
    +    EasyMock.verify(autoScaler, runner);
    +  }
    +
    +  @Test
    +  public void testTerminatingWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();
    +    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.anyObject())).andReturn(new ArrayList<>()).anyTimes();
    +    EasyMock.expect(autoScaler.terminate(EasyMock.anyObject())).andReturn(new AutoScalingData(new ArrayList<>()));
    +    final HttpRemoteTaskRunner runner = EasyMock.createMock(HttpRemoteTaskRunner.class);
    +    EasyMock.expect(runner.getWorkers()).andReturn(
    +        ImmutableList.of(workerWithTask(testTask), workerWithTask(testTask))
    +    ).anyTimes();
    +    EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))

    Same here: with anyInt() and current-version workers, this passes whether the workers count as valid or not. With old-version workers and an exact count, the fix gives maxWorkersToTerminate = 0 invalid + min(2, 2 - 1) = 1, while an all-invalid predicate gives 2 and fails.

        EasyMock.expect(runner.getWorkers()).andReturn(
            ImmutableList.of(
                workerWithTask(testTask, "http", "h1", "n1", INVALID_VERSION),
                workerWithTask(testTask, "http", "h2", "n2", INVALID_VERSION)
            )
        ).anyTimes();
        EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.eq(1)))
    

    amaechler amaechler commented on code on Nov 10, 2026 14:26 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -917,6 +981,21 @@ public void testNullWorkerConfig()
         EasyMock.verify(runner);
       }
     
    +  private void useConfigWithoutWorkerVersion()
    +  {
    +    config = new PendingTaskBasedWorkerProvisioningConfig()
    +        .setMaxScalingDuration(new Period(1000))
    +        .setNumEventsToTrack(10)
    +        .setPendingTaskTimeout(new Period(0))
    +        .setMaxScalingStep(2);
    +    strategy = new PendingTaskBasedWorkerProvisioningStrategy(
    +        config,
    +        DSuppliers.of(workerConfig),
    +        new ProvisioningSchedulerConfig(),
    +        () -> executorService
    +    );
    +  }
    +

    nit: the strategy holds this same config object and the predicate reads getWorkerVersion() on every apply(), so config.setWorkerVersion(null); in the two tests does the same job and this helper can go. With that change the tests pass on the fix and still fail with No minVersion found! on the old code.

    PDGGK PDGGK commented on code on Nov 12, 2026 11:08 UTC
    Code Review
    indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java:1
    @@ -34,11 +33,9 @@ public static Predicate<ImmutableWorkerInfo> createValidWorkerPredicate(
           @Override
           public boolean apply(ImmutableWorkerInfo worker)
           {
    +        // workerVersion is optional. Without it no worker is too old, but a disabled worker is still not valid.
             final String minVersion = config.getWorkerVersion();
    -        if (minVersion == null) {
    -          throw new ISE("No minVersion found! It should be set in your runtime properties or configuration database.");
    -        }
    -        return worker.isValidVersion(minVersion);
    +        return worker.isValidVersion(minVersion == null ? "" : minVersion);

    Thanks for checking that setup. I went with the first option in cda30f4. When workerVersion is unset, the predicate now uses runner.getConfig().getMinWorkerVersion(), so a worker the runner won't assign tasks to counts as invalid and can be terminated. getConfig() is only read when workerVersion is null, so the existing tests needed no new expectations.

    Your setup is now two tests: testProvisioningWithoutWorkerVersionUsesRunnerMinWorkerVersion (min = max = 1, runner minWorkerVersion raised, one old idle worker, one pending task: it provisions) and testTerminatingWithoutWorkerVersionUsesRunnerMinWorkerVersion (the old worker is offered for termination although it is the only one). If an unset workerVersion accepts any version, both fail, together with the predicate test.

    I also updated the druid.indexer.autoscale.workerVersion row along the lines you suggested, with the fallback in place of "workers of any version count as valid".

    PDGGK PDGGK commented on code on Nov 12, 2026 11:08 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -732,6 +733,69 @@ public void testDoSuccessfulTerminate()
         EasyMock.verify(autoScaler);
       }
     
    +  @Test
    +  public void testProvisioningWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();

    Applied in cda30f4. With every worker invalid it now fails with AutoScaler.provision(): expected: 1, actual: 2.

    PDGGK PDGGK commented on code on Nov 12, 2026 11:08 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -732,6 +733,69 @@ public void testDoSuccessfulTerminate()
         EasyMock.verify(autoScaler);
       }
     
    +  @Test
    +  public void testProvisioningWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();
    +    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2).anyTimes();
    +    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.anyObject())).andReturn(new ArrayList<>()).anyTimes();
    +    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Collections.singletonList("fake")));
    +    final HttpRemoteTaskRunner runner = EasyMock.createMock(HttpRemoteTaskRunner.class);
    +    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Collections.singletonList(NoopTask.create()));
    +    EasyMock.expect(runner.getWorkers()).andReturn(
    +        Collections.singletonList(workerWithTask(testTask, "http", "h1", "n1", INVALID_VERSION))
    +    );
    +    EasyMock.expect(runner.getConfig()).andReturn(new HttpRemoteTaskRunnerConfig());
    +    EasyMock.replay(runner, autoScaler);
    +
    +    final Provisioner provisioner = strategy.makeProvisioner(runner);
    +
    +    Assertions.assertTrue(provisioner.doProvision());
    +    Assertions.assertEquals(ScalingStats.EVENT.PROVISION, provisioner.getStats().toList().get(0).getEvent());
    +    EasyMock.verify(autoScaler, runner);
    +  }
    +
    +  @Test
    +  public void testTerminatingWithoutWorkerVersion()
    +  {
    +    useConfigWithoutWorkerVersion();
    +    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).anyTimes();
    +    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.anyObject())).andReturn(new ArrayList<>()).anyTimes();
    +    EasyMock.expect(autoScaler.terminate(EasyMock.anyObject())).andReturn(new AutoScalingData(new ArrayList<>()));
    +    final HttpRemoteTaskRunner runner = EasyMock.createMock(HttpRemoteTaskRunner.class);
    +    EasyMock.expect(runner.getWorkers()).andReturn(
    +        ImmutableList.of(workerWithTask(testTask), workerWithTask(testTask))
    +    ).anyTimes();
    +    EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))

    Applied in cda30f4. With every worker invalid, markWorkersLazy is called with 2 and the test fails on the eq(1) expectation.

    PDGGK PDGGK commented on code on Nov 12, 2026 11:08 UTC
    Code Review
    indexing-service/src/test/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedProvisioningStrategyTest.java:1
    @@ -917,6 +981,21 @@ public void testNullWorkerConfig()
         EasyMock.verify(runner);
       }
     
    +  private void useConfigWithoutWorkerVersion()
    +  {
    +    config = new PendingTaskBasedWorkerProvisioningConfig()
    +        .setMaxScalingDuration(new Period(1000))
    +        .setNumEventsToTrack(10)
    +        .setPendingTaskTimeout(new Period(0))
    +        .setMaxScalingStep(2);
    +    strategy = new PendingTaskBasedWorkerProvisioningStrategy(
    +        config,
    +        DSuppliers.of(workerConfig),
    +        new ProvisioningSchedulerConfig(),
    +        () -> executorService
    +    );
    +  }
    +

    Done in cda30f4: the helper is gone and the tests call config.setWorkerVersion(null).

    FrankChen021 FrankChen021 commented on Nov 12, 2026 12:38 UTC
    Reviewer

    🟢 Approval recommended

    The fallback to druid.indexer.runner.minWorkerVersion is consistently applied across provisioning and termination paths. The prior approval review had no findings, and the incremental changes were rechecked against the full diff and surrounding worker-selection code.

    Reviewed 5 of 5 changed files. Validation: git diff --check passed. No builds or tests were run.

    <!-- mergelens:review -->

    ---

    This is an automated review by Codex GPT-5.6-Luna(max)

    amaechler amaechler approved these changes on Nov 12, 2026 15:35 UTC
    Approved Reviewer

    🐻

    Reviewers
    Assignees
    PDGGK PDGGK
    Labels
    risk: low confidence: 90.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.5% (MEDIUM) · Higher = larger blast radius
    40.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.5% · Lower = rushed or shallow review
    90.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.9% · Safe to merge
    3.9%
    Repository