Skip to content

Cluster autoscaler argument --log-file is no longer working after v1.30.x #7842

@linhua11

Description

@linhua11

Which component are you using?: Cluster auto-scaler

What version of the component are you using?: v1.31.1, v.1.30.2

What did you expect to happen?:
When in v1.29.4, we use log-file=/xxx to redirect log to redirect all the logs to a separate file for tracking

What happened instead?:
After upgrading to v1.30.x, the log file no longer exist, not even created

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

  • --logtostderr=false
  • --alsologtostderr=false
  • --stderrthreshold=INFO
  • --v=4
  • --log_file=/xxxx/cluster-autoscaler.log

Anything else we need to know?:
I have done some research on the issue, it should be related to this change: kubernetes/component-base@4bf35a2

So in klog.go, if the logger is not nil, it won't proceed to the log file creation part. However, in the above commit, it sets the logger factory and bypass klog. So no log file will be created.

For reference: in https://github.com/kubernetes/klog/blob/e7125f792ea66a85818cfb45261c9e1acc585344/klog.go#L861
if logger != nil {
if logger.writeKlogBuffer != nil {
logger.writeKlogBuffer(data)
} else {
.....
}
} else if l.toStderr {
os.Stderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
os.Stderr.Write(data)
}
if logging.logFile != "" {
// Since we are using a single log file, all of the items in l.file array
// will point to the same file, so just use one of them to write data.
if l.file[severity.InfoLog] == nil {
if err := l.createFiles(severity.InfoLog); err != nil {
os.Stderr.Write(data) // Make sure the message appears somewhere.
l.exit(err)
}
}
}

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