Skip to content

feat(SLSRE-704): add scale.extraMachinePools for additional capacity reservation#617

Open
Ajpantuso wants to merge 2 commits into
openshift:masterfrom
Ajpantuso:apantuso/SLSRE-704
Open

feat(SLSRE-704): add scale.extraMachinePools for additional capacity reservation#617
Ajpantuso wants to merge 2 commits into
openshift:masterfrom
Ajpantuso:apantuso/SLSRE-704

Conversation

@Ajpantuso
Copy link
Copy Markdown
Contributor

@Ajpantuso Ajpantuso commented May 21, 2026

Summary

  • Adds a new scale.extraMachinePools ConfigMap field (list of glob patterns) to select additional MachineSets beyond the default worker pool for capacity reservation scaling during upgrades.
  • Enables management clusters to scale non-serving MachineSets (e.g. non-serving-*) alongside workers, controlled per-cluster via the operator ConfigMap.
  • Worker and extra pool scaling are independent: either can proceed without the other. Extra pool scaling is best-effort — failures are logged but do not block the upgrade.

Changes

pkg/upgraders/config.go: Added ExtraMachinePools []string to scaleConfig, with glob pattern validation via path.Match. Wired Scale.IsValid() into the upgraderConfig.IsValid() chain so invalid patterns fail at upgrader construction time.

pkg/scaler/scaler.go: Updated Scaler interface — EnsureScaleUpNodes now accepts a []string parameter for extra pool patterns.

pkg/scaler/machineSetScaler.go: Added LABEL_MACHINE_POOL constant and listMachineSetsByPoolPatterns() helper (lists MachineSets with hive.openshift.io/machine-pool label, filters by glob, excludes worker). Restructured EnsureScaleUpNodes so worker and extra pool fetching are independent.

pkg/upgraders/scalerstep.go: Threads ExtraMachinePools into EnsureScaleUpNodes. When CanScale returns false (no worker MachineSets) but extra pools are configured, scaling proceeds with extra pools only instead of skipping entirely.

Tests: 8 new scaler tests, 2 new scalerstep tests, 12 new config validation tests. All existing tests updated for the new interface.

docs/configmap.md: Documented the new extraMachinePools field with description and YAML example.

Configuration

scale:
  timeOut: 30
  extraMachinePools:
    - "non-serving-*"

When extraMachinePools is empty or absent, behavior is identical to the current implementation — only the default worker pool is scaled. Patterns use Go's path.Match syntax.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added extraMachinePools configuration option enabling capacity reservation to scale additional machine pools beyond workers using glob pattern matching.
  • Documentation

    • Updated configuration documentation with details on the new extraMachinePools knob and usage examples.
  • Tests

    • Added comprehensive test coverage for extra machine pool scaling scenarios and configuration validation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Walkthrough

This PR extends the managed upgrade operator's scaling subsystem to support additional machine pool pools beyond workers. The Scaler interface signature expands to accept glob patterns for optional extra pools. Configuration validation ensures pattern correctness, the core scaler aggregates MachineSets from workers and matching pools, and the scaling step conditionally proceeds even when standard scaling is unavailable if extra pools are configured.

Changes

Extra Machine Pool Scaling

