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

feat: add shard-group duration settings to CLI and API #20620

Closed
wants to merge 8 commits into from

Conversation

hinst
Copy link

@hinst hinst commented Jan 27, 2021

Closes #19764

Changes:

  • Shard duration can be set using command-line client
  • Shard duration can be set using Rest API
  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Feature flagged (if modified API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

@hinst hinst changed the title Shard duration config 19764 Add shard duration settings to the CLI Jan 27, 2021
@hinst hinst changed the title Add shard duration settings to the CLI fix(influx/cmd): Add shard duration settings to the CLI Jan 27, 2021
@hinst hinst changed the title fix(influx/cmd): Add shard duration settings to the CLI fix(influx/cmd): Add shard duration settings to CLI and API Jan 27, 2021
@danxmoran danxmoran self-assigned this Jan 28, 2021
@danxmoran
Copy link
Contributor

Hi @hinst, thank you for this contribution! Since this affects the server's public API, I'll need to check with our Cloud team to be sure it's something they're also able to implement and support.

@hinst hinst marked this pull request as ready for review January 28, 2021 23:23
@russorat russorat requested a review from danxmoran February 3, 2021 17:19
@timhallinflux timhallinflux added area/2.x OSS 2.0 related issues and PRs area/api area/cli labels Feb 23, 2021
@danxmoran danxmoran changed the title fix(influx/cmd): Add shard duration settings to CLI and API feat: add shard-group duration settings to CLI and API Feb 24, 2021
@danxmoran
Copy link
Contributor

@hinst apologies for the long delay. The good news is that we intent to accept this change! Ideally as part of our upcoming 2.0.5 release.

I need to double-check the proposed API for any edge cases and open a parallel PR against our Cloud implementation (returning a "not implemented" error if the new feature is used there)

@@ -60,6 +60,7 @@ Replacement `tsi1` indexes will be automatically generated on startup for shards
1. [20565](https://github.com/influxdata/influxdb/pull/20565): Update V1 API spec to document all valid Accept headers and matching Content-Types.
1. [20578](https://github.com/influxdata/influxdb/pull/20578): Respect the --skip-verify flag when running `influx query`.
1. [20495](https://github.com/influxdata/influxdb/pull/20495): Update Flux functions list in UI to reflect that `v1` package was renamed to `schema`.
1. [19764](https://github.com/influxdata/influxdb/pull/20620): Add shard duration settings to CLI and API
Copy link
Contributor

Choose a reason for hiding this comment

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

After rebasing onto / merging with latest master, this will need to move up to the "Features" section under "unreleased". Would propose:

Suggested change
1. [19764](https://github.com/influxdata/influxdb/pull/20620): Add shard duration settings to CLI and API
1. [20620](https://github.com/influxdata/influxdb/pull/20620): Add support for explicitly setting shard-group durations. Thanks @hinst!

@@ -73,6 +74,7 @@ func (b *cmdBucketBuilder) cmdCreate() *cobra.Command {

cmd.Flags().StringVarP(&b.description, "description", "d", "", "Description of bucket that will be created")
cmd.Flags().StringVarP(&b.retention, "retention", "r", "", "Duration bucket will retain data. 0 is infinite. Default is 0.")
cmd.Flags().StringVarP(&b.shardGroupDuration, "shardDuration", "", "", "Shard group duration used internally in storage. Default is 7 days")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd.Flags().StringVarP(&b.shardGroupDuration, "shardDuration", "", "", "Shard group duration used internally in storage. Default is 7 days")
cmd.Flags().StringVarP(&b.shardGroupDuration, "shardDuration", "", "", "Shard group duration used internally by the storage engine. Can only be specified when using InfluxDB OSS.")

@@ -335,6 +343,7 @@ func (b *cmdBucketBuilder) printBuckets(printOpt bucketPrintOpt) error {
"ID": bkt.ID.String(),
"Name": bkt.Name,
"Retention": bkt.RetentionPeriod,
"Shard duration": bkt.ShardGroupDuration,
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to think through what this will look like when listing objects returned by InfluxDB Cloud.

@@ -320,7 +328,7 @@ func (b *cmdBucketBuilder) printBuckets(printOpt bucketPrintOpt) error {

Copy link
Contributor

Choose a reason for hiding this comment

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

It's too far from the diff for me to comment on directly, but I think we'll also need support in the update command.

The server-side code for the update path will also need changed. At the moment, I believe it will reset the shard-group duration every time the retention policy is updated. We probably instead want the update API to accept both an RP and a shard-group duration (each one optional), and use:

  • Duration is unset = don't change the current shard-group duration
  • Duration set to 0 = have the server recompute a "good" duration based on the bucket's RP

shardGroupDuration:
type: integer
format: int64
description: shard duration measured in nanoseconds
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of nanos, could we use seconds to match the units used by retentionRules?

@@ -36,6 +36,7 @@ type Bucket struct {
Description string `json:"description"`
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
RetentionPeriod time.Duration `json:"retentionPeriod"`
ShardGroupDuration time.Duration `json:"shardGroupDuration"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to make this:

Suggested change
ShardGroupDuration time.Duration `json:"shardGroupDuration"`
ShardGroupDuration *time.Duration `json:"shardGroupDuration,omitempty"`

So Cloud can distinguish not-set from explicitly-0. Will get back to you after I work on the Cloud side of things...

@danxmoran
Copy link
Contributor

For anyone watching this PR: I've pulled @hinst's commits into a branch of my own, where I'm iterating on the API design

@rajaimrankhan
Copy link

Hi

@danxmoran
Copy link
Contributor

Superseded by #20911.

Thanks for getting this started @hinst! I'll make sure it gets into 2.0.5

@danxmoran danxmoran closed this Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/cli area/2.x OSS 2.0 related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add shard duration settings to the CLI
4 participants