Skip to content

Commit

Permalink
chore: Unvendor. Upgrade dependencies. Make tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlovelltroy committed Nov 7, 2024
1 parent 25faf77 commit 39fd698
Show file tree
Hide file tree
Showing 576 changed files with 125 additions and 349,386 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}
56 changes: 23 additions & 33 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
module github.com/Cray-HPE/hms-hmetcd

go 1.16
go 1.23

require (
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.13+incompatible
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/google/btree v1.0.0 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.8.6 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/sirupsen/logrus v1.4.1 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/etcd v3.3.13+incompatible
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5 // indirect
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/grpc v1.29.1 // indirect
gopkg.in/yaml.v2 v2.2.1 // indirect
go.etcd.io/etcd/api/v3 v3.5.16
go.etcd.io/etcd/client/v3 v3.5.16
)

require (
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

require (
github.com/coreos/go-semver v0.3.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/grpc v1.68.0 // indirect
)
202 changes: 65 additions & 137 deletions go.sum

Large diffs are not rendered by default.

63 changes: 34 additions & 29 deletions kvs_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ package hmetcd
import (
"context"
"fmt"
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
"go.etcd.io/etcd/clientv3/concurrency"
"log"
"os"
"path"
"strings"
"sync"
"time"

"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
)

// Distributed lock stuff
Expand Down Expand Up @@ -139,12 +140,13 @@ func getAppBase() string {
}

// (ETCD) Get the value of a key. There are several possible return scenarios:
// o There is an error fetching the key. This will result in an empty key,
// non-nil error string and the key-exists indicator set to false.
// o The key exists but has an empty-string value. The return values will
// be an empty string, key-exists flag set to true, and a nil error.
// o The key exists and has a non-empty value. The return value will be
// the key's value, key-exissts flag set to true, and a nil error.
//
// o There is an error fetching the key. This will result in an empty key,
// non-nil error string and the key-exists indicator set to false.
// o The key exists but has an empty-string value. The return values will
// be an empty string, key-exists flag set to true, and a nil error.
// o The key exists and has a non-empty value. The return value will be
// the key's value, key-exissts flag set to true, and a nil error.
//
// key(in): Key to get the value of.
//
Expand All @@ -163,7 +165,7 @@ func (kvs *Kvs_etcd) Get(key string) (string, bool, error) {
return "", false, nil
}
if kval.Count > 1 {
err := fmt.Errorf("WARNING: fetched %d keys for '%s', should only be 1!\n",
err := fmt.Errorf("WARNING: fetched %d keys for '%s', should only be 1",
kval.Count, key)
//for _,ev := range kval.Kvs {
// log.Printf("Key: '%s', val: '%s'\n",ev.Key,ev.Value)
Expand All @@ -175,12 +177,13 @@ func (kvs *Kvs_etcd) Get(key string) (string, bool, error) {
}

// (MEM) Get the value of a key. There are several possible return scenarios:
// o There is an error fetching the key. This will result in an empty key,
// non-nil error string and the key-exists indicator set to false.
// o The key exists but has an empty-string value. The return values will
// be an empty string, key-exists flag set to true, and a nil error.
// o The key exists and has a non-empty value. The return value will be
// the key's value, key-exissts flag set to true, and a nil error.
//
// o There is an error fetching the key. This will result in an empty key,
// non-nil error string and the key-exists indicator set to false.
// o The key exists but has an empty-string value. The return values will
// be an empty string, key-exists flag set to true, and a nil error.
// o The key exists and has a non-empty value. The return value will be
// the key's value, key-exissts flag set to true, and a nil error.
//
// key(in): Key to get the value of.
//
Expand Down Expand Up @@ -523,7 +526,7 @@ func (kvs *Kvs_etcd) DistTimedLock(tosec int) error {
var err error

if kvs.cc_session != nil {
err = fmt.Errorf("ERROR: distributed lock already held by this process!")
err = fmt.Errorf("ERROR: distributed lock already held by this process")
return err
}

Expand Down Expand Up @@ -629,10 +632,10 @@ func (kvs *Kvs_etcd) Watch(key string) (string, int) {
case mvccpb.PUT:
kcval = KVC_KEYCHANGE_PUT
keyval = string(ev.Kv.Value) //string(ev.PrevKv.Value)) ??
break

case mvccpb.DELETE:
kcval = KVC_KEYCHANGE_DELETE
break

default:
log.Printf("ERROR: Unknown trip type: '%s'\n",
string(ev.Type))
Expand Down Expand Up @@ -713,7 +716,7 @@ func watch_helper_etcd(hnd WatchCBHandle) {
hnd.cb(string(ev.Kv.Key), "", hnd.op, hnd.userdata)
rv = false //TODO: should we keep watching a deleted key?
}
case _ = <-hnd.killme:
case <-hnd.killme:
return
}

Expand All @@ -735,7 +738,7 @@ func watch_helper_mem(hnd WatchCBHandle) {
for {
rv = true
select {
case _ = <-hnd.killme:
case <-hnd.killme:
return
default:
val, op := mem_watch(hnd.hnd_mem, hnd.key)
Expand Down Expand Up @@ -763,9 +766,10 @@ func watch_helper_mem(hnd WatchCBHandle) {
// Cancelation:
//
// The watcher will run until the one of the following takes place:
// o The key watched key is deleted,
// o The callback function returns 'false'
// o The watcher is manually cancelled by calling WatchCBCancel().
//
// o The key watched key is deleted,
// o The callback function returns 'false'
// o The watcher is manually cancelled by calling WatchCBCancel().
//
// key(in): Key to watch.
//
Expand All @@ -780,7 +784,7 @@ func (kvs *Kvs_etcd) WatchWithCB(key string, op int, cb WatchCBFunc, userdata in
var wh = WatchCBHandle{}

if (op != KVC_KEYCHANGE_PUT) && (op != KVC_KEYCHANGE_DELETE) {
return wh, fmt.Errorf("Invalid key watch operation: %d", op)
return wh, fmt.Errorf("invalid key watch operation: %d", op)
}

wh = WatchCBHandle{key, op, make(chan int, 2), cb, userdata, kvs, nil}
Expand All @@ -796,9 +800,10 @@ func (kvs *Kvs_etcd) WatchWithCB(key string, op int, cb WatchCBFunc, userdata in
// Cancelation:
//
// The watcher will run until the one of the following takes place:
// o The key watched key is deleted,
// o The callback function returns 'false'
// o The watcher is manually cancelled by calling WatchCBCancel().
//
// o The key watched key is deleted,
// o The callback function returns 'false'
// o The watcher is manually cancelled by calling WatchCBCancel().
//
// key(in): Key to watch.
//
Expand All @@ -813,7 +818,7 @@ func (kvs *Kvs_etcd) WatchWithCB(key string, op int, cb WatchCBFunc, userdata in
func (kvs *Kvs_mem) WatchWithCB(key string, op int, cb WatchCBFunc, userdata interface{}) (WatchCBHandle, error) {
var wh = WatchCBHandle{}
if (op != KVC_KEYCHANGE_PUT) && (op != KVC_KEYCHANGE_DELETE) {
return wh, fmt.Errorf("Invalid key watch operation: %d", op)
return wh, fmt.Errorf("invalid key watch operation: %d", op)
}
wh = WatchCBHandle{key, op, make(chan int, 2), cb, userdata, nil, kvs}
go watch_helper_mem(wh)
Expand Down
Loading

0 comments on commit 39fd698

Please sign in to comment.