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

Deprecates current_billing_period #27426

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/27426.txt
Original file line number Diff line number Diff line change
@@ -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.
```
32 changes: 21 additions & 11 deletions vault/logical_system_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
},
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion website/content/api-docs/system/internal-counters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions website/content/docs/upgrading/upgrade-to-1.18.x.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -36,3 +38,22 @@ WARNING! The following warnings were returned from Vault:
```

</CodeBlockConfig>


The `current_billing_period` toggle for `/sys/internal/counters/activity` is also deprecated, as this will be set
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay and not bringing this up on Enterprise, but can you add a warning output like above? It helps users get more context about the warning if they encounter it.

true by default.

Attempts to set `current_billing_period` will result in the following warning from Vault:

<CodeBlockConfig hideClipboard>

```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


```

</CodeBlockConfig>
Loading