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

Prevent stolonctl init with empty file #22

Closed
wants to merge 1 commit into from

Conversation

benwh
Copy link

@benwh benwh commented Sep 15, 2019

This fixes what is debatably a bug, where supplying the file flag to
stolonctl init with a value that points to an empty file results in
initialising the cluster with an initMode of new.

This behaviour is dangerous because if the user intended to supply a
file that contained a cluster specification with an initMode of
existing, but mistakenly supplied a path to an empty file, then it
would result in the keeper data being removed.

To resolve this, change the behaviour of the command to always attempt
the unmarshalling of the supplied cluster spec JSON, which will result
in a fatal error in the case of an empty file.

If the user intends to initialise the cluster with a blank (initMode: new)
cluster specification then they should do so by omitting the file
flag and cluster specification argument, as is already possible.

This fixes what is debatably a bug, where supplying the file flag to
`stolonctl init` with a value that points to an empty file results in
initialising the cluster with an `initMode` of `new`.

This behaviour is dangerous because if the user intended to supply a
file that contained a cluster specification with an `initMode` of
`existing`, but mistakenly supplied a path to an empty file, then it
would result in the keeper data being removed.

To resolve this, change the behaviour of the command to always attempt
the unmarshalling of the supplied cluster spec JSON, which will result
in a fatal error in the case of an empty file.

If the user intends to initialise the cluster with a blank (`initMode:
new`) cluster specification then they should do so by omitting the file
flag and cluster specification argument, as is already possible.
@benwh
Copy link
Author

benwh commented Sep 15, 2019

@lawrencejones Thoughts on this? Do you think it's upstream-able?

Technically it's a change of interface, even if you'd really hope nobody is relying on this behaviour.

@lawrencejones
Copy link

Yeah I think this is absolutely upstreamable. It's a usability issue- can you make this PR to upstream instead?

@benwh
Copy link
Author

benwh commented Sep 20, 2019

Will do!

Edit: See here

@benwh benwh closed this Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants