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

Disk Size conversion from GB to MB during update to 4.1.2 #17631

Open
AndreasSMoe opened this issue Sep 27, 2024 · 3 comments
Open

Disk Size conversion from GB to MB during update to 4.1.2 #17631

AndreasSMoe opened this issue Sep 27, 2024 · 3 comments
Assignees
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application

Comments

@AndreasSMoe
Copy link

Deployment Type

Self-hosted

NetBox Version

v4.1.2

Python Version

3.12

Steps to Reproduce

10000 MB is shown as 10GB, import with script is bytes/1MB, which gives 10.24GB in netbox (1024MB)
Tested to do (bytes/1GB)*1000 was shown correctly. But failes if disk is > 1TB

Is there a configuration setting to choose between divider of 1000 and 1024?

Expected Behavior

1024 MB shown as 1GB so that conversion from bytes to MB will be shown correctly

Observed Behavior

The value is shown as 50GB when 50000 MB is entered. Expected that 51200 MB would show as 50GB

@AndreasSMoe AndreasSMoe added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Sep 27, 2024
@AndreasSMoe
Copy link
Author

Simular issue as
#17605 but for VMs

@arthanson arthanson added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Sep 30, 2024
@arthanson arthanson self-assigned this Sep 30, 2024
@arthanson
Copy link
Collaborator

@AndreasSMoe can you please update your reproduction steps, you never state where this is occurring or what steps to see it appear.

@AndreasSMoe
Copy link
Author

Field used to be GB, is now MB
Field collected from VMM is in Bytes, 1024 Bytes is 1KB, 1024KB is 1MB, 1024MB is 1GB, 1024GB is 1TB
Netbox uses 1000 Bytes as 1KB, 1000MB as 1GB
Example
Importing a value of 50000 MB on virtual disk is shown as 50GB
While converting from bytes to MB
52428800 Bytes is 51200MB

In Netbox, 51200 MB is converted to 51,2GB which is not correct

if I convert the bytes
52428800/1MB = 51200 MB which is correct, but shown wrong
(52428800/1GB)*1000 = 50000MB which is wrong, but shown correctly

Problems occur if the disk is larger than 1TB

(1 073 741 824/1GB)*1000 = 1024GB which is wrong, will be shown as 1.02 TB

Correct would be to not use humanizenumbers as conversion will be wrong
A posible solution would be to add ability in configuration to choose between 1000 and 1024

image
vs edit
image

To get value 60GB, the MB value should be 61440MB

But if I change value the converted value shown under virual disk is
image

We use netbox as source for our billing, and as a workaround they now divide the MB number by 1000
The correct way would be for billing to devide by 1024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants