-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
*: support wal dir #3413
*: support wal dir #3413
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,15 @@ import ( | |
|
||
// ServerConfig holds the configuration of etcd as taken from the command line or discovery. | ||
type ServerConfig struct { | ||
Name string | ||
DiscoveryURL string | ||
DiscoveryProxy string | ||
ClientURLs types.URLs | ||
PeerURLs types.URLs | ||
DataDir string | ||
Name string | ||
DiscoveryURL string | ||
DiscoveryProxy string | ||
ClientURLs types.URLs | ||
PeerURLs types.URLs | ||
DataDir string | ||
// DedicatedWALDir config will make the etcd to write the WAL to the WALDir | ||
// rather than the dataDir/member/wal. | ||
DedicatedWALDir string | ||
SnapCount uint64 | ||
MaxSnapFiles uint | ||
MaxWALFiles uint | ||
|
@@ -105,7 +108,12 @@ func (c *ServerConfig) verifyLocalMember(strict bool) error { | |
|
||
func (c *ServerConfig) MemberDir() string { return path.Join(c.DataDir, "member") } | ||
|
||
func (c *ServerConfig) WALDir() string { return path.Join(c.MemberDir(), "wal") } | ||
func (c *ServerConfig) WALDir() string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't this logic be moved into the initialization of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could. But this is how MemberDir ans SnapshotDir works no2.(If I remember correctly, we have some legacy issue put all these here but we do not have to do it any more now ) We can clean them up all together in a future pull request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. |
||
if c.DedicatedWALDir != "" { | ||
return c.DedicatedWALDir | ||
} | ||
return path.Join(c.MemberDir(), "wal") | ||
} | ||
|
||
func (c *ServerConfig) SnapDir() string { return path.Join(c.MemberDir(), "snap") } | ||
|
||
|
@@ -129,6 +137,9 @@ func (c *ServerConfig) print(initial bool) { | |
} | ||
plog.Infof("data dir = %s", c.DataDir) | ||
plog.Infof("member dir = %s", c.MemberDir()) | ||
if c.DedicatedWALDir != "" { | ||
plog.Infof("dedicated WAL dir = %s", c.DedicatedWALDir) | ||
} | ||
plog.Infof("heartbeat = %dms", c.TickMs) | ||
plog.Infof("election = %dms", c.ElectionTicks*int(c.TickMs)) | ||
plog.Infof("snapshot count = %d", c.SnapCount) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,11 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) { | |
return nil, err | ||
} | ||
|
||
err = os.MkdirAll(cfg.MemberDir(), privateDirMode) | ||
if err != nil && err != os.ErrExist { | ||
return nil, err | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to make member dir in this commit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used to use mkall to create member dir when creating member/wal. It might not be enough after we support separate wal dir. |
||
|
||
haveWAL := wal.Exist(cfg.WALDir()) | ||
ss := snap.New(cfg.SnapDir()) | ||
|
||
|
@@ -258,6 +263,10 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) { | |
return nil, fmt.Errorf("cannot write to member directory: %v", err) | ||
} | ||
|
||
if err := fileutil.IsDirWriteable(cfg.WALDir()); err != nil { | ||
return nil, fmt.Errorf("cannot write to WAL directory: %v", err) | ||
} | ||
|
||
if cfg.ShouldDiscover() { | ||
plog.Warningf("discovery token ignored since a cluster has already been initialized. Valid log found at %q", cfg.WALDir()) | ||
} | ||
|
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.
it needs to be mentioned in etcdmain/help.go too.