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 #702

Merged
merged 1 commit into from
Oct 8, 2019

Conversation

benwh
Copy link
Contributor

@benwh benwh commented Sep 20, 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.
@sgotti
Copy link
Member

sgotti commented Oct 8, 2019

@benwh Thanks! LGTM.

@sgotti sgotti merged commit 182e091 into sorintlab:master Oct 8, 2019
@sgotti sgotti added this to the v0.15.0 milestone Dec 3, 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