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

retentionPeriodHrs key in onboarding requests is misleading #20452

Closed
jeremy-prater opened this issue Jan 5, 2021 · 3 comments · Fixed by #20798
Closed

retentionPeriodHrs key in onboarding requests is misleading #20452

jeremy-prater opened this issue Jan 5, 2021 · 3 comments · Fixed by #20798
Assignees
Labels
area/api area/api-docs area/2.x OSS 2.0 related issues and PRs

Comments

@jeremy-prater
Copy link

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Create a new influxdb
  2. Verify the onboarding status is true (ready for onboarding)
  3. Using the C# client library v1.13.0 send a Onboarding request with a non-zero retention policy

Expected behavior:
Successful onboarding response

Actual behavior:
Onboarding fails with Message: retention policy duration must be at least 1h0m0s

Environment info:

  • System info: Darwin 19.6.0 x86_64
  • InfluxDB version: InfluxDB 2.0.3 (git: fe04d34) build_date: 2020-12-15T01:00:16Z
  • Other relevant environment details: None

Config:
Config is default

Code:

OnboardingRequest onboardingRequest = new OnboardingRequest(
    adminUsername,
    adminPassword,
    defaultOrg,
    defaultBucket,
    24 * 30 // 30 days
);
var onboardResponse = await influxDBClient.OnboardingAsync(onboardingRequest);

Logs:

ts=2021-01-05T22:59:11.445554Z lvl=debug msg="Onboarding eligibility check finished" log_id=0RXCFZaG000 result=true
ts=2021-01-05T22:59:11.445675Z lvl=debug msg=Request log_id=0RXCFZaG000 service=http method=GET host=localhost:8086 path=/api/v2/setup query= proto=HTTP/1.1 status_code=200 response_size=20 content_length=0 referrer= remote=[::1]:65335 user_agent=influxdb-client-csharp took=0.443ms body=
ts=2021-01-05T22:59:11.527917Z lvl=debug msg="user create" log_id=0RXCFZaG000 store=new took=15.825ms
ts=2021-01-05T22:59:11.626550Z lvl=debug msg="set password" log_id=0RXCFZaG000 store=new took=98.599ms
ts=2021-01-05T22:59:11.646952Z lvl=debug msg="org find by ID" log_id=0RXCFZaG000 store=new took=0.073ms
ts=2021-01-05T22:59:11.670368Z lvl=debug msg="bucket create" log_id=0RXCFZaG000 store=new took=23.487ms
ts=2021-01-05T22:59:11.690045Z lvl=debug msg="org find by ID" log_id=0RXCFZaG000 store=new took=0.064ms
ts=2021-01-05T22:59:11.708178Z lvl=debug msg="bucket create" log_id=0RXCFZaG000 store=new took=18.200ms
ts=2021-01-05T22:59:11.746375Z lvl=debug msg="urm create" log_id=0RXCFZaG000 store=new took=19.252ms
ts=2021-01-05T22:59:11.746409Z lvl=debug msg="org create" log_id=0RXCFZaG000 store=new took=119.821ms
ts=2021-01-05T22:59:11.746491Z lvl=debug msg="org find by ID" log_id=0RXCFZaG000 store=new took=0.063ms
ts=2021-01-05T22:59:11.764711Z lvl=debug msg="bucket create" log_id=0RXCFZaG000 store=new took=18.283ms
ts=2021-01-05T22:59:11.784019Z lvl=debug msg="urm find" log_id=0RXCFZaG000 store=new took=0.049ms
ts=2021-01-05T22:59:11.784058Z lvl=debug msg="bucket delete" log_id=0RXCFZaG000 store=new took=19.269ms
ts=2021-01-05T22:59:11.784092Z lvl=debug msg="failed to onboard user <removed>" log_id=0RXCFZaG000 handler=onboard error="retention policy duration must be at least 1h0m0s" took=272.015ms
ts=2021-01-05T22:59:11.784104Z lvl=error msg="api error encountered" log_id=0RXCFZaG000 error="retention policy duration must be at least 1h0m0s"
ts=2021-01-05T22:59:11.784161Z lvl=debug msg=Request log_id=0RXCFZaG000 service=http method=POST host=localhost:8086 path=/api/v2/setup query= proto=HTTP/1.1 status_code=500 response_size=94 content_length=123 referrer= remote=[::1]:65336 user_agent=influxdb-client-csharp took=272.300ms error="internal error" error_code="internal error"

Workaround:

Onboard influx with no retention policy and then update the default bucket's retention policy after creation

Bucket ingestBucket = await bucketsAPI.FindBucketByNameAsync(defaultBucket);
defaultBucket.RetentionRules.Add(new BucketRetentionRules(BucketRetentionRules.TypeEnum.Expire, 60 * 60 * 24 * 30)); // 30 days
await bucketsAPI.UpdateBucketAsync(defaultBucket);
ts=2021-01-05T23:17:48.471511Z lvl=debug msg="session find" log_id=0RXDJga0000 service=session took=0.373ms
ts=2021-01-05T23:17:48.471560Z lvl=debug msg="session renew" log_id=0RXDJga0000 service=session took=0.031ms
ts=2021-01-05T23:17:48.471616Z lvl=debug msg="user find by ID" log_id=0RXDJga0000 store=new took=0.044ms
ts=2021-01-05T23:17:48.471811Z lvl=debug msg="bucket find by ID" log_id=0RXDJga0000 store=new took=0.036ms
ts=2021-01-05T23:17:48.471862Z lvl=debug msg="bucket find by ID" log_id=0RXDJga0000 store=new took=0.033ms
ts=2021-01-05T23:17:48.507253Z lvl=debug msg="bucket update" log_id=0RXDJga0000 store=new took=15.474ms
ts=2021-01-05T23:17:48.507309Z lvl=debug msg="Bucket updated" log_id=0RXDJga0000 handler=bucket bucket="&{176a30aeb5799ec3 1fad2ddd9c1718f7 user <removed>   720h0m0s {2021-01-05 23:17:48.216219 +0000 UTC 2021-01-05 23:17:48.491829 +0000 UTC}}"

It is curious that Onboarding requires time in hours, but updating a bucket retention policy in the C# client is given in seconds.

@jeremy-prater jeremy-prater changed the title Onboarding failes with non-zero retention policy time in hours Onboarding fails with non-zero retention policy time in hours Jan 5, 2021
@danxmoran
Copy link
Contributor

danxmoran commented Jan 5, 2021

@jeremy-prater thanks for the report, this is unfortunate...

The onboarding implementation is using the specified retention policy as a raw duration (nanoseconds), so if you scale up your argument to match then things should work. The retentionPeriodHrs JSON key is a major misnomer, I'm guessing a spot was missed during a refactor. We'll need to figure out what to do on our end to deal with it now that versions 2.0+ of the influx CLI expect the current implementation.

@danxmoran danxmoran added area/2.x OSS 2.0 related issues and PRs area/api area/api-docs labels Jan 5, 2021
@danxmoran
Copy link
Contributor

danxmoran commented Jan 29, 2021

The good news is: the setup API is explicitly not supported by Cloud, so we don't need to coordinate cross-product API changes. Bad news: Cloud uses the same OnboardingRequest schema in their /setup/user API, but their impl actually treats the value as hours.

@danxmoran danxmoran changed the title Onboarding fails with non-zero retention policy time in hours retentionPeriodHrs key in onboarding requests is misleading Jan 29, 2021
@danxmoran danxmoran self-assigned this Feb 18, 2021
@danxmoran
Copy link
Contributor

After talking with the Cloud team, the plan is to:

  1. Introduce retentionPeriodSeconds
  2. Deprecate retentionPeriodHrs
  3. Update the server to prefer Seconds, but use Hrs if the new field isn't present
  4. Update the CLI to use Seconds

Step 4 will be easier once #20326 is done, tackling that first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/api-docs area/2.x OSS 2.0 related issues and PRs
Projects
None yet
2 participants