From 4f64b3b1edf4bebe33fa8c10fd1850b7eb62ca37 Mon Sep 17 00:00:00 2001 From: Aleksei Pleshakov Date: Mon, 11 Nov 2024 18:14:39 +0400 Subject: [PATCH] log IDs where possible, do not log user db data --- internal/backup_operations/make_backup.go | 3 +++ internal/connectors/client/connector.go | 7 ------- internal/server/services/backup/backup_service.go | 10 ++++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/backup_operations/make_backup.go b/internal/backup_operations/make_backup.go index 16ba86bf..230354d5 100644 --- a/internal/backup_operations/make_backup.go +++ b/internal/backup_operations/make_backup.go @@ -104,6 +104,9 @@ func MakeBackup( subject string, clock clockwork.Clock, ) (*types.Backup, *types.TakeBackupOperation, error) { + if req.ScheduleID != nil { + ctx = xlog.With(ctx, zap.String("ScheduleID", *req.ScheduleID)) + } if !IsAllowedEndpoint(req.DatabaseEndpoint, allowedEndpointDomains, allowInsecureEndpoint) { xlog.Error( ctx, diff --git a/internal/connectors/client/connector.go b/internal/connectors/client/connector.go index db6d50e9..a94c943a 100644 --- a/internal/connectors/client/connector.go +++ b/internal/connectors/client/connector.go @@ -178,13 +178,6 @@ func listDirectory(ctx context.Context, clientDb *ydb.Driver, initialPath string func (d *ClientYdbConnector) PreparePathsForExport( ctx context.Context, clientDb *ydb.Driver, sourcePaths []string, sourcePathsToExclude []string, ) ([]string, error) { - xlog.Debug( - ctx, - "Preparing paths for export", - zap.String("database_name", clientDb.Name()), - zap.Strings("paths", sourcePaths), - zap.Strings("paths_to_exclude", sourcePathsToExclude), - ) if clientDb == nil { return nil, fmt.Errorf("unititialized client db driver") } diff --git a/internal/server/services/backup/backup_service.go b/internal/server/services/backup/backup_service.go index 76c402e5..3ecf8b1c 100644 --- a/internal/server/services/backup/backup_service.go +++ b/internal/server/services/backup/backup_service.go @@ -39,6 +39,7 @@ type BackupService struct { func (s *BackupService) GetBackup(ctx context.Context, request *pb.GetBackupRequest) (*pb.Backup, error) { ctx = grpcinfo.WithGRPCInfo(ctx) xlog.Debug(ctx, "GetBackup", zap.String("request", request.String())) + ctx = xlog.With(ctx, zap.String("BackupID", request.Id)) backupID, err := types.ParseObjectID(request.GetId()) if err != nil { xlog.Error(ctx, "failed to parse BackupID", zap.Error(err)) @@ -79,8 +80,8 @@ func (s *BackupService) GetBackup(ctx context.Context, request *pb.GetBackupRequ func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupRequest) (*pb.Operation, error) { ctx = grpcinfo.WithGRPCInfo(ctx) - xlog.Info(ctx, "MakeBackup", zap.String("request", req.String())) + ctx = xlog.With(ctx, zap.String("ContainerID", req.ContainerId)) subject, err := auth.CheckAuth(ctx, s.auth, auth.PermissionBackupCreate, req.ContainerId, "") if err != nil { @@ -101,6 +102,7 @@ func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupReques if err != nil { return nil, err } + ctx = xlog.With(ctx, zap.String("BackupID", backup.ID)) ctx = xlog.With(ctx, zap.String("OperationID", op.GetID())) xlog.Debug(ctx, "MakeBackup was started successfully", zap.String("operation", types.OperationToString(op))) return op.Proto(), nil @@ -109,6 +111,7 @@ func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupReques func (s *BackupService) DeleteBackup(ctx context.Context, req *pb.DeleteBackupRequest) (*pb.Operation, error) { ctx = grpcinfo.WithGRPCInfo(ctx) xlog.Info(ctx, "DeleteBackup", zap.String("request", req.String())) + ctx = xlog.With(ctx, zap.String("BackupID", req.BackupId)) backupID, err := types.ParseObjectID(req.BackupId) if err != nil { @@ -192,6 +195,7 @@ func (s *BackupService) DeleteBackup(ctx context.Context, req *pb.DeleteBackupRe func (s *BackupService) MakeRestore(ctx context.Context, req *pb.MakeRestoreRequest) (*pb.Operation, error) { ctx = grpcinfo.WithGRPCInfo(ctx) xlog.Info(ctx, "MakeRestore", zap.String("request", req.String())) + ctx = xlog.With(ctx, zap.String("BackupID", req.BackupId)) backupID, err := types.ParseObjectID(req.BackupId) if err != nil { @@ -232,7 +236,9 @@ func (s *BackupService) MakeRestore(ctx context.Context, req *pb.MakeRestoreRequ if !backup_operations.IsAllowedEndpoint(req.DatabaseEndpoint, s.allowedEndpointDomains, s.allowInsecureEndpoint) { xlog.Error( - ctx, "endpoint of database is invalid or not allowed", zap.String("DatabaseEndpoint", req.DatabaseEndpoint), + ctx, + "endpoint of database is invalid or not allowed", + zap.String("DatabaseEndpoint", req.DatabaseEndpoint), ) return nil, status.Errorf( codes.InvalidArgument, "endpoint of database is invalid or not allowed, endpoint %s", req.DatabaseEndpoint,