Skip to content
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

Return an emulated etcd version in the status endpoint #316

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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