Skip to content

Commit

Permalink
Revert local sdk logging from Debug->Info (#1443)
Browse files Browse the repository at this point in the history
I got too aggressive with moving logging to Debug, and somehow managed
to pickup the local SDK.

I don't think the local SDK logging should be moved to debug, as the
reason the local SDK server exists is to provide information about what
SDK commands are being run -- so it is an Info level debug operation,
  • Loading branch information
markmandel authored Apr 2, 2020
1 parent 0f376ea commit 5ffef5c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions pkg/sdkserver/localsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ func NewLocalSDKServer(filePath string) (*LocalSDKServer, error) {
if event.Op != fsnotify.Write {
continue
}
logrus.WithField("event", event).Debug("File has been changed!")
logrus.WithField("event", event).Info("File has been changed!")
err := l.setGameServerFromFilePath(filePath)
if err != nil {
logrus.WithError(err).Error("error setting GameServer from file")
continue
}
logrus.Debug("Sending watched GameServer!")
logrus.Info("Sending watched GameServer!")
l.update <- struct{}{}
}
}()
Expand All @@ -129,7 +129,7 @@ func NewLocalSDKServer(filePath string) (*LocalSDKServer, error) {

go func() {
for value := range l.update {
logrus.Debug("Gameserver update received")
logrus.Info("Gameserver update received")
l.updateObservers.Range(func(observer, _ interface{}) bool {
observer.(chan struct{}) <- value
return true
Expand Down Expand Up @@ -196,7 +196,7 @@ func (l *LocalSDKServer) updateState(newState agonesv1.GameServerState) {

// Ready logs that the Ready request has been received
func (l *LocalSDKServer) Ready(context.Context, *sdk.Empty) (*sdk.Empty, error) {
logrus.Debug("Ready request has been received!")
logrus.Info("Ready request has been received!")
l.recordRequest("ready")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()
Expand All @@ -210,7 +210,7 @@ func (l *LocalSDKServer) Ready(context.Context, *sdk.Empty) (*sdk.Empty, error)

// Allocate logs that an allocate request has been received
func (l *LocalSDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, error) {
logrus.Debug("Allocate request has been received!")
logrus.Info("Allocate request has been received!")
l.recordRequest("allocate")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()
Expand All @@ -223,7 +223,7 @@ func (l *LocalSDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, erro

// Shutdown logs that the shutdown request has been received
func (l *LocalSDKServer) Shutdown(context.Context, *sdk.Empty) (*sdk.Empty, error) {
logrus.Debug("Shutdown request has been received!")
logrus.Info("Shutdown request has been received!")
l.recordRequest("shutdown")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()
Expand All @@ -238,20 +238,20 @@ func (l *LocalSDKServer) Health(stream sdk.SDK_HealthServer) error {
for {
_, err := stream.Recv()
if err == io.EOF {
logrus.Debug("Health stream closed.")
logrus.Info("Health stream closed.")
return stream.SendAndClose(&sdk.Empty{})
}
if err != nil {
return errors.Wrap(err, "Error with Health check")
}
l.recordRequest("health")
logrus.Debug("Health Ping Received!")
logrus.Info("Health Ping Received!")
}
}

// SetLabel applies a Label to the backing GameServer metadata
func (l *LocalSDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error) {
logrus.WithField("values", kv).Debug("Setting label")
logrus.WithField("values", kv).Info("Setting label")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()

Expand All @@ -270,7 +270,7 @@ func (l *LocalSDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Emp

// SetAnnotation applies a Annotation to the backing GameServer metadata
func (l *LocalSDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error) {
logrus.WithField("values", kv).Debug("Setting annotation")
logrus.WithField("values", kv).Info("Setting annotation")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()

Expand All @@ -289,7 +289,7 @@ func (l *LocalSDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sd

// GetGameServer returns current GameServer configuration.
func (l *LocalSDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameServer, error) {
logrus.Debug("Getting GameServer details")
logrus.Info("Getting GameServer details")
l.recordRequest("gameserver")
l.gsMutex.RLock()
defer l.gsMutex.RUnlock()
Expand All @@ -298,7 +298,7 @@ func (l *LocalSDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameSe

// WatchGameServer will return current GameServer configuration, 3 times, every 5 seconds
func (l *LocalSDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameServerServer) error {
logrus.Debug("Connected to watch GameServer...")
logrus.Info("Connected to watch GameServer...")
observer := make(chan struct{})

defer func() {
Expand All @@ -323,7 +323,7 @@ func (l *LocalSDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameS

// Reserve moves this GameServer to the Reserved state for the Duration specified
func (l *LocalSDKServer) Reserve(ctx context.Context, d *sdk.Duration) (*sdk.Empty, error) {
logrus.WithField("duration", d).Debug("Reserve request has been received!")
logrus.WithField("duration", d).Info("Reserve request has been received!")
l.recordRequest("reserve")
l.gsMutex.Lock()
defer l.gsMutex.Unlock()
Expand Down Expand Up @@ -426,18 +426,18 @@ func EqualSets(a, b []string) bool {

// Close tears down all the things
func (l *LocalSDKServer) compare() {
logrus.Debug("Compare")
logrus.Info("Compare")

if l.testMode {
if !EqualSets(l.expectedSequence, l.requestSequence) {
logrus.Debug(fmt.Sprintf("Testing Failed %v %v", l.expectedSequence, l.requestSequence))
logrus.Info(fmt.Sprintf("Testing Failed %v %v", l.expectedSequence, l.requestSequence))
os.Exit(1)
}
}
}

func (l *LocalSDKServer) setGameServerFromFilePath(filePath string) error {
logrus.WithField("filePath", filePath).Debug("Reading GameServer configuration")
logrus.WithField("filePath", filePath).Info("Reading GameServer configuration")

reader, err := os.Open(filePath) // nolint: gosec
defer reader.Close() // nolint: megacheck,errcheck
Expand Down

0 comments on commit 5ffef5c

Please sign in to comment.