diff --git a/changelog/27426.txt b/changelog/27426.txt new file mode 100644 index 0000000000..ac18d43862 --- /dev/null +++ b/changelog/27426.txt @@ -0,0 +1,4 @@ +```release-note:change +activity log: Deprecates the current_billing_period field for /sys/internal/counters/activity. The default start time +will automatically be set the billing period start date. +``` \ No newline at end of file diff --git a/vault/logical_system_activity.go b/vault/logical_system_activity.go index 8eeeb24ad3..38674be000 100644 --- a/vault/logical_system_activity.go +++ b/vault/logical_system_activity.go @@ -20,6 +20,11 @@ import ( // defaultToRetentionMonthsMaxWarning is a warning message for setting the max retention_months value when retention_months value is more than activityLogMaximumRetentionMonths var defaultToRetentionMonthsMaxWarning = fmt.Sprintf("retention_months cannot be greater than %d; capped to %d.", activityLogMaximumRetentionMonths, activityLogMaximumRetentionMonths) +const ( + // WarningCurrentBillingPeriodDeprecated is a warning string that is used to indicate that the current_billing_period field, as the default start time will automatically be the billing period start date + WarningCurrentBillingPeriodDeprecated = "current_billing_period is deprecated; unless otherwise specified, all requests will default to the current billing period" +) + // activityQueryPath is available in every namespace func (b *SystemBackend) activityQueryPath() *framework.Path { return &framework.Path{ @@ -33,6 +38,7 @@ func (b *SystemBackend) activityQueryPath() *framework.Path { Fields: map[string]*framework.FieldSchema{ "current_billing_period": { + Deprecated: true, Type: framework.TypeBool, Description: "Query utilization for configured billing period", }, @@ -254,15 +260,16 @@ func (b *SystemBackend) handleClientMetricQuery(ctx context.Context, req *logica return logical.ErrorResponse("no activity log present"), nil } - if d.Get("current_billing_period").(bool) { - startTime = b.Core.BillingStart() - endTime = time.Now().UTC() - } else { - var err error - startTime, endTime, err = parseStartEndTimes(a, d, b.Core.BillingStart()) - if err != nil { - return logical.ErrorResponse(err.Error()), nil - } + warnings := make([]string, 0) + + if _, ok := d.GetOk("current_billing_period"); ok { + warnings = append(warnings, WarningCurrentBillingPeriodDeprecated) + } + + var err error + startTime, endTime, err = parseStartEndTimes(a, d, b.Core.BillingStart()) + if err != nil { + return logical.ErrorResponse(err.Error()), nil } var limitNamespaces int @@ -275,12 +282,15 @@ func (b *SystemBackend) handleClientMetricQuery(ctx context.Context, req *logica return nil, err } if results == nil { - resp204, err := logical.RespondWithStatusCode(nil, req, http.StatusNoContent) + resp204, err := logical.RespondWithStatusCode(&logical.Response{ + Warnings: warnings, + }, req, http.StatusNoContent) return resp204, err } return &logical.Response{ - Data: results, + Warnings: warnings, + Data: results, }, nil } diff --git a/website/content/api-docs/system/internal-counters.mdx b/website/content/api-docs/system/internal-counters.mdx index 69be0d763d..6e12f44c6f 100644 --- a/website/content/api-docs/system/internal-counters.mdx +++ b/website/content/api-docs/system/internal-counters.mdx @@ -352,7 +352,7 @@ This endpoint was added in Vault 1.6. - `limit_namespaces` `(int, optional)` - Controls the total number of by_namespace data returned. This can be used to return the client counts for the specified number of namespaces having highest activity. If no `limit_namespaces` parameter is specified, client counts for all namespaces in specified usage period is returned. -- `current_billing_period` `(bool, optional)` - Uses the builtin billing start +- `current_billing_period` `(bool, optional)` - **DEPRECATED** Uses the builtin billing start timestamp as `start_time` and the current time as the `end_time`, returning a response with the current billing period information without having to explicitly provide a start and end time. diff --git a/website/content/docs/upgrading/upgrade-to-1.18.x.mdx b/website/content/docs/upgrading/upgrade-to-1.18.x.mdx index d111c6c9c9..28e7f4583a 100644 --- a/website/content/docs/upgrading/upgrade-to-1.18.x.mdx +++ b/website/content/docs/upgrading/upgrade-to-1.18.x.mdx @@ -16,6 +16,8 @@ Vault 1.17. **Please read carefully**. ### Activity Log Changes +#### Default Activity Log Querying Period + The field `default_report_months` can no longer be configured or read. Any previously set values will be ignored by the system. @@ -36,3 +38,22 @@ WARNING! The following warnings were returned from Vault: ``` + + +The `current_billing_period` toggle for `/sys/internal/counters/activity` is also deprecated, as this will be set +true by default. + +Attempts to set `current_billing_period` will result in the following warning from Vault: + + + +```shell-session + +WARNING! The following warnings were returned from Vault: + + * current_billing_period is deprecated; unless otherwise specified, all requests will default to the current billing period + + +``` + +