feat(vks): update_nodegroup disable_auto_scale sends autoScaleConfig:null - #64
Open
vks-team wants to merge 1 commit into
Open
feat(vks): update_nodegroup disable_auto_scale sends autoScaleConfig:null#64vks-team wants to merge 1 commit into
vks-team wants to merge 1 commit into
Conversation
…null The backend's autoScaleConfig is JsonNullable, but the MCP tool's Optional[AutoScaleConfig]=None + model_dump(exclude_none=True) could only express two states — omit (keep) and object (set). Disabling autoscaling (send autoScaleConfig: null to delete the current config) was impossible. Add a bool disable_auto_scale sentinel to UpdateNodeGroupDto (mirroring the greennode-cli --disable-auto-scale flag). The handler rejects it together with an autoScaleConfig object (mutually exclusive), strips it from the payload, and sets an explicit autoScaleConfig: None so the wire body carries "autoScaleConfig": null. The other two CLI gaps are already handled by the pydantic models: AutoScaleConfig marks minSize/maxSize required (fail-fast on a partial object at parse time) and UpgradeConfig defaults maxSurge=1/maxUnavailable=0. Only the disable state needed work. Tests pin all three states: - disable alone sends "autoScaleConfig": null, strips the sentinel - disable + object rejected before any HTTP call - autoScaleConfig omitted keeps the field off the wire - autoScaleConfig object set carries the object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirrors the greennode-cli
update-nodegroupalignment onto the MCPupdate_nodegrouptool. The backend'sautoScaleConfigisJsonNullable, but the tool'sOptional[AutoScaleConfig]=None+model_dump(exclude_none=True)could only express two states — omit (keep) and object (set). Disabling autoscaling (sendautoScaleConfig: nullto delete the current config) was impossible.Add a
disable_auto_scale: boolsentinel toUpdateNodeGroupDto(mirroring the CLI's--disable-auto-scale). The handler rejects it together with anautoScaleConfigobject (mutually exclusive), strips the sentinel from the payload, and sets an explicitautoScaleConfig: Noneso the wire body carries"autoScaleConfig": null.autoScaleConfigdisable_auto_scale=true"autoScaleConfig": nullautoScaleConfig={...}"autoScaleConfig": {...}Only one state needed work
The two other gaps the CLI fix closed are already handled by the pydantic models here — no code needed:
AutoScaleConfigdeclaresminSize: int = Field(...)+maxSize: int = Field(...)required, so pydantic rejects{}/partial objects at parse.UpgradeConfigdeclaresmaxSurge=Field(1,...),maxUnavailable=Field(0,...)as defaults, so an emptyUpgradeConfig()already sends{maxSurge:1, maxUnavailable:0}.Only the disable state needed code.
Why a sentinel bool, not
exclude_unset/JsonNullablemodel_dump(exclude_unset=True)distinguishes "unset" from "provided as None", the pydantic-native 3-state path. But it requires the LLM caller to explicitly passautoScaleConfig=Noneto disable — a fragile, undocumented argument contract. A sentinel bool is an unambiguous, self-documenting argument ("disable_auto_scale": true) that matches the CLI's UX. Cost: one extra field the handler strips — trivial.Test plan
Four new tests in
test_nodegroup_tools.pypin all three states plus the mutex:disable_autoscale_sends_null{"autoScaleConfig": None}, sentinel stripped, HTTP PUT madedisable_and_object_is_mutually_exclusiveomits_autoscale_when_unsetautoScaleConfigabsent from wire (keep current) — pinsends_autoscale_objectuv run pytest tests/uv run ruff check .uv run ruff format --check .Ported from
greennode-cli PR #11 (update-nodegroup
--disable-auto-scale+ autoscale null + upgrade defaults). The fail-fast and upgrade-defaults parts were unnecessary here because pydantic'sField(...)required-fields andField(default)already enforce them; only the disable state ported.