Skip to content

Commit

Permalink
Address leftover TODOs from slog migrations (#48038)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstimothy authored Oct 29, 2024
1 parent 34f9d0d commit 820dc4e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 32 deletions.
4 changes: 0 additions & 4 deletions lib/services/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"log/slog"

"github.com/gravitational/trace"
"github.com/sirupsen/logrus"

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
Expand Down Expand Up @@ -54,9 +53,6 @@ type GenericReconcilerConfig[K comparable, T any] struct {
OnUpdate func(ctx context.Context, new, old T) error
// OnDelete is called when an existing resource is deleted.
OnDelete func(context.Context, T) error
// Log is the reconciler's logger.
// TODO(tross) remove this when all components in e have been updated
Log logrus.FieldLogger
// Logger emits log messages.
Logger *slog.Logger
}
Expand Down
9 changes: 3 additions & 6 deletions lib/srv/app/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package app
import (
"context"
"fmt"
"log/slog"

"github.com/gravitational/trace"

Expand All @@ -42,8 +41,7 @@ func (s *Server) startReconciler(ctx context.Context) error {
OnCreate: s.onCreate,
OnUpdate: s.onUpdate,
OnDelete: s.onDelete,
// TODO(tross): update to use the server logger once it is converted to slog
Logger: slog.With("kind", types.KindApp),
Logger: s.log.With("kind", types.KindApp),
})
if err != nil {
return trace.Wrap(err)
Expand Down Expand Up @@ -77,9 +75,8 @@ func (s *Server) startResourceWatcher(ctx context.Context) (*services.GenericWat
watcher, err := services.NewAppWatcher(ctx, services.AppWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentApp,
// TODO(tross): update this once converted to use slog
// Log: s.log,
Client: s.c.AccessPoint,
Logger: s.log,
Client: s.c.AccessPoint,
},
AppGetter: s.c.AccessPoint,
})
Expand Down
4 changes: 1 addition & 3 deletions lib/srv/desktop/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"log/slog"
"maps"
"net"
"net/netip"
Expand Down Expand Up @@ -55,8 +54,7 @@ func (s *WindowsService) startDesktopDiscovery() error {
OnCreate: s.upsertDesktop,
OnUpdate: s.updateDesktop,
OnDelete: s.deleteDesktop,
// TODO(tross): update to use the service logger once it is converted to use slog
Logger: slog.With("kind", types.KindWindowsDesktop),
Logger: s.cfg.Logger.With("kind", types.KindWindowsDesktop),
})
if err != nil {
return trace.Wrap(err)
Expand Down
5 changes: 0 additions & 5 deletions lib/usagereporter/teleport/aggregating/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/google/uuid"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"

"github.com/gravitational/teleport/api/types"
prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1"
Expand All @@ -52,15 +51,11 @@ const (
type ReporterConfig struct {
// Backend is the backend used to store reports. Required
Backend backend.Backend
// Log is the logger used for logging.
// TODO(tross): Delete once e has been converted
Log logrus.FieldLogger
// Logger is the used for emitting log messages.
Logger *slog.Logger
// Clock is the clock used for timestamping reports and deciding when to
// persist them to the backend. Optional, defaults to the real clock.
Clock clockwork.Clock

// ClusterName is the ClusterName resource for the current cluster, used for
// anonymization and to report the cluster name itself. Required.
ClusterName types.ClusterName
Expand Down
4 changes: 0 additions & 4 deletions lib/usagereporter/teleport/aggregating/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/google/uuid"
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"

"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils/retryutils"
Expand Down Expand Up @@ -69,9 +68,6 @@ var alertMessage = fmt.Sprintf("Teleport has failed to contact the usage reporti
type SubmitterConfig struct {
// Backend is the backend to use to read reports and apply locks. Required.
Backend backend.Backend
// Log is the [logrus.FieldLogger] used for logging.
// TODO(tross): remove once e has been converted
Log logrus.FieldLogger
// Logger is the used for emitting log messages.
Logger *slog.Logger
// Status is used to create or clear cluster alerts on a failure. Required.
Expand Down
11 changes: 1 addition & 10 deletions lib/usagereporter/teleport/usagereporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,7 @@ func (t *StreamingUsageReporter) Run(ctx context.Context) {

type SubmitFunc = usagereporter.SubmitFunc[prehogv1a.SubmitEventRequest]

// TODO(tross): change the log type once e has been updated
func NewStreamingUsageReporter(log any, clusterName types.ClusterName, anonymizationKey string, submitter SubmitFunc) (*StreamingUsageReporter, error) {
logger := slog.Default()

if log != nil {
if l, ok := log.(*slog.Logger); ok {
logger = l
}
}

func NewStreamingUsageReporter(logger *slog.Logger, clusterName types.ClusterName, anonymizationKey string, submitter SubmitFunc) (*StreamingUsageReporter, error) {
if anonymizationKey == "" {
return nil, trace.BadParameter("anonymization key is required")
}
Expand Down

0 comments on commit 820dc4e

Please sign in to comment.