Layer / File(s) Summary
Interface contract and scaler constant
pkg/scaler/scaler.go, pkg/scaler/machineSetScaler.go
The Scaler interface method EnsureScaleUpNodes now accepts an extraMachinePools []string parameter. Export LABEL_MACHINE_POOL constant to centralize the machine pool label key, and add path import for glob matching.
Configuration field and validation
pkg/upgraders/config.go, pkg/upgraders/config_test.go
Add ExtraMachinePools []string field to scaleConfig populated from YAML. Implement validation using path.Match to reject invalid glob patterns. Wire scaleConfig.IsValid() into the upgrader config validation. Test all validation paths including invalid patterns and valid glob forms.
Scaler refactoring: worker + extra pools
pkg/scaler/machineSetScaler.go
Refactor EnsureScaleUpNodes to aggregate MachineSets from workers and optional glob-matched extra pools, returning an error if no MachineSets are found. Add listMachineSetsByPoolPatterns helper to filter MachineSets by pool label and glob patterns. Update CanScale to use the LABEL_MACHINE_POOL constant.
Scaler tests: signature and behavior updates
pkg/scaler/scaling_test.go
Update all existing tests to use LABEL_MACHINE_POOL, pass the new extraMachinePools argument (as nil in worker-only scenarios), and add a comprehensive test context verifying worker+extra pool creation, error resilience when only workers or only extra pools match, pattern matching via glob, deduplication, and equivalence when extra pools is nil.
Scaler step: conditional scaling logic
pkg/upgraders/scalerstep.go
Update EnsureExtraUpgradeWorkers to skip early only when scaling is unavailable and no extra pools are configured; proceed with scaling if extra pools exist. Similarly gate RemoveExtraScaledNodes to continue when extra pools are configured. Pass config.Scale.ExtraMachinePools to the scaler.
Scaler step tests: signature and conditional logic
pkg/upgraders/scalerstep_test.go
Update mock expectations to pass the extra pools argument in successful and timeout test cases. Add test context verifying scale-up and scale-down operations proceed when extra pools are configured, even if CanScale returns false, including drain-strategy setup and metric updates.
Generated mock updates
pkg/scaler/mocks/scaler.go
Regenerate MockScaler interface and MockScalerMockRecorder to accept the additional []string parameter in EnsureScaleUpNodes.

Documentation and team updates

Layer / File(s) Summary
Configuration docs and team membership
docs/configmap.md, OWNERS_ALIASES
Document the extraMachinePools knob, explaining it accepts glob patterns for additional machine pools and providing an example. Update the functional team alias roster.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning config_test.go imports Ginkgo v1 instead of v2; scalerstep_test.go lacks assertion failure messages (lines 176-189) and uses gomock.Any() instead of asserting ExtraMachinePools value (line 172). Update config_test.go to import Ginkgo v2; add failure messages to scalerstep_test.go assertions; use gomock.Eq(config.Scale.ExtraMachinePools) instead of gomock.Any() at line 172.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and clearly describes the main change: adding a new scale.extraMachinePools configuration feature for additional capacity reservation during upgrades.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All Ginkgo test titles in the PR use stable, deterministic strings with no dynamic content like generated suffixes, timestamps, UUIDs, or variable interpolation.
Microshift Test Compatibility ✅ Passed The new Ginkgo tests added (config_test.go, scaling_test.go, scalerstep_test.go) are unit tests with mocked clients, not e2e tests. The MicroShift compatibility check applies only to e2e tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds only unit tests (not e2e tests) in pkg/ directories using mocks/gomock to test operator logic in isolation. No new e2e tests targeting OpenShift clusters were added.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds MachineSet scaling for extra pools at infrastructure level. No pod scheduling constraints, affinity rules, topology spread constraints, or node selectors introduced. Code is topology-agnostic.
Ote Binary Stdout Contract ✅ Passed No stdout writes detected in production code. All logging uses logr framework (logger.Info/Error); fmt.Sprintf only formats log messages; fmt.Errorf returns errors, not stdout.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New unit tests in config_test.go, scalerstep_test.go, and scaling_test.go contain no IPv4 assumptions, hardcoded IPs, or external connectivity requirements. All tests use mocks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from Tafhim and vaidehi411 May 21, 2026 16:23
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ajpantuso
Once this PR has been reviewed and has the lgtm label, please assign theautoroboto for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

@Ajpantuso: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/scaler/machineSetScaler.go (1)

272-285: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid early return when one upgrade MachineSet already exists.

Returning immediately on the first existing *-upgrade MachineSet prevents creating other missing upgrade MachineSets in the same reconcile loop (partial state never converges reliably).

