Skip to content

TPT-4324: Allow dict passthrough for config_create 'devices' field#673

Open
lgarber-akamai wants to merge 1 commit intolinode:devfrom
lgarber-akamai:new/config-create-devices
Open

TPT-4324: Allow dict passthrough for config_create 'devices' field#673
lgarber-akamai wants to merge 1 commit intolinode:devfrom
lgarber-akamai:new/config-create-devices

Conversation

@lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Mar 26, 2026

📝 Description

Adds backwards-compatible support for passing a raw device mapping dict to the devices parameter of Instance.config_create(...), allowing callers to explicitly specify the sdX key for a device during config creation.

This resolves an issue in ansible_linode that is currently blocking the release of Block Storage Volume Limits Increase.

✔️ How to Test

Unit Testing

make test-unit

Integration Testing

make test-int TEST_COMMAND=models/volume
make test-int TEST_COMMAND=models/linode

@lgarber-akamai lgarber-akamai requested review from a team as code owners March 26, 2026 15:21
@lgarber-akamai lgarber-akamai requested review from mgwoj and removed request for a team March 26, 2026 15:21
@lgarber-akamai lgarber-akamai added the improvement for improvements in existing functionality in the changelog. label Mar 26, 2026
@lgarber-akamai lgarber-akamai changed the title Allow dict passthrough for config_create 'devices' field TPT-4324: Allow dict passthrough for config_create 'devices' field Mar 26, 2026
@lgarber-akamai lgarber-akamai force-pushed the new/config-create-devices branch from 04d5132 to d89e53c Compare March 26, 2026 15:34
@lgarber-akamai lgarber-akamai requested review from a team, Copilot and psnoch-akamai and removed request for a team, ezilber-akamai and mgwoj March 26, 2026 15:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds backwards-compatible support for passing a raw device mapping dict into Instance.config_create(..., devices=...), enabling explicit sdX key selection during config creation (needed for ansible_linode workflows around expanded volume limits).

Changes:

  • Update Instance.config_create to accept a raw device-map dict and to normalize/serialize device inputs more flexibly.
  • Add a unit test to ensure device-map dicts are passed through unchanged.
  • Add an integration test validating config creation using an explicit device-map key.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
linode_api4/objects/linode.py Extends config_create input handling/typing to support device-map dict passthrough; also adjusts clone defaults/normalization.
test/unit/objects/linode_test.py Adds unit coverage asserting raw device-map dict passthrough in config_create.
test/integration/models/volume/test_blockstorage.py Adds integration coverage for creating a config using an explicit device-map key.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1246 to +1261
ConfigCreateDevice = Union["Disk", "Volume", Dict[str, Any]]
ConfigCreateDisk = Union["Disk", int]
ConfigCreateVolume = Union["Volume", int]

# create derived objects
def config_create(
self,
kernel=None,
label=None,
devices=[],
disks=[],
volumes=[],
interfaces=[],
kernel: Optional[Union[Kernel, str]] = None,
label: Optional[str] = None,
devices: Optional[
Union[
ConfigCreateDevice,
List[ConfigCreateDevice],
Dict[str, Any],
]
] = None,
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The new type aliases/annotation for devices are inconsistent with the runtime behavior: ConfigCreateDevice includes Dict[str, Any], and devices itself allows Dict[str, Any], but _build_devices() treats any dict as the full device-map passthrough (keys like sda, sdb). This makes it ambiguous for type-checkers/users and suggests supported inputs (a single device-entry dict or dicts inside the devices list) that the implementation doesn’t actually handle. Consider tightening the typing to distinguish a device-entry vs a device-map (e.g. Dict[str, ConfigCreateDeviceEntry]) and aligning the implementation/docs accordingly.

Copilot uses AI. Check for mistakes.
else:
raise TypeError("Disk or Volume expected!")
if len(device_map) < 1:
raise ValueError("Must include at least one disk or volume!")
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test for this case?

Comment on lines 11 to 34
@@ -25,10 +25,11 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = ["requests", "polling", "deprecated"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per our support policy, we stop supporting Python versions as soon as they EOL.

I can split this out into a separate PR if needed. Just wanted to use the fancy new type hint syntax.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ezilber-akamai
ezilber-akamai previously approved these changes Mar 26, 2026
@lgarber-akamai lgarber-akamai force-pushed the new/config-create-devices branch from c62fefb to b406990 Compare March 26, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants