-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Check if data-dir is a directory #2529
Conversation
imho, If an app is told to use a directory and has the perms to create it, it should attempt to create it if missing. Nothing more frustrating than that one box out of thirty where someone made a boneheaded manual change that laid a timebomb your service can't recover from. |
@babbottscott Thoughts on this @slackpad ? It wouldn't be hard to implement but I'm not sure if this is the intended behavior for this case. |
@mckennajones @babbottscott That's a good suggestion in general, but I'd keep the current behavior for Consul and not auto-create the directory. We use the presence of state in that directory to tell if a cluster is fresh and whether it's safe to bootstrap, for example, so I'd rather be conservative and have it error out. For non-servers it might be safe to create it on the fly, but that's probably too subtle/complex to have a behavior difference. |
@@ -209,6 +209,12 @@ func (c *Command) readConfig() *Config { | |||
return nil | |||
} | |||
|
|||
if finfo, _ := os.Stat(config.DataDir); !finfo.IsDir() { |
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.
We should handle the error here in case they gave an invalid path.
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.
@kyhavlov What are you suggesting differently than what I have done?
fix for #1838