Skip to content

Commit

Permalink
Return an emulated etcd version in the status endpoint (#316)
Browse files Browse the repository at this point in the history
* Return an emulated etcd version in the status endpoint
* Fix golangci-lint error
* Set default watch progress interval to 5s to ensure appropriate k8s support

Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
  • Loading branch information
sambhav authored Aug 21, 2024
1 parent 863b9f7 commit 227f4d3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ func main() {
},
&cli.DurationFlag{
Name: "watch-progress-notify-interval",
Usage: "Interval between periodic watch progress notifications. Default is 10m.",
Usage: "Interval between periodic watch progress notifications. Default is 5s to ensure support for watch progress notifications.",
Destination: &config.NotifyInterval,
Value: time.Minute * 10,
Value: time.Second * 5,
},
&cli.StringFlag{
Name: "emulated-etcd-version",
Usage: "The emulated etcd version to return on a call to the status endpoint. Defaults to 3.5.13, in order to indicate support for watch progress notifications.",
Destination: &config.EmulatedETCDVersion,
Value: "3.5.13",
},
&cli.BoolFlag{Name: "debug"},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/nats/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func getOrCreateBucket(ctx context.Context, js jetstream.JetStream, config *Conf

// Check for temporary JetStream errors when the cluster is unhealthy and retry.
if jsClusterNotAvailErr.Is(err) || jsNoSuitablePeersErr.Is(err) {
logrus.Warnf(err.Error())
logrus.Warn(err.Error())
time.Sleep(time.Second)
continue
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
BackendTLSConfig tls.Config
MetricsRegisterer prometheus.Registerer
NotifyInterval time.Duration
EmulatedETCDVersion string
}

type ETCDConfig struct {
Expand Down Expand Up @@ -82,7 +83,7 @@ func Listen(ctx context.Context, config Config) (ETCDConfig, error) {
}

// set up GRPC server and register services
b := server.New(backend, endpointScheme(config), config.NotifyInterval)
b := server.New(backend, endpointScheme(config), config.NotifyInterval, config.EmulatedETCDVersion)
grpcServer, err := grpcServer(config)
if err != nil {
return ETCDConfig{}, errors.Wrap(err, "creating GRPC server")
Expand Down
5 changes: 3 additions & 2 deletions pkg/server/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func (s *KVServerBridge) Status(ctx context.Context, r *etcdserverpb.StatusReque
return nil, err
}
return &etcdserverpb.StatusResponse{
Header: &etcdserverpb.ResponseHeader{},
DbSize: size,
Header: &etcdserverpb.ResponseHeader{},
DbSize: size,
Version: s.emulatedETCDVersion,
}, nil
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import (
)

type KVServerBridge struct {
limited *LimitedServer
emulatedETCDVersion string
limited *LimitedServer
}

func New(backend Backend, scheme string, notifyInterval time.Duration) *KVServerBridge {
func New(backend Backend, scheme string, notifyInterval time.Duration, emulatedETCDVersion string) *KVServerBridge {
return &KVServerBridge{
emulatedETCDVersion: emulatedETCDVersion,
limited: &LimitedServer{
notifyInterval: notifyInterval,
backend: backend,
Expand Down

0 comments on commit 227f4d3

Please sign in to comment.