Skip to content

Keep the byte counts on NotEnoughFreeSpaceError - #427

Open
bernalvinicius wants to merge 2 commits into
networktocode:developfrom
bernalvinicius:u/vbernal-free-space-error-attributes
Open

Keep the byte counts on NotEnoughFreeSpaceError#427
bernalvinicius wants to merge 2 commits into
networktocode:developfrom
bernalvinicius:u/vbernal-free-space-error-attributes

Conversation

@bernalvinicius

Copy link
Copy Markdown

Closes #426

Explanation of Change(s)

NotEnoughFreeSpaceError accepted required, available and file_system, used them to build the message string, and then dropped them — the values were only recoverable by parsing message. They are now kept as attributes, along with a precomputed shortfall.

The message also gained thousands separators and the shortfall, since a nine-digit byte count is hard to read and the remaining space was left for the reader to work out:

- host1: bootflash: has 13456789 bytes free; 313456789 bytes required for transfer
+ host1: bootflash: has 13,456,789 bytes free; 313,456,789 bytes required for transfer (300,000,000 more bytes required to succeed)

The legacy min_space form is untouched; its byte attributes are None.

Heads-up on the message change: the wording is observable to anyone parsing it. That is exactly the situation this fixes — nautobot-app-os-upgrades was regexing the counts back out of message and drops that workaround once this lands.

Added change log fragment(s)

changes/426.changed

Unit, Integration Tests

Four new tests in tests/unit/test_errors.py cover the stored attributes, the message with counts and shortfall, the message without a file system, and the legacy form leaving the byte attributes unset. Full suite: 950 passed, 26 skipped.

Outline Remaining Work, Constraints from Design

None.

The error accepted required/available/file_system, used them to build the
message and then discarded them, so callers could only recover the numbers
by parsing the message text. They are now kept as attributes, along with a
precomputed shortfall.

The message itself gained thousands separators and the shortfall, since a
nine-digit byte count is hard to read and the remaining space was left for
the reader to work out.

The legacy min_space form is unchanged; its byte attributes are None.

@gsnider2195 gsnider2195 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great thanks!

@jvanderaa jvanderaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update to single backticks.

Comment thread pyntc/errors.py Outdated
Co-authored-by: Josh VanDeraa <josh@josh-v.com>
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.

NotEnoughFreeSpaceError discards its byte counts, forcing callers to parse the message

3 participants