Skip to content

Prevent stolonctl init with empty file#702

Merged
sgotti merged 1 commit into
sorintlab:masterfrom
gocardless:benwh/no-init-empty-file
Oct 8, 2019
Merged

Prevent stolonctl init with empty file#702
sgotti merged 1 commit into
sorintlab:masterfrom
gocardless:benwh/no-init-empty-file

Conversation

@benwh

@benwh benwh commented Sep 20, 2019

Copy link
Copy Markdown
Contributor

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

sgotti commented Oct 8, 2019

Copy link
Copy Markdown
Member

@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