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

Address leftover TODOs from slog migrations #48038

Merged
merged 1 commit into from
Oct 29, 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
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 @@ -41,8 +40,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 @@ -76,9 +74,8 @@ func (s *Server) startResourceWatcher(ctx context.Context) (*services.AppWatcher
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,
},
})
if err != nil {
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 @@ -54,8 +53,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
Loading