diff --git a/base-images/image_versions.yml b/base-images/image_versions.yml index 5d1082d84..332bbd430 100644 --- a/base-images/image_versions.yml +++ b/base-images/image_versions.yml @@ -4,7 +4,7 @@ REGISTRY_PATH: "docker.io/" # Virtualization images BASE_DEBIAN_BOOKWORM_SLIM: "debian:bookworm-slim@sha256:a629e796d77a7b2ff82186ed15d01a493801c020eed5ce6adaa2704356f15a1c" BASE_CONTAINER_REGISTRY: "registry:2.8.3@sha256:ac0192b549007e22998eb74e8d8488dcfe70f1489520c3b144a6047ac5efbe90" -BASE_GOLANG_22_BOOKWORM: "golang:1.22.7-bookworm@sha256:027bd04b1d3b4529bf8ccebf62eb7eeeae7b7bef134a68bd419824e929ad93ad" +BASE_GOLANG_22_BOOKWORM: "golang:1.22.8-bookworm@sha256:3f0457a0a56a926d93c2baf4cf0057a645e8ff69ff31314080fcc62389643b8e" BASE_ALT_P10: "alt:p10@sha256:4fab03b8d23eb16147397b0bc41a5025ba59f4e834f7fb4b933ac5206431d740" # Digest for image created at 2024-09-20. diff --git a/images/virtualization-artifact/cmd/virtualization-controller/main.go b/images/virtualization-artifact/cmd/virtualization-controller/main.go index 166e32cad..400d7d729 100644 --- a/images/virtualization-artifact/cmd/virtualization-controller/main.go +++ b/images/virtualization-artifact/cmd/virtualization-controller/main.go @@ -35,6 +35,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager/signals" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/common" appconfig "github.com/deckhouse/virtualization-controller/pkg/config" "github.com/deckhouse/virtualization-controller/pkg/controller/cvi" @@ -81,9 +82,6 @@ func main() { var logDebugVerbosity int flag.IntVar(&logDebugVerbosity, "log-debug-verbosity", int(defaultDebugVerbosity), "log debug verbosity") - var logFormat string - flag.StringVar(&logFormat, "log-format", os.Getenv(logFormatEnv), "log format") - var logOutput string flag.StringVar(&logOutput, "log-output", os.Getenv(logOutputEnv), "log output") @@ -92,11 +90,9 @@ func main() { flag.Parse() - log := logger.New(logger.Options{ - Level: logLevel, - DebugVerbosity: logDebugVerbosity, - Format: logFormat, - Output: logOutput, + log := log.NewLogger(log.Options{ + Level: logger.DetectLogLevel(logLevel, logDebugVerbosity), + Output: logger.DetectLogOutput(logOutput), }) logger.SetDefaultLogger(log) @@ -291,7 +287,7 @@ func main() { } } -func printVersion(log *slog.Logger) { +func printVersion(log *log.Logger) { log.Info(fmt.Sprintf("Go Version: %s", runtime.Version())) log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)) } diff --git a/images/virtualization-artifact/go.mod b/images/virtualization-artifact/go.mod index 768820a04..bd902769a 100644 --- a/images/virtualization-artifact/go.mod +++ b/images/virtualization-artifact/go.mod @@ -1,6 +1,6 @@ module github.com/deckhouse/virtualization-controller -go 1.22.7 +go 1.22.8 require ( github.com/deckhouse/virtualization/api v0.0.0-00010101000000-000000000000 @@ -14,7 +14,7 @@ require ( github.com/prometheus/client_golang v1.18.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.7.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 go.uber.org/zap v1.26.0 k8s.io/api v0.30.2 k8s.io/apiextensions-apiserver v0.30.0 @@ -33,6 +33,8 @@ require ( sigs.k8s.io/yaml v1.4.0 ) +require github.com/DataDog/gostackparse v0.7.0 // indirect + require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect @@ -45,6 +47,7 @@ require ( github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241113072037-8825f2588d0f github.com/docker/docker v25.0.6+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect diff --git a/images/virtualization-artifact/go.sum b/images/virtualization-artifact/go.sum index 8152e104d..3af052ea3 100644 --- a/images/virtualization-artifact/go.sum +++ b/images/virtualization-artifact/go.sum @@ -5,6 +5,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/DataDog/gostackparse v0.7.0 h1:i7dLkXHvYzHV308hnkvVGDL3BR4FWl7IsXNPz/IGQh4= +github.com/DataDog/gostackparse v0.7.0/go.mod h1:lTfqcJKqS9KnXQGnyQMCugq3u1FP6UZMfWR0aitKFMM= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= @@ -39,6 +41,9 @@ github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241112131304-2e49a30b5e43/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241113072037-8825f2588d0f h1:2imDVTm2VlLCQVj5ZqxaSWHg59mPG2EZecdd6cwkBBw= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241113072037-8825f2588d0f/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/cli v23.0.5+incompatible h1:ufWmAOuD3Vmr7JP2G5K3cyuNC4YZWiAsuDEvFVVDafE= @@ -300,6 +305,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= diff --git a/images/virtualization-artifact/hack/dlv-controller.Dockerfile b/images/virtualization-artifact/hack/dlv-controller.Dockerfile index ae46ed521..a8e03a55f 100644 --- a/images/virtualization-artifact/hack/dlv-controller.Dockerfile +++ b/images/virtualization-artifact/hack/dlv-controller.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.7-bookworm@sha256:027bd04b1d3b4529bf8ccebf62eb7eeeae7b7bef134a68bd419824e929ad93ad AS builder +FROM golang:1.22.8-bookworm@sha256:3f0457a0a56a926d93c2baf4cf0057a645e8ff69ff31314080fcc62389643b8e AS builder ARG TARGETOS ARG TARGETARCH diff --git a/images/virtualization-artifact/pkg/controller/cvi/cvi_controller.go b/images/virtualization-artifact/pkg/controller/cvi/cvi_controller.go index c28a605ab..6ac29bfc1 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/cvi_controller.go +++ b/images/virtualization-artifact/pkg/controller/cvi/cvi_controller.go @@ -18,7 +18,6 @@ package cvi import ( "context" - "log/slog" "time" corev1 "k8s.io/api/core/v1" @@ -27,6 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/cvi/internal" "github.com/deckhouse/virtualization-controller/pkg/controller/cvi/internal/source" "github.com/deckhouse/virtualization-controller/pkg/controller/service" @@ -49,7 +49,7 @@ type Condition interface { func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, importerImage string, uploaderImage string, requirements corev1.ResourceRequirements, diff --git a/images/virtualization-artifact/pkg/controller/cvi/cvi_webhook.go b/images/virtualization-artifact/pkg/controller/cvi/cvi_webhook.go index 19cc564b6..a7ecf4a98 100644 --- a/images/virtualization-artifact/pkg/controller/cvi/cvi_webhook.go +++ b/images/virtualization-artifact/pkg/controller/cvi/cvi_webhook.go @@ -19,22 +19,22 @@ package cvi import ( "context" "fmt" - "log/slog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/conditions" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/cvicondition" ) type Validator struct { - logger *slog.Logger + logger *log.Logger } -func NewValidator(logger *slog.Logger) *Validator { +func NewValidator(logger *log.Logger) *Validator { return &Validator{ logger: logger.With("webhook", "validator"), } diff --git a/images/virtualization-artifact/pkg/controller/gc/cron_source.go b/images/virtualization-artifact/pkg/controller/gc/cron_source.go index 49cb8ee85..52f8266f3 100644 --- a/images/virtualization-artifact/pkg/controller/gc/cron_source.go +++ b/images/virtualization-artifact/pkg/controller/gc/cron_source.go @@ -20,7 +20,6 @@ import ( "cmp" "context" "fmt" - "log/slog" "slices" "time" @@ -36,6 +35,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" "github.com/deckhouse/virtualization-controller/pkg/sdk/framework/helper" ) @@ -48,7 +48,7 @@ func NewCronSource(c client.Client, standardSpec string, objList client.ObjectList, option CronSourceOption, - log *slog.Logger, + log *log.Logger, ) *CronSource { return &CronSource{ Client: c, @@ -64,20 +64,20 @@ type CronSource struct { standardSpec string objList client.ObjectList option CronSourceOption - log *slog.Logger + log *log.Logger } type CronSourceOption struct { GetOlder func(objList client.ObjectList) client.ObjectList } -func NewDefaultCronSourceOption(objs client.ObjectList, ttl time.Duration, log *slog.Logger) CronSourceOption { +func NewDefaultCronSourceOption(objs client.ObjectList, ttl time.Duration, log *log.Logger) CronSourceOption { return CronSourceOption{ GetOlder: DefaultGetOlder(objs, ttl, 10, log), } } -func DefaultGetOlder(objs client.ObjectList, ttl time.Duration, maxCount int, log *slog.Logger) func(objList client.ObjectList) client.ObjectList { +func DefaultGetOlder(objs client.ObjectList, ttl time.Duration, maxCount int, log *log.Logger) func(objList client.ObjectList) client.ObjectList { return func(objList client.ObjectList) client.ObjectList { var expiredItems []runtime.Object var notExpiredItems []runtime.Object diff --git a/images/virtualization-artifact/pkg/controller/gc/gc_controller.go b/images/virtualization-artifact/pkg/controller/gc/gc_controller.go index 6a4c2c876..0c6456952 100644 --- a/images/virtualization-artifact/pkg/controller/gc/gc_controller.go +++ b/images/virtualization-artifact/pkg/controller/gc/gc_controller.go @@ -17,18 +17,17 @@ limitations under the License. package gc import ( - "log/slog" - "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/source" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) func SetupGcController( controllerName string, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, watchSource source.Source, newObject NewObject, isNeedDelete IsNeedDelete, diff --git a/images/virtualization-artifact/pkg/controller/gc/gc_reconciler.go b/images/virtualization-artifact/pkg/controller/gc/gc_reconciler.go index 845777855..c737820b0 100644 --- a/images/virtualization-artifact/pkg/controller/gc/gc_reconciler.go +++ b/images/virtualization-artifact/pkg/controller/gc/gc_reconciler.go @@ -18,7 +18,6 @@ package gc import ( "context" - "log/slog" "time" "k8s.io/client-go/tools/record" @@ -32,6 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) @@ -77,7 +77,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( return reconcile.Result{}, nil } -func (r *Reconciler) SetupWithManager(controllerName string, mgr ctrl.Manager, log *slog.Logger) error { +func (r *Reconciler) SetupWithManager(controllerName string, mgr ctrl.Manager, log *log.Logger) error { return ctrl.NewControllerManagedBy(mgr). Named(controllerName). For(r.newObject(), builder.WithPredicates(predicate.Funcs{ diff --git a/images/virtualization-artifact/pkg/controller/service/ip_address_service.go b/images/virtualization-artifact/pkg/controller/service/ip_address_service.go index 49f7eadaf..b1cf7a3d5 100644 --- a/images/virtualization-artifact/pkg/controller/service/ip_address_service.go +++ b/images/virtualization-artifact/pkg/controller/service/ip_address_service.go @@ -19,12 +19,12 @@ package service import ( "errors" "fmt" - "log/slog" "net" "net/netip" k8snet "k8s.io/utils/net" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/common" ) @@ -33,7 +33,7 @@ type IpAddressService struct { } func NewIpAddressService( - logger *slog.Logger, + logger *log.Logger, virtualMachineCIDRs []string, ) *IpAddressService { parsedCIDRs := make([]netip.Prefix, len(virtualMachineCIDRs)) diff --git a/images/virtualization-artifact/pkg/controller/service/ip_address_service_test.go b/images/virtualization-artifact/pkg/controller/service/ip_address_service_test.go index d2e170102..a071ded14 100644 --- a/images/virtualization-artifact/pkg/controller/service/ip_address_service_test.go +++ b/images/virtualization-artifact/pkg/controller/service/ip_address_service_test.go @@ -17,12 +17,12 @@ limitations under the License. package service import ( - "log/slog" "net/netip" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/common" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) @@ -31,7 +31,7 @@ var _ = Describe("IpAddressService", func() { var ( ipService *IpAddressService allocatedIPs common.AllocatedIPs - logger *slog.Logger + logger *log.Logger ) BeforeEach(func() { diff --git a/images/virtualization-artifact/pkg/controller/service/stat_service.go b/images/virtualization-artifact/pkg/controller/service/stat_service.go index e116be689..437c0affc 100644 --- a/images/virtualization-artifact/pkg/controller/service/stat_service.go +++ b/images/virtualization-artifact/pkg/controller/service/stat_service.go @@ -19,7 +19,6 @@ package service import ( "errors" "fmt" - "log/slog" "strconv" "time" @@ -28,6 +27,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/common" cc "github.com/deckhouse/virtualization-controller/pkg/controller/common" "github.com/deckhouse/virtualization-controller/pkg/controller/monitoring" @@ -37,10 +37,10 @@ import ( ) type StatService struct { - logger *slog.Logger + logger *log.Logger } -func NewStatService(logger *slog.Logger) *StatService { +func NewStatService(logger *log.Logger) *StatService { return &StatService{ logger: logger.With("svc", "stat"), } diff --git a/images/virtualization-artifact/pkg/controller/vd/internal/watcher/vdsnapshot_watcher.go b/images/virtualization-artifact/pkg/controller/vd/internal/watcher/vdsnapshot_watcher.go index 3fda39e69..215704349 100644 --- a/images/virtualization-artifact/pkg/controller/vd/internal/watcher/vdsnapshot_watcher.go +++ b/images/virtualization-artifact/pkg/controller/vd/internal/watcher/vdsnapshot_watcher.go @@ -19,7 +19,6 @@ package watcher import ( "context" "fmt" - "log/slog" "strings" "k8s.io/apimachinery/pkg/fields" @@ -33,19 +32,20 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/indexer" "github.com/deckhouse/virtualization-controller/pkg/sdk/framework/helper" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) type VirtualDiskSnapshotWatcher struct { - logger *slog.Logger + logger *log.Logger client client.Client } func NewVirtualDiskSnapshotWatcher(client client.Client) *VirtualDiskSnapshotWatcher { return &VirtualDiskSnapshotWatcher{ - logger: slog.Default().With("watcher", strings.ToLower(virtv2.VirtualDiskSnapshotKind)), + logger: log.Default().With("watcher", strings.ToLower(virtv2.VirtualDiskSnapshotKind)), client: client, } } diff --git a/images/virtualization-artifact/pkg/controller/vd/vd_controller.go b/images/virtualization-artifact/pkg/controller/vd/vd_controller.go index 2d0ec7d15..7afcfa4e6 100644 --- a/images/virtualization-artifact/pkg/controller/vd/vd_controller.go +++ b/images/virtualization-artifact/pkg/controller/vd/vd_controller.go @@ -18,7 +18,6 @@ package vd import ( "context" - "log/slog" "time" corev1 "k8s.io/api/core/v1" @@ -28,6 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/metrics" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vd/internal" "github.com/deckhouse/virtualization-controller/pkg/controller/vd/internal/source" @@ -51,7 +51,7 @@ type Condition interface { func NewController( ctx context.Context, mgr manager.Manager, - lg *slog.Logger, + lg *log.Logger, importerImage string, uploaderImage string, requirements corev1.ResourceRequirements, diff --git a/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_controller.go b/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_controller.go index c0699958c..95c7c1f7e 100644 --- a/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_controller.go +++ b/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_controller.go @@ -18,7 +18,6 @@ package vdsnapshot import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vdsnapshot/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" @@ -38,7 +38,7 @@ const ControllerName = "vdsnapshot-controller" func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, virtClient kubeclient.Client, ) (controller.Controller, error) { log = log.With(logger.SlogController(ControllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_webhook.go b/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_webhook.go index a024dd672..276305096 100644 --- a/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vdsnapshot/vdsnapshot_webhook.go @@ -19,19 +19,19 @@ package vdsnapshot import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) type Validator struct { - logger *slog.Logger + logger *log.Logger } -func NewValidator(logger *slog.Logger) *Validator { +func NewValidator(logger *log.Logger) *Validator { return &Validator{ logger: logger.With("webhook", "validator"), } diff --git a/images/virtualization-artifact/pkg/controller/vi/vi_controller.go b/images/virtualization-artifact/pkg/controller/vi/vi_controller.go index 7f37697b4..ac2d64808 100644 --- a/images/virtualization-artifact/pkg/controller/vi/vi_controller.go +++ b/images/virtualization-artifact/pkg/controller/vi/vi_controller.go @@ -18,7 +18,6 @@ package vi import ( "context" - "log/slog" "time" corev1 "k8s.io/api/core/v1" @@ -27,6 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vi/internal" "github.com/deckhouse/virtualization-controller/pkg/controller/vi/internal/source" @@ -49,7 +49,7 @@ type Condition interface { func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, importerImage string, uploaderImage string, requirements corev1.ResourceRequirements, diff --git a/images/virtualization-artifact/pkg/controller/vi/vi_webhook.go b/images/virtualization-artifact/pkg/controller/vi/vi_webhook.go index a96e2baa8..993fad4b6 100644 --- a/images/virtualization-artifact/pkg/controller/vi/vi_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vi/vi_webhook.go @@ -19,22 +19,22 @@ package vi import ( "context" "fmt" - "log/slog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/vicondition" ) type Validator struct { - logger *slog.Logger + logger *log.Logger } -func NewValidator(logger *slog.Logger) *Validator { +func NewValidator(logger *log.Logger) *Validator { return &Validator{ logger: logger.With("webhook", "validator"), } diff --git a/images/virtualization-artifact/pkg/controller/vm/gc.go b/images/virtualization-artifact/pkg/controller/vm/gc.go index f108b5bf5..83c787295 100644 --- a/images/virtualization-artifact/pkg/controller/vm/gc.go +++ b/images/virtualization-artifact/pkg/controller/vm/gc.go @@ -17,13 +17,13 @@ limitations under the License. package vm import ( - "log/slog" "time" virtv1 "kubevirt.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/config" "github.com/deckhouse/virtualization-controller/pkg/controller/gc" ) @@ -32,7 +32,7 @@ const gcVMMigrationControllerName = "vmi-migration-gc-controller" func SetupGC( mgr manager.Manager, - log *slog.Logger, + log *log.Logger, gcSettings config.BaseGcSettings, ) error { ttl := 24 * time.Hour diff --git a/images/virtualization-artifact/pkg/controller/vm/internal/validators/block_device_limiter_validator.go b/images/virtualization-artifact/pkg/controller/vm/internal/validators/block_device_limiter_validator.go index 59e903841..9f17b5abe 100644 --- a/images/virtualization-artifact/pkg/controller/vm/internal/validators/block_device_limiter_validator.go +++ b/images/virtualization-artifact/pkg/controller/vm/internal/validators/block_device_limiter_validator.go @@ -19,10 +19,10 @@ package validators import ( "context" "fmt" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/common" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -30,10 +30,10 @@ import ( type BlockDeviceLimiterValidator struct { service *service.BlockDeviceService - log *slog.Logger + log *log.Logger } -func NewBlockDeviceLimiterValidator(service *service.BlockDeviceService, log *slog.Logger) *BlockDeviceLimiterValidator { +func NewBlockDeviceLimiterValidator(service *service.BlockDeviceService, log *log.Logger) *BlockDeviceLimiterValidator { return &BlockDeviceLimiterValidator{ service: service, log: log, diff --git a/images/virtualization-artifact/pkg/controller/vm/vm_controller.go b/images/virtualization-artifact/pkg/controller/vm/vm_controller.go index 1d34d2649..5e2b47200 100644 --- a/images/virtualization-artifact/pkg/controller/vm/vm_controller.go +++ b/images/virtualization-artifact/pkg/controller/vm/vm_controller.go @@ -18,7 +18,6 @@ package vm import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -27,6 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/metrics" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/ipam" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal" @@ -43,7 +43,7 @@ const ( func SetupController( ctx context.Context, mgr manager.Manager, - lg *slog.Logger, + lg *log.Logger, dvcrSettings *dvcr.Settings, ) error { log := lg.With(logger.SlogController(controllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vm/vm_webhook.go b/images/virtualization-artifact/pkg/controller/vm/vm_webhook.go index f3bff398b..5fc52ced2 100644 --- a/images/virtualization-artifact/pkg/controller/vm/vm_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vm/vm_webhook.go @@ -19,12 +19,12 @@ package vm import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal" "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/validators" @@ -38,10 +38,10 @@ type VirtualMachineValidator interface { type Validator struct { validators []VirtualMachineValidator - log *slog.Logger + log *log.Logger } -func NewValidator(ipam internal.IPAM, client client.Client, service *service.BlockDeviceService, log *slog.Logger) *Validator { +func NewValidator(ipam internal.IPAM, client client.Client, service *service.BlockDeviceService, log *log.Logger) *Validator { return &Validator{ validators: []VirtualMachineValidator{ validators.NewMetaValidator(client), diff --git a/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/attachment_conflict_validator.go b/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/attachment_conflict_validator.go index 3af10ebcf..f68f481d6 100644 --- a/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/attachment_conflict_validator.go +++ b/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/attachment_conflict_validator.go @@ -19,20 +19,20 @@ package validators import ( "context" "fmt" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) type AttachmentConflictValidator struct { - log *slog.Logger + log *log.Logger service *service.AttachmentService } -func NewAttachmentConflictValidator(service *service.AttachmentService, log *slog.Logger) *AttachmentConflictValidator { +func NewAttachmentConflictValidator(service *service.AttachmentService, log *log.Logger) *AttachmentConflictValidator { return &AttachmentConflictValidator{ log: log, service: service, diff --git a/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/vm_connect_limiter_validator.go b/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/vm_connect_limiter_validator.go index 48240ee63..9a9b1f879 100644 --- a/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/vm_connect_limiter_validator.go +++ b/images/virtualization-artifact/pkg/controller/vmbda/internal/validators/vm_connect_limiter_validator.go @@ -19,10 +19,10 @@ package validators import ( "context" "fmt" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/common" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -30,10 +30,10 @@ import ( type VMConnectLimiterValidator struct { service *service.BlockDeviceService - log *slog.Logger + log *log.Logger } -func NewVMConnectLimiterValidator(service *service.BlockDeviceService, log *slog.Logger) *VMConnectLimiterValidator { +func NewVMConnectLimiterValidator(service *service.BlockDeviceService, log *log.Logger) *VMConnectLimiterValidator { return &VMConnectLimiterValidator{ service: service, log: log, diff --git a/images/virtualization-artifact/pkg/controller/vmbda/vmbda_controller.go b/images/virtualization-artifact/pkg/controller/vmbda/vmbda_controller.go index 5682d91e9..1e468c6c0 100644 --- a/images/virtualization-artifact/pkg/controller/vmbda/vmbda_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmbda/vmbda_controller.go @@ -18,7 +18,6 @@ package vmbda import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -27,6 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/metrics" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vmbda/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" @@ -39,7 +39,7 @@ const ControllerName = "vmbda-controller" func NewController( ctx context.Context, mgr manager.Manager, - lg *slog.Logger, + lg *log.Logger, ns string, ) (controller.Controller, error) { log := lg.With(logger.SlogController(ControllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmbda/vmbda_webhook.go b/images/virtualization-artifact/pkg/controller/vmbda/vmbda_webhook.go index c861009bf..6f8432aa3 100644 --- a/images/virtualization-artifact/pkg/controller/vmbda/vmbda_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vmbda/vmbda_webhook.go @@ -19,11 +19,11 @@ package vmbda import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vmbda/internal/validators" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -36,10 +36,10 @@ type VirtualMachineBlockDeviceAttachmentValidator interface { type Validator struct { validators []VirtualMachineBlockDeviceAttachmentValidator - log *slog.Logger + log *log.Logger } -func NewValidator(attachmentService *service.AttachmentService, service *service.BlockDeviceService, log *slog.Logger) *Validator { +func NewValidator(attachmentService *service.AttachmentService, service *service.BlockDeviceService, log *log.Logger) *Validator { return &Validator{ log: log.With("webhook", "validation"), validators: []VirtualMachineBlockDeviceAttachmentValidator{ diff --git a/images/virtualization-artifact/pkg/controller/vmclass/internal/deletion.go b/images/virtualization-artifact/pkg/controller/vmclass/internal/deletion.go index 9a05051ca..77978202b 100644 --- a/images/virtualization-artifact/pkg/controller/vmclass/internal/deletion.go +++ b/images/virtualization-artifact/pkg/controller/vmclass/internal/deletion.go @@ -19,7 +19,6 @@ package internal import ( "context" "fmt" - "log/slog" "time" corev1 "k8s.io/api/core/v1" @@ -28,6 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/common" "github.com/deckhouse/virtualization-controller/pkg/controller/vmclass/internal/state" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -35,7 +35,7 @@ import ( const nameDeletionHandler = "DeletionHandler" -func NewDeletionHandler(client client.Client, recorder record.EventRecorder, logger *slog.Logger) *DeletionHandler { +func NewDeletionHandler(client client.Client, recorder record.EventRecorder, logger *log.Logger) *DeletionHandler { return &DeletionHandler{ client: client, recorder: recorder, @@ -46,7 +46,7 @@ func NewDeletionHandler(client client.Client, recorder record.EventRecorder, log type DeletionHandler struct { client client.Client recorder record.EventRecorder - logger *slog.Logger + logger *log.Logger } func (h *DeletionHandler) Handle(ctx context.Context, s state.VirtualMachineClassState) (reconcile.Result, error) { diff --git a/images/virtualization-artifact/pkg/controller/vmclass/vmclass_controller.go b/images/virtualization-artifact/pkg/controller/vmclass/vmclass_controller.go index d66083da1..2d62dd52a 100644 --- a/images/virtualization-artifact/pkg/controller/vmclass/vmclass_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmclass/vmclass_controller.go @@ -18,7 +18,6 @@ package vmclass import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/vmclass/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -39,7 +39,7 @@ func NewController( ctx context.Context, mgr manager.Manager, controllerNamespace string, - log *slog.Logger, + log *log.Logger, ) (controller.Controller, error) { log = log.With(logger.SlogController(controllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmclass/vmclass_webhook.go b/images/virtualization-artifact/pkg/controller/vmclass/vmclass_webhook.go index c28550dd7..f37a068a8 100644 --- a/images/virtualization-artifact/pkg/controller/vmclass/vmclass_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vmclass/vmclass_webhook.go @@ -16,12 +16,12 @@ package vmclass import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/vmclass/internal/validators" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) @@ -33,10 +33,10 @@ type VirtualMachineClassValidator interface { type Validator struct { validators []VirtualMachineClassValidator - log *slog.Logger + log *log.Logger } -func NewValidator(client client.Client, log *slog.Logger) *Validator { +func NewValidator(client client.Client, log *log.Logger) *Validator { return &Validator{ validators: []VirtualMachineClassValidator{ validators.NewSizingPoliciesValidator(client), diff --git a/images/virtualization-artifact/pkg/controller/vmip/vmip_controller.go b/images/virtualization-artifact/pkg/controller/vmip/vmip_controller.go index 869b6fc2c..6d73f5fa0 100644 --- a/images/virtualization-artifact/pkg/controller/vmip/vmip_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmip/vmip_controller.go @@ -18,7 +18,6 @@ package vmip import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vmip/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" @@ -39,7 +39,7 @@ const ( func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, virtualMachineCIDRs []string, ) (controller.Controller, error) { log = log.With(logger.SlogController(controllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmip/vmip_webhook.go b/images/virtualization-artifact/pkg/controller/vmip/vmip_webhook.go index 218ed2364..8dce9fc99 100644 --- a/images/virtualization-artifact/pkg/controller/vmip/vmip_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vmip/vmip_webhook.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "log/slog" "net" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,13 +27,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vmip/internal/util" "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/vmipcondition" ) -func NewValidator(log *slog.Logger, client client.Client, ipAddressService *service.IpAddressService) *Validator { +func NewValidator(log *log.Logger, client client.Client, ipAddressService *service.IpAddressService) *Validator { return &Validator{ log: log.With("webhook", "validation"), client: client, @@ -43,7 +43,7 @@ func NewValidator(log *slog.Logger, client client.Client, ipAddressService *serv } type Validator struct { - log *slog.Logger + log *log.Logger client client.Client ipService *service.IpAddressService } diff --git a/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_controller.go b/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_controller.go index 42597f340..56cd065ac 100644 --- a/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_controller.go @@ -18,7 +18,6 @@ package vmiplease import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/vmiplease/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -38,7 +38,7 @@ const ( func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, retentionDurationStr string, ) (controller.Controller, error) { log = log.With(logger.SlogController(controllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_webhook.go b/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_webhook.go index ab507f340..0a6223f99 100644 --- a/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vmiplease/vmiplease_webhook.go @@ -19,22 +19,22 @@ package vmiplease import ( "context" "fmt" - "log/slog" "net" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/common" "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func NewValidator(log *slog.Logger) *Validator { +func NewValidator(log *log.Logger) *Validator { return &Validator{log: log.With("webhook", "validation")} } type Validator struct { - log *slog.Logger + log *log.Logger } func (v *Validator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { diff --git a/images/virtualization-artifact/pkg/controller/vmop/gc.go b/images/virtualization-artifact/pkg/controller/vmop/gc.go index 1d394d719..97c41ed59 100644 --- a/images/virtualization-artifact/pkg/controller/vmop/gc.go +++ b/images/virtualization-artifact/pkg/controller/vmop/gc.go @@ -17,12 +17,12 @@ limitations under the License. package vmop import ( - "log/slog" "time" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/config" "github.com/deckhouse/virtualization-controller/pkg/controller/gc" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -32,7 +32,7 @@ const gcControllerName = "vmop-gc-controller" func SetupGC( mgr manager.Manager, - log *slog.Logger, + log *log.Logger, gcSettings config.BaseGcSettings, ) error { ttl := 24 * time.Hour diff --git a/images/virtualization-artifact/pkg/controller/vmop/vmop_controller.go b/images/virtualization-artifact/pkg/controller/vmop/vmop_controller.go index d14e5d647..21daa3517 100644 --- a/images/virtualization-artifact/pkg/controller/vmop/vmop_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmop/vmop_controller.go @@ -18,7 +18,6 @@ package vmop import ( "context" - "log/slog" "time" "k8s.io/client-go/util/workqueue" @@ -28,6 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/metrics" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/vmop/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" @@ -44,7 +44,7 @@ func SetupController( ctx context.Context, mgr manager.Manager, virtClient kubeclient.Client, - lg *slog.Logger, + lg *log.Logger, ) error { log := lg.With(logger.SlogController(controllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmop/vmop_webhook.go b/images/virtualization-artifact/pkg/controller/vmop/vmop_webhook.go index ff0a21d3c..e83d34ff9 100644 --- a/images/virtualization-artifact/pkg/controller/vmop/vmop_webhook.go +++ b/images/virtualization-artifact/pkg/controller/vmop/vmop_webhook.go @@ -19,22 +19,22 @@ package vmop import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func NewValidator(log *slog.Logger) *Validator { +func NewValidator(log *log.Logger) *Validator { return &Validator{ log: log.With("controller", controllerName).With("webhook", "validation"), } } type Validator struct { - log *slog.Logger + log *log.Logger } func (v *Validator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { diff --git a/images/virtualization-artifact/pkg/controller/vmrestore/vmrestore_controller.go b/images/virtualization-artifact/pkg/controller/vmrestore/vmrestore_controller.go index 2f337f652..855ffc214 100644 --- a/images/virtualization-artifact/pkg/controller/vmrestore/vmrestore_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmrestore/vmrestore_controller.go @@ -18,7 +18,6 @@ package vmrestore import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service/restorer" "github.com/deckhouse/virtualization-controller/pkg/controller/vmrestore/internal" "github.com/deckhouse/virtualization-controller/pkg/logger" @@ -37,7 +37,7 @@ const ControllerName = "vmrestore-controller" func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, ) error { log = log.With(logger.SlogController(ControllerName)) diff --git a/images/virtualization-artifact/pkg/controller/vmsnapshot/vmsnapshot_controller.go b/images/virtualization-artifact/pkg/controller/vmsnapshot/vmsnapshot_controller.go index 09d2fca64..f9f20ab35 100644 --- a/images/virtualization-artifact/pkg/controller/vmsnapshot/vmsnapshot_controller.go +++ b/images/virtualization-artifact/pkg/controller/vmsnapshot/vmsnapshot_controller.go @@ -18,7 +18,6 @@ package vmsnapshot import ( "context" - "log/slog" "time" "k8s.io/utils/ptr" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" "github.com/deckhouse/virtualization-controller/pkg/controller/service/restorer" "github.com/deckhouse/virtualization-controller/pkg/controller/vmsnapshot/internal" @@ -39,7 +39,7 @@ const ControllerName = "vmsnapshot-controller" func NewController( ctx context.Context, mgr manager.Manager, - log *slog.Logger, + log *log.Logger, virtClient kubeclient.Client, ) error { log = log.With(logger.SlogController(ControllerName)) diff --git a/images/virtualization-artifact/pkg/controller/watchers/cvi_enqueuer.go b/images/virtualization-artifact/pkg/controller/watchers/cvi_enqueuer.go index f38ce9df1..e8824b5ba 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/cvi_enqueuer.go +++ b/images/virtualization-artifact/pkg/controller/watchers/cvi_enqueuer.go @@ -19,13 +19,13 @@ package watchers import ( "context" "fmt" - "log/slog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/conditions" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/cvicondition" @@ -35,7 +35,7 @@ type ClusterVirtualImageRequestEnqueuer struct { enqueueFromObj client.Object enqueueFromKind virtv2.ClusterVirtualImageObjectRefKind client client.Client - logger *slog.Logger + logger *log.Logger } func NewClusterVirtualImageRequestEnqueuer(client client.Client, enqueueFromObj client.Object, enqueueFromKind virtv2.ClusterVirtualImageObjectRefKind) *ClusterVirtualImageRequestEnqueuer { @@ -43,7 +43,7 @@ func NewClusterVirtualImageRequestEnqueuer(client client.Client, enqueueFromObj enqueueFromObj: enqueueFromObj, enqueueFromKind: enqueueFromKind, client: client, - logger: slog.Default().With("enqueuer", "cvi"), + logger: log.Default().With("enqueuer", "cvi"), } } diff --git a/images/virtualization-artifact/pkg/controller/watchers/cvi_filter.go b/images/virtualization-artifact/pkg/controller/watchers/cvi_filter.go index 450447d35..4b3f46125 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/cvi_filter.go +++ b/images/virtualization-artifact/pkg/controller/watchers/cvi_filter.go @@ -18,20 +18,20 @@ package watchers import ( "fmt" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/event" + "github.com/deckhouse/deckhouse/pkg/log" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) type ClusterVirtualImageFilter struct { - logger *slog.Logger + logger *log.Logger } func NewClusterVirtualImageFilter() *ClusterVirtualImageFilter { return &ClusterVirtualImageFilter{ - logger: slog.Default().With("filter", "cvi"), + logger: log.Default().With("filter", "cvi"), } } diff --git a/images/virtualization-artifact/pkg/controller/watchers/object_ref_watcher.go b/images/virtualization-artifact/pkg/controller/watchers/object_ref_watcher.go index 2f6fa9d54..350ac8864 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/object_ref_watcher.go +++ b/images/virtualization-artifact/pkg/controller/watchers/object_ref_watcher.go @@ -18,7 +18,6 @@ package watchers import ( "context" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -28,12 +27,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "github.com/deckhouse/deckhouse/pkg/log" ) type ObjectRefWatcher struct { filter UpdateEventsFilter enqueuer RequestEnqueuer - logger *slog.Logger + logger *log.Logger } type RequestEnqueuer interface { @@ -52,7 +53,7 @@ func NewObjectRefWatcher( return &ObjectRefWatcher{ filter: filter, enqueuer: enqueuer, - logger: slog.Default().With("watcher", "cvi"), + logger: log.Default().With("watcher", "cvi"), } } diff --git a/images/virtualization-artifact/pkg/controller/watchers/vd_enqueuer.go b/images/virtualization-artifact/pkg/controller/watchers/vd_enqueuer.go index 95bf14482..5e16c5bc6 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/vd_enqueuer.go +++ b/images/virtualization-artifact/pkg/controller/watchers/vd_enqueuer.go @@ -19,13 +19,13 @@ package watchers import ( "context" "fmt" - "log/slog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/vdcondition" @@ -35,7 +35,7 @@ type VirtualDiskRequestEnqueuer struct { enqueueFromObj client.Object enqueueFromKind virtv2.VirtualDiskObjectRefKind client client.Client - logger *slog.Logger + logger *log.Logger } func NewVirtualDiskRequestEnqueuer(client client.Client, enqueueFromObj client.Object, enqueueFromKind virtv2.VirtualDiskObjectRefKind) *VirtualDiskRequestEnqueuer { @@ -43,7 +43,7 @@ func NewVirtualDiskRequestEnqueuer(client client.Client, enqueueFromObj client.O enqueueFromObj: enqueueFromObj, enqueueFromKind: enqueueFromKind, client: client, - logger: slog.Default().With("enqueuer", "vd"), + logger: log.Default().With("enqueuer", "vd"), } } diff --git a/images/virtualization-artifact/pkg/controller/watchers/vi_enqueuer.go b/images/virtualization-artifact/pkg/controller/watchers/vi_enqueuer.go index 0046ae6ca..86257b35a 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/vi_enqueuer.go +++ b/images/virtualization-artifact/pkg/controller/watchers/vi_enqueuer.go @@ -19,13 +19,13 @@ package watchers import ( "context" "fmt" - "log/slog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/controller/service" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/api/core/v1alpha2/vicondition" @@ -35,7 +35,7 @@ type VirtualImageRequestEnqueuer struct { enqueueFromObj client.Object enqueueFromKind virtv2.VirtualImageObjectRefKind client client.Client - logger *slog.Logger + logger *log.Logger } func NewVirtualImageRequestEnqueuer(client client.Client, enqueueFromObj client.Object, enqueueFromKind virtv2.VirtualImageObjectRefKind) *VirtualImageRequestEnqueuer { @@ -43,7 +43,7 @@ func NewVirtualImageRequestEnqueuer(client client.Client, enqueueFromObj client. enqueueFromObj: enqueueFromObj, enqueueFromKind: enqueueFromKind, client: client, - logger: slog.Default().With("enqueuer", "vi"), + logger: log.Default().With("enqueuer", "vi"), } } diff --git a/images/virtualization-artifact/pkg/controller/watchers/vi_filter.go b/images/virtualization-artifact/pkg/controller/watchers/vi_filter.go index 0284326f1..04895fcd8 100644 --- a/images/virtualization-artifact/pkg/controller/watchers/vi_filter.go +++ b/images/virtualization-artifact/pkg/controller/watchers/vi_filter.go @@ -18,20 +18,20 @@ package watchers import ( "fmt" - "log/slog" "sigs.k8s.io/controller-runtime/pkg/event" + "github.com/deckhouse/deckhouse/pkg/log" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) type VirtualImageFilter struct { - logger *slog.Logger + logger *log.Logger } func NewVirtualImageFilter() *VirtualImageFilter { return &VirtualImageFilter{ - logger: slog.Default().With("filter", "vi"), + logger: log.Default().With("filter", "vi"), } } diff --git a/images/virtualization-artifact/pkg/logger/constructor.go b/images/virtualization-artifact/pkg/logger/constructor.go index 9f168b435..2d6ad05d8 100644 --- a/images/virtualization-artifact/pkg/logger/constructor.go +++ b/images/virtualization-artifact/pkg/logger/constructor.go @@ -17,13 +17,13 @@ limitations under the License. package logger import ( - "log/slog" - "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "github.com/deckhouse/deckhouse/pkg/log" ) -func NewConstructor(log *slog.Logger) func(req *reconcile.Request) logr.Logger { +func NewConstructor(log *log.Logger) func(req *reconcile.Request) logr.Logger { return func(req *reconcile.Request) logr.Logger { log := log if req != nil { diff --git a/images/virtualization-artifact/pkg/logger/logger.go b/images/virtualization-artifact/pkg/logger/logger.go index f1a0bcbff..efe531825 100644 --- a/images/virtualization-artifact/pkg/logger/logger.go +++ b/images/virtualization-artifact/pkg/logger/logger.go @@ -25,24 +25,8 @@ import ( "github.com/go-logr/logr" "k8s.io/klog/v2" logf "sigs.k8s.io/controller-runtime/pkg/log" -) - -func New(opts Options) *slog.Logger { - return slog.New(NewHandler(opts)) -} - -func SetDefaultLogger(l *slog.Logger) { - slog.SetDefault(l) - fromSlog := logr.FromSlogHandler(l.Handler()) - logf.SetLogger(fromSlog) - klog.SetLogger(fromSlog) -} - -type Format string -const ( - TextLog Format = "text" - JSONLog Format = "json" + "github.com/deckhouse/deckhouse/pkg/log" ) type Output string @@ -53,67 +37,32 @@ const ( Discard Output = "discard" ) -const ( - DefaultLogLevel = slog.LevelInfo - DefaultLogFormat = JSONLog -) +const DefaultLogLevel = log.LevelInfo var DefaultLogOutput = os.Stdout -type Options struct { - Level string - DebugVerbosity int - Format string - Output string -} - -func NewHandler(opts Options) slog.Handler { - logLevel := detectLogLevel(opts.Level, opts.DebugVerbosity) - logFormat := detectLogFormat(opts.Format) - logOutput := detectLogOutput(opts.Output) - - logHandlerOpts := &slog.HandlerOptions{Level: logLevel} - switch logFormat { - case TextLog: - return slog.NewTextHandler(logOutput, logHandlerOpts) - case JSONLog: - return slog.NewJSONHandler(logOutput, logHandlerOpts) - default: - return slog.NewTextHandler(logOutput, logHandlerOpts) - } -} - -func detectLogLevel(level string, debugVerbosity int) slog.Level { +func DetectLogLevel(level string, debugVerbosity int) slog.Level { switch strings.ToLower(level) { case "error": - return slog.LevelError + return log.LevelError.Level() case "warn": - return slog.LevelWarn + return log.LevelWarn.Level() case "info": - return slog.LevelInfo + return log.LevelInfo.Level() + case "trace": + return log.LevelTrace.Level() case "debug": if debugVerbosity != 0 { return slog.Level(-1 * debugVerbosity) } - return slog.LevelDebug - default: - return DefaultLogLevel - } -} - -func detectLogFormat(format string) Format { - switch strings.ToLower(format) { - case string(TextLog): - return TextLog - case string(JSONLog): - return JSONLog + return log.LevelDebug.Level() default: - return DefaultLogFormat + return DefaultLogLevel.Level() } } -func detectLogOutput(output string) io.Writer { +func DetectLogOutput(output string) io.Writer { switch strings.ToLower(output) { case string(Stdout): return os.Stdout @@ -125,3 +74,10 @@ func detectLogOutput(output string) io.Writer { return DefaultLogOutput } } + +func SetDefaultLogger(l *log.Logger) { + log.SetDefault(l) + fromSlog := logr.FromSlogHandler(l.Handler()) + logf.SetLogger(fromSlog) + klog.SetLogger(fromSlog) +} diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vd/collector.go b/images/virtualization-artifact/pkg/monitoring/metrics/vd/collector.go index 0119d674f..21c52602e 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vd/collector.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vd/collector.go @@ -18,12 +18,12 @@ package vd import ( "context" - "log/slog" "time" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) @@ -31,7 +31,7 @@ const collectorName = "virtualdisk-collector" func SetupCollector(reader client.Reader, registerer prometheus.Registerer, - log *slog.Logger, + log *log.Logger, ) *Collector { c := &Collector{ iterator: newUnsafeIterator(reader), @@ -49,7 +49,7 @@ type Iterator interface { type Collector struct { iterator Iterator - log *slog.Logger + log *log.Logger } func (c Collector) Describe(ch chan<- *prometheus.Desc) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vd/scraper.go b/images/virtualization-artifact/pkg/monitoring/metrics/vd/scraper.go index b08a7184b..e88b38006 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vd/scraper.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vd/scraper.go @@ -18,22 +18,22 @@ package vd import ( "fmt" - "log/slog" "github.com/prometheus/client_golang/prometheus" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/monitoring/metrics/promutil" "github.com/deckhouse/virtualization-controller/pkg/util" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func newScraper(ch chan<- prometheus.Metric, log *slog.Logger) *scraper { +func newScraper(ch chan<- prometheus.Metric, log *log.Logger) *scraper { return &scraper{ch: ch, log: log} } type scraper struct { ch chan<- prometheus.Metric - log *slog.Logger + log *log.Logger } func (s *scraper) Report(m *dataMetric) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/collector.go b/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/collector.go index 63ae8e97e..e382ac187 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/collector.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/collector.go @@ -18,12 +18,12 @@ package virtualmachine import ( "context" - "log/slog" "time" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) @@ -31,7 +31,7 @@ const collectorName = "virtualmachine-collector" func SetupCollector(reader client.Reader, registerer prometheus.Registerer, - log *slog.Logger, + log *log.Logger, ) { c := NewCollector(reader, log) c.Register(registerer) @@ -43,7 +43,7 @@ type Iterator interface { Iter(ctx context.Context, h handler) error } -func NewCollector(reader client.Reader, log *slog.Logger) *Collector { +func NewCollector(reader client.Reader, log *log.Logger) *Collector { return &Collector{ iterator: newUnsafeIterator(reader), log: log.With(logger.SlogCollector(collectorName)), @@ -52,7 +52,7 @@ func NewCollector(reader client.Reader, log *slog.Logger) *Collector { type Collector struct { iterator Iterator - log *slog.Logger + log *log.Logger } func (c Collector) Register(reg prometheus.Registerer) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/scraper.go b/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/scraper.go index 3c45c4f0e..4f17611c1 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/scraper.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/virtualmachine/scraper.go @@ -18,22 +18,22 @@ package virtualmachine import ( "fmt" - "log/slog" "github.com/prometheus/client_golang/prometheus" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/monitoring/metrics/promutil" "github.com/deckhouse/virtualization-controller/pkg/util" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func newScraper(ch chan<- prometheus.Metric, log *slog.Logger) *scraper { +func newScraper(ch chan<- prometheus.Metric, log *log.Logger) *scraper { return &scraper{ch: ch, log: log} } type scraper struct { ch chan<- prometheus.Metric - log *slog.Logger + log *log.Logger } func (s *scraper) Report(m *dataMetric) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/collector.go b/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/collector.go index f921c7ccc..7dc1c6360 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/collector.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/collector.go @@ -18,12 +18,12 @@ package vmbda import ( "context" - "log/slog" "time" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) @@ -31,7 +31,7 @@ const collectorName = "vmbda-collector" func SetupCollector(reader client.Reader, registerer prometheus.Registerer, - log *slog.Logger, + log *log.Logger, ) *Collector { c := &Collector{ iterator: newUnsafeIterator(reader), @@ -50,7 +50,7 @@ type Iterator interface { type Collector struct { iterator Iterator - log *slog.Logger + log *log.Logger } func (c Collector) Describe(ch chan<- *prometheus.Desc) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/scraper.go b/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/scraper.go index ee63a0652..f5a9eb2c4 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/scraper.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vmbda/scraper.go @@ -18,22 +18,22 @@ package vmbda import ( "fmt" - "log/slog" "github.com/prometheus/client_golang/prometheus" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/monitoring/metrics/promutil" "github.com/deckhouse/virtualization-controller/pkg/util" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func newScraper(ch chan<- prometheus.Metric, log *slog.Logger) *scraper { +func newScraper(ch chan<- prometheus.Metric, log *log.Logger) *scraper { return &scraper{ch: ch, log: log} } type scraper struct { ch chan<- prometheus.Metric - log *slog.Logger + log *log.Logger } func (s *scraper) Report(m *dataMetric) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vmop/collector.go b/images/virtualization-artifact/pkg/monitoring/metrics/vmop/collector.go index 7d260e17b..261b4a28f 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vmop/collector.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vmop/collector.go @@ -18,12 +18,12 @@ package vmop import ( "context" - "log/slog" "time" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/logger" ) @@ -31,7 +31,7 @@ const collectorName = "vmop-collector" func SetupCollector(reader client.Reader, registerer prometheus.Registerer, - log *slog.Logger, + log *log.Logger, ) *Collector { c := &Collector{ iterator: newUnsafeIterator(reader), @@ -49,7 +49,7 @@ type Iterator interface { type Collector struct { iterator Iterator - log *slog.Logger + log *log.Logger } func (c Collector) Describe(ch chan<- *prometheus.Desc) { diff --git a/images/virtualization-artifact/pkg/monitoring/metrics/vmop/scraper.go b/images/virtualization-artifact/pkg/monitoring/metrics/vmop/scraper.go index e3fe1763e..16c63de0e 100644 --- a/images/virtualization-artifact/pkg/monitoring/metrics/vmop/scraper.go +++ b/images/virtualization-artifact/pkg/monitoring/metrics/vmop/scraper.go @@ -18,21 +18,21 @@ package vmop import ( "fmt" - "log/slog" "github.com/prometheus/client_golang/prometheus" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/deckhouse/virtualization-controller/pkg/util" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" ) -func newScraper(ch chan<- prometheus.Metric, log *slog.Logger) *scraper { +func newScraper(ch chan<- prometheus.Metric, log *log.Logger) *scraper { return &scraper{ch: ch, log: log} } type scraper struct { ch chan<- prometheus.Metric - log *slog.Logger + log *log.Logger } func (s *scraper) Report(m *dataMetric) { diff --git a/images/virtualization-artifact/pkg/sdk/framework/helper/resource.go b/images/virtualization-artifact/pkg/sdk/framework/helper/resource.go index c2e8a1d88..29be13443 100644 --- a/images/virtualization-artifact/pkg/sdk/framework/helper/resource.go +++ b/images/virtualization-artifact/pkg/sdk/framework/helper/resource.go @@ -19,13 +19,14 @@ package helper import ( "context" "fmt" - "log/slog" "reflect" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/deckhouse/deckhouse/pkg/log" ) type Object[T, ST any] interface { @@ -47,12 +48,12 @@ type Resource[T Object[T, ST], ST any] struct { objFactory ObjectFactory[T] objStatusGetter ObjectStatusGetter[T, ST] - log *slog.Logger + log *log.Logger client client.Client cache cache.Cache } -func NewResource[T Object[T, ST], ST any](name types.NamespacedName, logger *slog.Logger, client client.Client, cache cache.Cache, objFactory ObjectFactory[T], objStatusGetter ObjectStatusGetter[T, ST]) *Resource[T, ST] { +func NewResource[T Object[T, ST], ST any](name types.NamespacedName, logger *log.Logger, client client.Client, cache cache.Cache, objFactory ObjectFactory[T], objStatusGetter ObjectStatusGetter[T, ST]) *Resource[T, ST] { return &Resource[T, ST]{ name: name, log: logger, diff --git a/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_core.go b/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_core.go index d46cbb7d0..a5a9398d7 100644 --- a/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_core.go +++ b/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_core.go @@ -19,13 +19,14 @@ package two_phase_reconciler import ( "context" "fmt" - "log/slog" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "github.com/deckhouse/deckhouse/pkg/log" ) type ReconcilerOptions struct { @@ -33,7 +34,7 @@ type ReconcilerOptions struct { Cache cache.Cache Recorder record.EventRecorder Scheme *runtime.Scheme - Log *slog.Logger + Log *log.Logger } type ReconcilerCore[T ReconcilerState] struct { diff --git a/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_state.go b/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_state.go index c2ae9c23c..9bd772deb 100644 --- a/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_state.go +++ b/images/virtualization-artifact/pkg/sdk/framework/two_phase_reconciler/reconciler_state.go @@ -18,15 +18,16 @@ package two_phase_reconciler import ( "context" - "log/slog" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "github.com/deckhouse/deckhouse/pkg/log" ) -type ReconcilerStateFactory[T ReconcilerState] func(name types.NamespacedName, logger *slog.Logger, client client.Client, cache cache.Cache) T +type ReconcilerStateFactory[T ReconcilerState] func(name types.NamespacedName, logger *log.Logger, client client.Client, cache cache.Cache) T type ReconcilerState interface { ReconcilerStateApplier @@ -34,11 +35,11 @@ type ReconcilerState interface { SetReconcilerResult(result *reconcile.Result) GetReconcilerResult() *reconcile.Result - Reload(ctx context.Context, req reconcile.Request, logger *slog.Logger, client client.Client) error - ShouldReconcile(log *slog.Logger) bool + Reload(ctx context.Context, req reconcile.Request, logger *log.Logger, client client.Client) error + ShouldReconcile(log *log.Logger) bool } type ReconcilerStateApplier interface { - ApplySync(ctx context.Context, log *slog.Logger) error - ApplyUpdateStatus(ctx context.Context, log *slog.Logger) error + ApplySync(ctx context.Context, log *log.Logger) error + ApplyUpdateStatus(ctx context.Context, log *log.Logger) error }