etcd: scheduler: Remove etcd 3.2 specific hacks

Now that we're using etcd 3.3, we can simplify our code now that our
patches are in a release.
This commit is contained in:
James Shubin
2018-02-18 18:07:59 -05:00
parent 24cb2e6450
commit 28ec7a1e54

View File

@@ -28,7 +28,6 @@ import (
etcd "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/clientv3/concurrency"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
errwrap "github.com/pkg/errors"
)
@@ -88,11 +87,6 @@ func (obj *Result) Shutdown() {
// XXX: should we have a waitgroup to wait for it all to close?
}
// TODO: use: https://github.com/coreos/etcd/pull/8488 when available
func leaseValue(key string) etcd.Cmp {
return etcd.Cmp{Key: []byte(key), Target: pb.Compare_LEASE}
}
// Schedule returns a scheduler result which can be queried with it's available
// methods. This automatically causes different etcd clients sharing the same
// path to discover each other and be part of the scheduled set. On close the
@@ -181,7 +175,7 @@ func Schedule(client *etcd.Client, path string, hostname string, opts ...Option)
data := "TODO" // XXX: no data to exchange alongside hostnames yet
ifops := []etcd.Cmp{
etcd.Compare(etcd.Value(exchangePathHost), "=", data),
etcd.Compare(leaseValue(exchangePathHost), "=", int64(leaseID)), // XXX: remove int64() after 3.3.0
etcd.Compare(etcd.LeaseValue(exchangePathHost), "=", leaseID),
}
elsop := etcd.OpPut(exchangePathHost, data, etcd.WithLease(leaseID))