You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
The CLI tool stops working and returns an empty list of estimates if a managed HDD is found, such as S4 LRS Disk.
The error throw is: Unable to get estimate data for Azure subscription {GUID}: Cannot read properties of null (reading '0')
Operating System:
Windows 11 (23H2)
Browser:
Not relevant
Expected Behavior
I expect that the tool generates a file containing the co2 emissions for my subscriptions
Actual Behavior
The tool returns an empty CSV file
Running yarn start-cli --startDate 2023-11-01 --endDate 2023-11-02 --format csv --groupBy dayAndService
Throws a warning Unable to get estimate data for Azure subscription {GUID}: Cannot read properties of null (reading '0')
And returns:
Date (UTC),SUM kilowatt hours,SUM metric tons CO2e Emissions
Total,0.00,0.000000
To Reproduce
I guess the best way to reproduce this is to have a managed HDD in your subscription and run: yarn start-cli --startDate 2023-11-01 --endDate 2023-11-02 --format csv --groupBy dayAndService### Screenshots
Additional Information
I have taken some time to look into the issue and here is what I found.
When getUsageAmountInTerabyteHours gets called, on line 800 it checks if the storage type by running this.isSSDStorage(consumptionDetailRow).
Given the consumptionDetailRow.usageType -> S4 LRS Disk, a managed HDD, the function will return true because the input contains LRS in its name.
This causes line 804 to throw as the regex can't find any matches of P or E storage type since our input is S4 LRS Disk, and therefore, we get the Cannot read properties of null (reading '0') error.
Here is the full stack trace after removing a try catch around the main function orchestrating the whole thing.
E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:805
consumptionDetailRow.usageType.match(/(P|E)\d{1,2}/)[0]
^
TypeError: Cannot read properties of null (reading '0')
at ConsumptionManagementService.getUsageAmountInTerabyteHours (E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:805:61)
at ConsumptionManagementService.getStorageFootprintEstimate (E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:588:12)
at ConsumptionManagementService.getEstimateByPricingUnit (E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:508:21)
at ConsumptionManagementService.getFootprintEstimateFromUsageRow (E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:251:21)
at ConsumptionManagementService.getEstimates (E:\repos\cloud-carbon-footprint\packages\azure\src\lib\ConsumptionManagement.ts:137:38)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AzureAccount.getDataForSubscription (E:\repos\cloud-carbon-footprint\packages\azure\src\application\AzureAccount.ts:216:12)
at async E:\repos\cloud-carbon-footprint\packages\azure\src\application\AzureAccount.ts:242:16
at async Promise.all (index 0)
at async AzureAccount.getDataFromConsumptionManagement (E:\repos\cloud-carbon-footprint\packages\azure\src\application\AzureAccount.ts:111:9)
at async Object.getCostAndEstimates (E:\repos\cloud-carbon-footprint\packages\app\src\App.ts:114:25)
at async Promise.all (index 0)
at async getEstimatesForMissingDates (E:\repos\cloud-carbon-footprint\packages\app\src\Cache.ts:119:11)
at async App.descriptor.value (E:\repos\cloud-carbon-footprint\packages\app\src\Cache.ts:71:24)
at async cli (E:\repos\cloud-carbon-footprint\packages\cli\src\cli.ts:75:32)
One quick solution I found was to reverse these two if statements.
By checking for HDD first, "fixes" the issue.
Also, the storage types confuses the bejesus out of me. Is S4 LRS Disk supposed to be an SSD or HDD?
Looking around the interwebs, if the storage type is Standard_LRS it means it's a HDD else is an SSD. I am not very familiar with the notations we get from the Azure management API, so I can't tell for sure if that's how it works.
Preflight Checklist
Issue Details
The CLI tool stops working and returns an empty list of estimates if a managed HDD is found, such as
S4 LRS Disk
.The error throw is:
Unable to get estimate data for Azure subscription {GUID}: Cannot read properties of null (reading '0')
Expected Behavior
I expect that the tool generates a file containing the co2 emissions for my subscriptions
Actual Behavior
The tool returns an empty CSV file
Running
yarn start-cli --startDate 2023-11-01 --endDate 2023-11-02 --format csv --groupBy dayAndService
Throws a warning
Unable to get estimate data for Azure subscription {GUID}: Cannot read properties of null (reading '0')
And returns:
To Reproduce
I guess the best way to reproduce this is to have a managed HDD in your subscription and run:
yarn start-cli --startDate 2023-11-01 --endDate 2023-11-02 --format csv --groupBy dayAndService
### ScreenshotsAdditional Information
I have taken some time to look into the issue and here is what I found.
When getUsageAmountInTerabyteHours gets called, on line 800 it checks if the storage type by running
this.isSSDStorage(consumptionDetailRow)
.Given the
consumptionDetailRow.usageType
->S4 LRS Disk
, a managed HDD, the function will return true because the input containsLRS
in its name.This causes line 804 to throw as the regex can't find any matches of
P
orE
storage type since our input isS4 LRS Disk
, and therefore, we get theCannot read properties of null (reading '0')
error.Here is the full stack trace after removing a try catch around the main function orchestrating the whole thing.
One quick solution I found was to reverse these two if statements.
By checking for HDD first, "fixes" the issue.
Also, the storage types confuses the bejesus out of me. Is S4 LRS Disk supposed to be an SSD or HDD?
Looking around the interwebs, if the storage type is
Standard_LRS
it means it's a HDD else is an SSD. I am not very familiar with the notations we get from the Azure management API, so I can't tell for sure if that's how it works.Anyway, that's what I got so far.
© 2021 Thoughtworks, Inc.
The text was updated successfully, but these errors were encountered: