-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
fix: add a warning message on startup if the server name is default #14613
Conversation
Codecov Report
@@ Coverage Diff @@
## main #14613 +/- ##
==========================================
- Coverage 75.76% 75.44% -0.33%
==========================================
Files 457 457
Lines 37267 37269 +2
==========================================
- Hits 28235 28117 -118
- Misses 7284 7385 +101
- Partials 1748 1767 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
for idx := range urls { | ||
m := NewMember(name, urls[idx:idx+1], token, nil) | ||
if _, ok := c.members[m.ID]; ok { | ||
return nil, fmt.Errorf("member exists with identical ID %v", m) |
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.
You might be heading in the wrong direction. Usually each member has different peerURL(s), they must have different memberID. FYI.
etcd/server/etcdserver/api/membership/member.go
Lines 63 to 76 in f215cd8
func computeMemberId(peerURLs types.URLs, clusterName string, now *time.Time) types.ID { | |
peerURLstrs := peerURLs.StringSlice() | |
sort.Strings(peerURLstrs) | |
joinedPeerUrls := strings.Join(peerURLstrs, "") | |
b := []byte(joinedPeerUrls) | |
b = append(b, []byte(clusterName)...) | |
if now != nil { | |
b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...) | |
} | |
hash := sha1.Sum(b) | |
return types.ID(binary.BigEndian.Uint64(hash[:8])) | |
} |
For simplicity, we can just add a warning message on startup if --name
isn't provided a value.
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.
Thank you very much for the reminder.
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.
updated. Please take a look again.
Instead of actually checking if --name
is empty, I'm checking if it's default.
Signed-off-by: nic-chen <chenjunxu6@gmail.com>
86e4a06
to
d4fbfb8
Compare
member count is unequal
error when initializing a cluster
server/etcdmain/etcd.go
Outdated
@@ -90,6 +90,10 @@ func startEtcdOrProxyV2(args []string) { | |||
lg.Info("failed to detect default host", zap.Error(dhErr)) | |||
} | |||
|
|||
if cfg.ec.Name == embed.DefaultName { | |||
lg.Warn("the server is using default name, which might cause error that failed the startup.") | |||
} |
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.
I suggest to add the check into (*Config) Validate(), so that we have all configuration checker in one place.
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.
Thanks!
I tried to find such a place, but failed.
So I put it here according to the content in the log 'data-dir' was empty; using default
...
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.
updated.
Signed-off-by: nic-chen <chenjunxu6@gmail.com>
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.
LGTM
Thank you @nic-chen
// because each member can have multiple client or peer URLs. | ||
// Please refer to https://github.com/etcd-io/etcd/issues/13757 | ||
if cfg.Name == DefaultName { | ||
cfg.logger.Warn("the server is using default name, which might cause error that failed the startup.") |
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.
I was planning to add a comment for this, but somehow forgot to do it:(
Please change it to something like below,
return fmt.Errorf("it isn't recommended to use %q name, please set a value for --name. Note that etcd might run into issue when multiple members have the same default name", DefaultName)
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.
Please ignore my previous comment. We can't return an error, because etcd may fail to get started. Let's just update the message,
cfg.logger.Warn("it isn't recommended to use %q name, please set a value for --name. Note that etcd might run into issue when multiple members have the same default name", DefaultName)
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.
OK, I will update it later today or tomorrow
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.
OK, I will update it later today or tomorrow
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.
updated. #14642
please take a look at your convenience. thanks.
fix #13757