Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle output from call_cmd better in maas_storage #283

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

plars
Copy link
Collaborator

@plars plars commented Jun 4, 2024

Description

I was looking at some other things with the maas device connector and recalled that there were some gaps in how output is handled from this call_cmd method in maas_storage. There are some failure modes that wouldn't produce the output you would expect, and some places where it should raise an exception instead. This should close those gaps.

I also noticed while testing this that the previous unit tests fail on python3.12 because there's a way it can get TypeError when trying to run the command with None in it. This handles that potential error better, and also adds a way to inject the node_info so that testing is easier

Resolved issues

Resolves #264

Documentation

N/A

Web service API changes

N/A

Tests

Lots of test improvements, including a way to inject node_info in MaasStorage.
+4% coverage of maas_storage with the additional unit tests added too

@plars plars force-pushed the maas-call-cmd-improved branch from 0961e33 to 67830ab Compare June 4, 2024 18:22
@plars plars requested review from a team, val500, bladernr and rodwsmith June 4, 2024 18:42
Comment on lines +42 to +46
# Better support for testing
if node_info is None:
self.node_info = self._node_read()
else:
self.node_info = node_info
Copy link
Contributor

Choose a reason for hiding this comment

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

can be a one-line assignment, but you can keep it as is since it's a personal preference

Suggested change
# Better support for testing
if node_info is None:
self.node_info = self._node_read()
else:
self.node_info = node_info
# Better support for testing
self.node_info = self._node_read() if node_info is None else node_info

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.

JSONDecodeError when provisioning with maas storage specified
2 participants