Skip to content

KObjSlice: nil entry printed as "" #409

@pohly

Description

@pohly

/kind bug

What steps did you take and what happened:

I added a test in https://github.com/kubernetes/kubernetes/pull/125699/files

logger.Info("Some NodeInfo slice", "nodes", klog.KObjSlice([]*NodeInfo{nil, {}, {node: &v1.Node{}}, {node: &v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "worker"}}}}))

*NodeInfo implements klog.KMetadata. The first slice entry is passed to klog.KObj which detects the nil value and turns it into an empty ObjectRef{}. That then gets printed as "" in the array.

What did you expect to happen:

Some kind of indicator that the first entry is nil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions