InfluxDB upgrade fails with "No buckets for database exist in 2.x"

I’m running InfluxDB in Docker and get a consistent error when upgrading from 1.8.9 to 2.x. I’m sure I’m doing something stupid, but can’t find any reference to this issue.

I run Docker in upgrade mode as instructed in the upgrade instructions

docker create --name='Influxdb-v2-upgrade' \
-e TZ="America/New_York" -e HOST_OS="Unraid" -e 'TCP_PORT_8086'='8086' \
-e 'DOCKER_INFLUXDB_INIT_USERNAME'='<previous-admin-user>' 
-e 'DOCKER_INFLUXDB_INIT_PASSWORD'='<previous-admin-password>' \ 
-e 'DOCKER_INFLUXDB_INIT_ORG'='home_assistant' \
-e 'DOCKER_INFLUXDB_INIT_BUCKET'='home_assistant' \
-e 'DOCKER_INFLUXDB_INIT_MODE'='upgrade' \
-v '<on influxdb path on host>':'/var/lib/influxdb':'rw' \
-v '<path of old influxdb.conf file>':'/etc/influxdb/influxdb.conf':'rw' \
-v '<new empty directoy for data>':'/var/lib/influxdb2':'rw' \
-v '<new empty directory for config>':'/etc/influxdb2':'rw' \
'influxdb:2.0'

The logs show

{"level":"info","ts":1633306969.0330784,"caller":"upgrade/upgrade.go:401","msg":"Starting InfluxDB 1.x upgrade"}
{"level":"info","ts":1633306969.0341682,"caller":"upgrade/upgrade.go:404","msg":"Upgrading config file","file":"/etc/influxdb/influxdb.conf"}
{"level":"info","ts":1633306969.036784,"caller":"upgrade/upgrade.go:408","msg":"Config file upgraded.","1.x config":"/etc/influxdb/influxdb.conf","2.x config":"/etc/influxdb2/config.toml"}
{"level":"info","ts":1633306969.0375338,"caller":"upgrade/upgrade.go:418","msg":"Upgrade source paths","meta":"/var/lib/influxdb/meta","data":"/var/lib/influxdb/data"}
{"level":"info","ts":1633306969.0384605,"caller":"upgrade/upgrade.go:419","msg":"Upgrade target paths","bolt":"/var/lib/influxdb2/influxd.bolt","engine":"/var/lib/influxdb2/engine"}
{"level":"info","ts":1633306969.094964,"caller":"bolt/bbolt.go:82","msg":"Resources opened","service":"bolt","path":"/var/lib/influxdb2/influxd.bolt"}
{"level":"info","ts":1633306969.1129034,"caller":"migration/migration.go:153","msg":"Bringing up metadata migrations","service":"migrations","migration_count":15}
{"level":"info","ts":1633306970.6485534,"caller":"upgrade/setup.go:73","msg":"CLI config has been stored.","path":"/etc/influxdb2/influx-configs"}
{"level":"info","ts":1633306970.6487503,"caller":"upgrade/database.go:200","msg":"Checking available disk space"}
{"level":"info","ts":1633306970.8734708,"caller":"upgrade/database.go:221","msg":"Computed disk space","free":"424 GB","required":"9.6 GB"}
{"level":"info","ts":1633306970.8742876,"caller":"upgrade/database.go:50","msg":"Upgrading databases"}
{"level":"info","ts":1633306985.282964,"caller":"upgrade/database.go:193","msg":"Database upgrade complete","upgraded_count":2}
{"level":"warn","ts":1633306985.2834294,"caller":"upgrade/security.go:140","msg":"No buckets for database [home-assistant] exist in 2.x."}
{"level":"warn","ts":1633306985.2836392,"caller":"upgrade/security.go:140","msg":"No buckets for database [home-assistant] exist in 2.x."}
Error: upgrade: there were errors/warnings, please fix them and run the command again

See 'influxd -h' for help
2021-10-04T00:23:05.327335698Z warn cleaning bolt and engine files to prevent conflicts on retry {"system": "docker", "bolt_path": "/var/lib/influxdb2/influxd.bolt", "engine_path": "/var/lib/influxdb2/engine"}

I can see that the new data directory is filled during the migration process, then cleared when the process ends.

My main database I want to migrate data for is called home_assistant. NOT* home-assistant. I have a user named home-assistant which has privileges configured on home_assistant database.

Any ideas what might be happening here and how to resolve?

@drobtravels is it possible that you/somebody accidentally made a typo when trying to grant privileges on the home_assistant database and typed home-assistant instead? I see in the InfluxQL docs for GRANT that “Users can be granted privileges on databases that do not yet exist” (in other words, the DB doesn’t complain if you accidentally typo a DB name in a GRANT command)

is it possible that you/somebody accidentally made a typo when trying to grant privileges on the home_assistant database and typed home-assistant instead?

Yes! Thank you!!

Unfortunately the REVOKE command fails because its not a valid database. I had to drop the users and was able to successfully upgrade.