Vault Automation 5f77aa78fc
VAULT-42759: Fix logic around setting updated_at field in billing endpoint, enhance tests coverage for the endpoint (#12454) (#12584)
* fix updated_at logic for previous month, add tests

* improvement: separate out metric names into consts

* wholistically cover all metrics in billing api test

* add actual totp data in the ent test

* fix more wording errors

* feedback: remove consts and use metric names directly

* fix a test

* simplify the logic around refreshing data

* simplify the logic by centralizing the atomic tracker interacting inside updateBillingMetrics method, fix the logic inside the endpoint, add tests

* miner fixes

* feedback: set time tracker to zero at set up and at start of month to indicate data has not been updated yet, update test

* attempt to fix deadlock by using statelock free version of update billing metrics method

* remove unnecessary locks inside request handling

* remove duplicate methods - instead create 2 wrappers around the method one with lock and one without

* add a new prefix and methods to store and retrieve last update time

* add comments to explain local prefix behavior for the update method

* replace atomic tracker with storage methods

* add method level tests for the update time storage methods

* add external tests to verify perf replicated cluster independelty track last update time now

* normalize time to utc before storing to storage, fix comments

* code scanql feedback: remove logging of raw error to prevent leakage

* feedback: reorganize and refactor update billing metric method wrappers

* feedback: add go doc to the get method

* feedback: retrieve stored update time for last month, instead of always putting end of month inside computeUpdatedTime

* use equal test instead of within duration inside util tests

* use require equal inside external tests too

* use end of the requested month inside the endpoint for past months

* update tests

* add a new test case for when time is not stored in storage

* fix a bug: add nil check before passing role counts and managed key counts to update method

* feedback: remove update call of of time inside setup billing

* Update vault/consumption_billing_util.go



* Update vault/logical_system_use_case_billing.go



* Update vault/logical_system_use_case_billing.go



* comment fix

* feedback: do not allow refresh on perf standby, add a warning and just retrieve stored data

* add tests

---------

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>
Co-authored-by: divyaac <divya.chandrasekaran@hashicorp.com>
2026-02-26 21:19:16 +00:00
..

Vault API

This provides the github.com/hashicorp/vault/api package which contains code useful for interacting with a Vault server.

For examples of how to use this module, see the vault-examples repo. For a step-by-step walkthrough on using these client libraries, see the developer quickstart.

GoDoc