Skip to content

Unexpected log output from the init function when importing Karmada types #6957

@williamburgson

Description

@williamburgson

What happened:

Importing the karmada api types from pkg/apis/operator/v1alpha1 results in unwanted log line.

e.g.

I1125 19:35:50.978387      15 defaults.go:54] default Karmada Image Version: v0.0.0-master

What you expected to happen:

Kardama should either omit logs in the init function or log at debug level.

If the log lines are necessary then they should allow the logger to be configurable.

How to reproduce it (as minimally and precisely as possible):

simply import the types and unwanted logs will be printed

package main

import (
        "log/slog"

        "github.com/karmada-io/karmada/operator/pkg/apis/operator/v1alpha1"
)

var k = v1alpha1.Karmada{}

func main() {
        slog.Info("Expected output from slog")
}

Will output

$ go run main.go
I1129 17:47:21.437296  225428 defaults.go:54] default Karmada Image Version: v0.0.0-master
2025/11/29 17:47:21 INFO Expected output from slog

Configuring klog to use slog handler in this main.go example does not resolve the issue because the logging is done inside the init function of the package we are importing.

Anything else we need to know?:

Nope.

Environment:

  • Karmada version: v1.14.0-alpha.1
  • kubectl-karmada or karmadactl version (the result of kubectl-karmada version or karmadactl version): N/A
  • Others: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions