-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: influxd upgrade command #19591
Conversation
A couple of early comments @vlastahajek:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @vlastahajek.
Whilst I'm not averse to having some integration style tests in the repo against a small test set of real-world files (index or series files etc) I think that the contents that's been added here via the data
and wal
directories is too significant.
I can see two ways to improve this:
- you could programatically create the files during tests;
- you could just zip everything up into a single archive that is uncompressed into a temporary location (and then also cleaned up) during tests.
Alternatively I seem to recall there possibly being an alternative repo setup for test fixtures but I'm not sure if that impacts the influxdb repo or not.
@@ -0,0 +1,4 @@ | |||
# Ignore everything in this directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all of these .gitignore
files. Perhaps we can help you achieve what you were intending to do with these file a different way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files were added to allow committing the wal folder with empty dirs. As stated below, this will be cleaned.
@e-dard, I prefer to have a pre-created dataset to rest a real upgrade scenario. I will zip the test data in the repo.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got a bunch of comments, but I'm afraid this PR is rather to big to review in its entirety. Perhaps it could be split up into a bunch of independent parts working from the bottom up?
In general, the approach seems good though, thanks!
cmd/influxd/upgrade/upgrade.go
Outdated
// read each database / retention policy from v1.meta and create bucket db-name/rp-name | ||
// create database in v2.meta | ||
// copy shard info from v1.meta | ||
if len(v1.meta.Databases()) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about inverting the condition and returning early when there are no databases to save a bunch of indented code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
cmd/influxd/upgrade/upgrade.go
Outdated
} | ||
size += size2 | ||
v2dir := filepath.Dir(options.target.boltPath) | ||
diskInfo, err := fs2.DiskUsage(v2dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than import this very OS-dependent code in order to do a fairly inaccurate check (sum of file sizes doesn't equate to used disk space), it might be best just to let the user decide for themselves and provide a "dry run" mode that just says how much new disk space will be needed or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose user databases have size in hundreads of MB and probably more.. Do you think that it will be such a big difference that these will give false result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual error can be just because filesystem entries size and block size rounding, but comparing to the datafile sizes this shouldn't be much difference.
Even available disk space can be different during copying data, due to the other processes work.
This just a sanity check. If disk available size is very close to the requires size (condition when the check inaccuracy matters) is even bad for a system.
On the other hand, dry run mode is a new feature and can be added later..
cmd/influxd/upgrade/upgrade.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
if canOnboard { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invert the condition and return early?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
orgName string | ||
bucket string | ||
token string | ||
retention string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retention string | |
retention time.Duration |
Then you won't have to go to the trouble of parsing it yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the one bellow is done based on the setup command. So I suppose there is a good reason to have this way..
cmd/influxd/upgrade/upgrade.go
Outdated
return dir | ||
} | ||
|
||
func rawDurationToTimeDuration(raw string) (time.Duration, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why this is needed when we already have time.ParseDuration
and the flag package already directly supports time.Duration
-typed flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Actually, this is copied from the setup command, but it would be best to reuse this. Could you, please, suggest a good place to put it?
e5babb3
to
8b9751c
Compare
0a242d7
to
a30b148
Compare
a30b148
to
0699c25
Compare
Closes #19308
InfluxDB server command to upgrade 1.x config, database and users to 2.0.
Features:
TODOs:
Minimal command line includes parameters for creating admin:
influxd upgrade -b my-bucket -o my-org -u my-user -p my-password
Complete help: