etcd: Add a special magic option hack

Workaround some legacy code for now.
This commit is contained in:
James Shubin
2025-03-11 04:26:07 -04:00
parent 1cb9648b08
commit dce83efa96
3 changed files with 20 additions and 5 deletions

View File

@@ -262,6 +262,9 @@ type EmbdEtcd struct { // EMBeddeD etcd
// NoNetwork causes this to use unix:// sockets instead of TCP for
// connections.
NoNetwork bool
// NoMagic turns off some things which aren't needed when used with a
// simple Seeds and NoServer option.
NoMagic bool
// Chooser is the implementation of the algorithm that decides which
// hosts to add or remove to grow and shrink the cluster.
@@ -418,6 +421,10 @@ func (obj *EmbdEtcd) Validate() error {
}
}
if obj.NoMagic && !obj.NoServer {
return fmt.Errorf("we need Magic if we're a Server")
}
if _, err := etcdUtil.CopyURLs(obj.Seeds); err != nil { // this will validate
return errwrap.Wrapf(err, "the Seeds are not valid")
}
@@ -1215,11 +1222,13 @@ func (obj *EmbdEtcd) Run() error {
obj.activateExit4.Ack()
// startup endpoints watcher (to learn about other servers)
ctx, cancel := context.WithCancel(unblockCtx)
defer cancel() // cleanup on close...
if err := obj.runEndpoints(ctx); err != nil {
obj.activateExit5.Ack()
return err
if !obj.NoMagic { // disable possibly buggy code for now
ctx, cancel := context.WithCancel(unblockCtx)
defer cancel() // cleanup on close...
if err := obj.runEndpoints(ctx); err != nil {
obj.activateExit5.Ack()
return err
}
}
obj.activateExit5.Ack()
// We don't set state, we only watch others, so nothing to defer close!