Skip to content

Potential unused condition check in internal/xds/server/runner/runner.go #1228

@muyuan0

Description

@muyuan0

Description:

Describe the issue.

There is a nil check in the

if r.cache == nil {
r.Logger.Error(err, "failed to init snapshot cache")
} else {

However, r.cache is initialized in

r.cache = cache.NewSnapshotCache(false, r.Logger)
and NewSnapshotCache never returns a nil from it:
func NewSnapshotCache(ads bool, logger logr.Logger) SnapshotCacheWithCallbacks {
// Set up the nasty wrapper hack.
wrappedLogger := NewLogrWrapper(logger)
return &snapshotCache{
SnapshotCache: cachev3.NewSnapshotCache(ads, &Hash, wrappedLogger),
log: wrappedLogger,
lastSnapshot: make(snapshotMap),
streamIDNodeInfo: make(nodeInfoMap),
}
}

IMHO, the logger message is suspicious because the code around doesn't init snapshot cache. It could be a remnant of a previous refactor.

[optional Relevant Links:]

Any extra documentation required to understand the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions