influxdata / influx-cli

CLI for managing resources in InfluxDB v2
MIT License
61 stars 23 forks source link

Task import no longer takes task options from provided task #459

Closed btasker closed 1 year ago

btasker commented 1 year ago

For reference, the task used below is from this doc.

It's not currently possible to load the task into a Cloud2 account.

Running

influx task create -file task\(1\).flux

results in

Error: 400 Bad Request: failed to decode request: time: invalid duration ""

The task contains a valid definition

option task = {every: 5m, name: "Migrate data from InfluxDB Cloud"}

If every is defined on the command line, it works

influx task create -every 5m -file task\(1\).flux

Taking a packet capture shows that the CLI is not correctly populating every in it's API call

POST /api/v2/tasks HTTP/1.1
Host: eu-central-1-1.aws.cloud2.influxdata.com
User-Agent: influx/2.5.0 (linux) Sha/3285a03 Date/2022-11-01T16:32:06Z
Transfer-Encoding: chunked
Accept: application/json
Authorization: Token <redacted>
Content-Type: application/json
Accept-Encoding: gzip

13bf
{"cron":"","every":"","flux":"import \"array\"\r\nimport \"experimental\"\r\nimport \"influxdata/influxdb/secrets\"\r\n\r\n// Configure the task\r\noption task = {every: 5m, name: \"Migrate data from InfluxDB Cloud\"}\r\n\r\n

..snip..
0

Working back through the versions, it looks like this stopped working after version 2.3.0 of the cli

ben@bumblebee:~/tmp$ influxdb2-client-2.5.0-linux-amd64/influx task create -file task\(1\).flux
Error: 400 Bad Request: failed to decode request: time: invalid duration ""

ben@bumblebee:~/tmp$ influxdb2-client-2.4.0-linux-amd64/influx task create -file ~/Downloads/task\(1\).flux
Error: 400 Bad Request: failed to decode request: time: invalid duration ""

ben@bumblebee:~/tmp$ influxdb2-client-2.3.0-linux-amd64/influx task create -file task\(1\).flux
ID          Name                    Organization ID     Organization    Status  Every   Cron
0a5ba41b17f40000    Migrate data from InfluxDB Cloud    8d58f686fe69c193            active  5m  

The underlying issue seems to be the addition of this line in commit 1453e20f2bb264c08be61f151853629ebe686a70.

Commenting that line out and compiling resolves the issue, although that'll break support for the commandline param