Suggested fix
 func extraMachineSetCreated(c client.Client, originalMachinesets, upgradeMachinesets machineapi.MachineSetList, logger logr.Logger) (bool, error) {
+	createdAny := false
 	for _, ms := range originalMachinesets.Items {
 
 		found := false
 		for _, ums := range upgradeMachinesets.Items {
 			if ums.Name == ms.Name+"-upgrade" {
 				found = true
 			}
 		}
 		// extra machine already created
 		if found {
 			logger.Info(fmt.Sprintf("machineset for upgrade already created :%s", ms.Name))
-			return false, nil
+			continue
 		}
@@
 		err := c.Create(context.TODO(), newMs)
 		if err != nil {
 			logger.Error(err, "failed to create machineset")
 			return false, err
 		}
+		createdAny = true
 	}
 
-	return true, nil
+	return createdAny, nil
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/scaler/machineSetScaler.go` around lines 272 - 285, The function
extraMachineSetCreated currently returns immediately when it finds the first
original MachineSet that already has a corresponding "*-upgrade" MachineSet,
which prevents checking the rest; change the logic in extraMachineSetCreated to
avoid early returns inside the loop over originalMachinesets: for each ms in
originalMachinesets.Items, check upgradeMachinesets.Items and log if an upgrade
exists (using logger.Info and ms.Name) but do not return; instead track whether
any originals are missing their corresponding "*-upgrade" (e.g., increment a
missing counter or set a allExist boolean) and after the loop finishes return a
single result (bool, error) that reflects whether all upgrade MachineSets exist
(or not) and any error encountered. Ensure you update the return sites to use
that aggregated flag and keep references to extraMachineSetCreated,
originalMachinesets, upgradeMachinesets, ms and logger to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/configmap.md`:
- Line 103: The fenced code block containing the config snippet for the scale
section is unlabeled and triggers markdownlint MD040; update the opening fence
from ``` to ```yaml so the block is language-identified (the block that contains
the scale/timeOut/extraMachinePools snippet), ensuring the fenced example is
declared as YAML.

In `@pkg/upgraders/config_test.go`:
- Around line 4-5: Update the Ginkgo import in the test file to use Ginkgo v2 by
changing the import path from "github.com/onsi/ginkgo" to
"github.com/onsi/ginkgo/v2" (the dotted import used at the top of
pkg/upgraders/config_test.go), so the test uses the v2 API consistently with
other *_test.go files; ensure the companion Gomega import stays unchanged.

In `@pkg/upgraders/scalerstep_test.go`:
- Around line 176-177: Add concise failure messages to the new Ginkgo assertions
so CI failures are actionable: update the two assertions
Expect(err).To(Not(HaveOccurred())) and Expect(ok).To(BeTrue()) (and the similar
pair at the other location) to include short message strings as the final
argument, e.g. Expect(err).To(Not(HaveOccurred()), "unexpected error from
<operation/context>") and Expect(ok).To(BeTrue(), "expected ok to be true after
<operation/context>"), replacing <operation/context> with the specific operation
being tested in scalerstep_test.go.
- Line 172: The mock expectation uses gomock.Any() for the new []string
ExtraMachinePools argument which hides regressions; update the
EnsureScaleUpNodes expectation on mockScalerClient to assert the exact forwarded
slice instead of gomock.Any() — compute or reference the expected extra pools in
the test and replace the gomock.Any() argument with
gomock.Eq(expectedExtraMachinePools) (or gomock.ElementsMatch/DeepEqual
equivalent) so EnsureScaleUpNodes(..., config.GetScaleDuration(),
expectedExtraMachinePools, ...) verifies the forwarded ExtraMachinePools value.

---

Outside diff comments:
In `@pkg/scaler/machineSetScaler.go`:
- Around line 272-285: The function extraMachineSetCreated currently returns
immediately when it finds the first original MachineSet that already has a
corresponding "*-upgrade" MachineSet, which prevents checking the rest; change
the logic in extraMachineSetCreated to avoid early returns inside the loop over
originalMachinesets: for each ms in originalMachinesets.Items, check
upgradeMachinesets.Items and log if an upgrade exists (using logger.Info and
ms.Name) but do not return; instead track whether any originals are missing
their corresponding "*-upgrade" (e.g., increment a missing counter or set a
allExist boolean) and after the loop finishes return a single result (bool,
error) that reflects whether all upgrade MachineSets exist (or not) and any
error encountered. Ensure you update the return sites to use that aggregated
flag and keep references to extraMachineSetCreated, originalMachinesets,
upgradeMachinesets, ms and logger to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 86c3fe33-669d-4e33-b8b3-0013d2ba0198

📥 Commits

Reviewing files that changed from the base of the PR and between 2c004ef and 3fe033f.

⛔ Files ignored due to path filters (4)
  • boilerplate/_data/last-boilerplate-commit is excluded by !boilerplate/**
  • boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES is excluded by !boilerplate/**
  • build/Dockerfile is excluded by !build/**
  • build/Dockerfile.olm-registry is excluded by !build/**
📒 Files selected for processing (10)
  • OWNERS_ALIASES
  • docs/configmap.md
  • pkg/scaler/machineSetScaler.go
  • pkg/scaler/mocks/scaler.go
  • pkg/scaler/scaler.go
  • pkg/scaler/scaling_test.go
  • pkg/upgraders/config.go
  • pkg/upgraders/config_test.go
  • pkg/upgraders/scalerstep.go
  • pkg/upgraders/scalerstep_test.go

Comment thread docs/configmap.md
| `extraMachinePools` | optional list of glob patterns matching additional `hive.openshift.io/machine-pool` label values whose MachineSets should also be scaled up during capacity reservation (e.g. `non-serving-*`). Patterns use Go's `path.Match` syntax. When empty or absent, only the default `worker` pool is scaled. |

Example:
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a language identifier to the fenced example block.

Line 103 uses an unlabeled fenced code block, which triggers markdownlint MD040. Use ```yaml for this config snippet.

Proposed fix
-```
+```yaml
     scale:
       timeOut: 30
       extraMachinePools:
         - "non-serving-*"
</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>

[warning] 103-103: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/configmap.md at line 103, The fenced code block containing the config
snippet for the scale section is unlabeled and triggers markdownlint MD040;
update the opening fence from toyaml so the block is language-identified
(the block that contains the scale/timeOut/extraMachinePools snippet), ensuring
the fenced example is declared as YAML.


</details>

<!-- fingerprinting:phantom:triton:hawk -->

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +4 to +5
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether *_test.go files still import Ginkgo v1.
rg -n --type=go 'github.com/onsi/ginkgo"' -g '**/*_test.go'
rg -n --type=go 'github.com/onsi/ginkgo/v2"' -g '**/*_test.go'

Repository: openshift/managed-upgrade-operator

Length of output: 4763


Use Ginkgo v2 in pkg/upgraders/config_test.go

pkg/upgraders/config_test.go imports . "github.com/onsi/ginkgo" (v1) at line 4; switch to . "github.com/onsi/ginkgo/v2" to match the *_test.go Ginkgo v2 guideline.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/upgraders/config_test.go` around lines 4 - 5, Update the Ginkgo import in
the test file to use Ginkgo v2 by changing the import path from
"github.com/onsi/ginkgo" to "github.com/onsi/ginkgo/v2" (the dotted import used
at the top of pkg/upgraders/config_test.go), so the test uses the v2 API
consistently with other *_test.go files; ensure the companion Gomega import
stays unchanged.

gomock.InOrder(
mockCVClient.EXPECT().HasUpgradeCommenced(gomock.Any()).Return(false, nil),
mockScalerClient.EXPECT().CanScale(gomock.Any(), gomock.Any()).Return(false, nil),
mockScalerClient.EXPECT().EnsureScaleUpNodes(gomock.Any(), config.GetScaleDuration(), gomock.Any(), gomock.Any()).Return(true, nil),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -nP 'EnsureScaleUpNodes\([^)]*gomock\.Any\(\)\)\.Return' pkg/upgraders/scalerstep_test.go

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/upgraders/scalerstep_test.go"

echo "== EnsureScaleUpNodes occurrences =="
rg -n "EnsureScaleUpNodes" "$FILE" || true

echo
echo "== Import block (first ~80 lines) =="
sed -n '1,90p' "$FILE" | nl -ba

echo
echo "== Assertions around lines ~150-220 =="
sed -n '140,230p' "$FILE" | nl -ba

echo
echo "== HaveOccurred() assertions without messages (best-effort) =="
rg -n "HaveOccurred\\(\\)" "$FILE" || true

Repository: openshift/managed-upgrade-operator

Length of output: 689


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/upgraders/scalerstep_test.go"

echo "== Import block =="
sed -n '1,120p' "$FILE" | cat -n

echo
echo "== Assertions/expect blocks near 140-230 =="
sed -n '130,240p' "$FILE" | cat -n

echo
echo "== HaveOccurred() / NotTo(HaveOccurred()) occurrences (best-effort) =="
rg -n "NotTo\\(HaveOccurred\\(\\)\\)|To\\(HaveOccurred\\(\\)\\)|HaveOccurred\\(\\)" "$FILE" || true

Repository: openshift/managed-upgrade-operator

Length of output: 10827


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "type .*Scaler.*interface|EnsureScaleUpNodes" -S pkg/scaler pkg/upgraders | head -n 50

echo "== Search in scaler interface =="
rg -n "EnsureScaleUpNodes" pkg/scaler --glob='*.go'

echo
echo "== Search in scaler mock interface =="
rg -n "EnsureScaleUpNodes" pkg/scaler/mocks --glob='*.go'

echo
echo "== Show relevant parts of mock file =="
MOCKFILE=$(rg -l "EnsureScaleUpNodes" pkg/scaler/mocks --glob='*.go' | head -n 1 || true)
if [[ -n "${MOCKFILE:-}" ]]; then
  echo "Mock file: $MOCKFILE"
  sed -n '1,200p' "$MOCKFILE" | cat -n
else
  echo "No mock file found containing EnsureScaleUpNodes"
fi

Repository: openshift/managed-upgrade-operator

Length of output: 12210


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/upgraders/scalerstep_test.go"

echo "== buildTestUpgraderConfig definition =="
rg -n "func buildTestUpgraderConfig\\b|buildTestUpgraderConfig\\(" "$FILE"

if rg -q "func buildTestUpgraderConfig\\b" "$FILE"; then
  # print around the function if present in this file
  FUNC_LINE=$(rg -n "func buildTestUpgraderConfig\\b" "$FILE" | head -n1 | cut -d: -f1)
  START=$((FUNC_LINE-20))
  END=$((FUNC_LINE+80))
  sed -n "${START},${END}p" "$FILE" | cat -n
else
  # search for it in package
  rg -n "func buildTestUpgraderConfig\\b" pkg/upgraders | head -n 20
fi

echo
echo "== ExtraMachinePools assignment in this test file =="
rg -n "ExtraMachinePools\\s*=" "$FILE"

Repository: openshift/managed-upgrade-operator

Length of output: 491


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect buildTestUpgraderConfig defaults
SUITE_FILE="pkg/upgraders/upgraders_suite_test.go"
echo "== buildTestUpgraderConfig in $SUITE_FILE =="
rg -n "func buildTestUpgraderConfig\\b" "$SUITE_FILE"
FUNC_LINE=$(rg -n "func buildTestUpgraderConfig\\b" "$SUITE_FILE" | head -n1 | cut -d: -f1)
START=$((FUNC_LINE-30)); END=$((FUNC_LINE+120))
sed -n "${START},${END}p" "$SUITE_FILE" | cat -n

echo
echo "== Ginkgo imports in suite file =="
sed -n '1,80p' "$SUITE_FILE" | cat -n

# 2) Inspect go.mod for Ginkgo version
echo
echo "== go.mod ginkgo references =="
if [[ -f go.mod ]]; then
  rg -n "ginkgo" go.mod || true
  rg -n "onsi/ginkgo" go.mod || true
fi

Repository: openshift/managed-upgrade-operator

Length of output: 2146


🏁 Script executed:

#!/bin/bash
set -euo pipefail

SUITE_FILE="pkg/upgraders/upgraders_suite_test.go"

echo "== Function line for buildTestUpgraderConfig =="
FUNC_LINE=$(rg -n "func buildTestUpgraderConfig\\b" "$SUITE_FILE" | head -n1 | cut -d: -f1)
echo "FUNC_LINE=$FUNC_LINE"

START=$((FUNC_LINE-10))
END=$((FUNC_LINE+120))
echo "== buildTestUpgraderConfig context lines ${START}-${END} =="
sed -n "${START},${END}p" "$SUITE_FILE" | cat -n

echo
echo "== Suite file imports (top 60 lines) =="
sed -n '1,60p' "$SUITE_FILE" | cat -n

echo
echo "== go.mod ginkgo references =="
rg -n "ginkgo|onsi/ginkgo" go.mod || true

Repository: openshift/managed-upgrade-operator

Length of output: 2490


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "type (scaleConfig|upgraderConfig) struct|ExtraMachinePools" pkg/upgraders | head -n 50
rg -n "ExtraMachinePools" pkg/upgraders | head -n 50

Repository: openshift/managed-upgrade-operator

Length of output: 2929


Assert forwarded ExtraMachinePools value in the EnsureScaleUpNodes mock expectation.
gomock.Any() for the new []string argument can hide regressions where incorrect extra machine pool patterns are forwarded.

Suggested test tightening
- mockScalerClient.EXPECT().EnsureScaleUpNodes(gomock.Any(), config.GetScaleDuration(), gomock.Any(), gomock.Any()).Return(true, nil),
+ mockScalerClient.EXPECT().EnsureScaleUpNodes(
+   gomock.Any(),
+   config.GetScaleDuration(),
+   gomock.Any(),
+   gomock.Eq(config.Scale.ExtraMachinePools),
+ ).Return(true, nil),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mockScalerClient.EXPECT().EnsureScaleUpNodes(gomock.Any(), config.GetScaleDuration(), gomock.Any(), gomock.Any()).Return(true, nil),
mockScalerClient.EXPECT().EnsureScaleUpNodes(
gomock.Any(),
config.GetScaleDuration(),
gomock.Any(),
gomock.Eq(config.Scale.ExtraMachinePools),
).Return(true, nil),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/upgraders/scalerstep_test.go` at line 172, The mock expectation uses
gomock.Any() for the new []string ExtraMachinePools argument which hides
regressions; update the EnsureScaleUpNodes expectation on mockScalerClient to
assert the exact forwarded slice instead of gomock.Any() — compute or reference
the expected extra pools in the test and replace the gomock.Any() argument with
gomock.Eq(expectedExtraMachinePools) (or gomock.ElementsMatch/DeepEqual
equivalent) so EnsureScaleUpNodes(..., config.GetScaleDuration(),
expectedExtraMachinePools, ...) verifies the forwarded ExtraMachinePools value.

Comment on lines +176 to +177
Expect(err).To(Not(HaveOccurred()))
Expect(ok).To(BeTrue())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add failure messages to new expectations for debuggability.

The new assertions omit failure context; include short messages so CI failures are actionable.

As per coding guidelines Ginkgo test code quality rule: assertions should include meaningful failure messages, and assertions like Expect(err).NotTo(HaveOccurred()) without messages should be flagged.

Also applies to: 188-189

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/upgraders/scalerstep_test.go` around lines 176 - 177, Add concise failure
messages to the new Ginkgo assertions so CI failures are actionable: update the
two assertions Expect(err).To(Not(HaveOccurred())) and Expect(ok).To(BeTrue())
(and the similar pair at the other location) to include short message strings as
the final argument, e.g. Expect(err).To(Not(HaveOccurred()), "unexpected error
from <operation/context>") and Expect(ok).To(BeTrue(), "expected ok to be true
after <operation/context>"), replacing <operation/context> with the specific
operation being tested in scalerstep_test.go.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.64286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.27%. Comparing base (2c004ef) to head (3fe033f).

Files with missing lines Patch % Lines
pkg/scaler/machineSetScaler.go 95.23% 1 Missing and 1 partial ⚠️
pkg/upgraders/scalerstep.go 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #617      +/-   ##
==========================================
+ Coverage   53.59%   54.27%   +0.67%     
==========================================
  Files         123      123              
  Lines        6165     6204      +39     
==========================================
+ Hits         3304     3367      +63     
+ Misses       2668     2631      -37     
- Partials      193      206      +13     
Files with missing lines Coverage Δ
pkg/scaler/mocks/scaler.go 100.00% <100.00%> (+27.27%) ⬆️
pkg/scaler/scaler.go 38.88% <ø> (ø)
pkg/upgraders/config.go 62.79% <100.00%> (+15.42%) ⬆️
pkg/upgraders/scalerstep.go 65.00% <80.00%> (+13.27%) ⬆️
pkg/scaler/machineSetScaler.go 93.27% <95.23%> (+0.07%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants