Merge pull request #97715 from changshuchao/files_tmptag

Made some optimizations, including modifying variable names, omitting…
This commit is contained in:
Kubernetes Prow Robot 2021-01-21 22:55:26 -08:00 committed by GitHub
commit cea1098997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@ import (
const (
defaultPerm = 0755
tmptag = "tmp_" // additional prefix to prevent accidental collisions
tmpTag = "tmp_" // additional prefix to prevent accidental collisions
)
// FileExists returns true if a regular file exists at `path`, false if `path` does not exist, otherwise an error
@ -70,7 +70,7 @@ func EnsureFile(fs utilfs.Filesystem, path string) error {
// Expects the parent directory to exist.
func WriteTmpFile(fs utilfs.Filesystem, path string, data []byte) (tmpPath string, retErr error) {
dir := filepath.Dir(path)
prefix := tmptag + filepath.Base(path)
prefix := tmpTag + filepath.Base(path)
// create the tmp file
tmpFile, err := fs.TempFile(dir, prefix)
@ -174,7 +174,7 @@ func WriteTempDir(fs utilfs.Filesystem, path string, files map[string]string) (t
// write the temp directory in parent dir and return path to the tmp directory
dir := filepath.Dir(path)
prefix := tmptag + filepath.Base(path)
prefix := tmpTag + filepath.Base(path)
// create the tmp dir
var err error

View File

@ -884,8 +884,8 @@ func (m *kubeGenericRuntimeManager) doBackOff(pod *v1.Pod, container *v1.Contain
// backOff requires a unique key to identify the container.
key := getStableKey(pod, container)
if backOff.IsInBackOffSince(key, ts) {
if ref, err := kubecontainer.GenerateContainerRef(pod, container); err == nil {
m.recorder.Eventf(ref, v1.EventTypeWarning, events.BackOffStartContainer, "Back-off restarting failed container")
if containerRef, err := kubecontainer.GenerateContainerRef(pod, container); err == nil {
m.recorder.Eventf(containerRef, v1.EventTypeWarning, events.BackOffStartContainer, "Back-off restarting failed container")
}
err := fmt.Errorf("back-off %s restarting failed container=%s pod=%s", backOff.Get(key), container.Name, format.Pod(pod))
klog.V(3).Infof("%s", err.Error())

View File

@ -155,7 +155,7 @@ func parseCRILog(log []byte, msg *logMessage) error {
}
// Keep this forward compatible.
tags := bytes.Split(log[:idx], tagDelimiter)
partial := (runtimeapi.LogTag(tags[0]) == runtimeapi.LogTagPartial)
partial := runtimeapi.LogTag(tags[0]) == runtimeapi.LogTagPartial
// Trim the tailing new line if this is a partial line.
if partial && len(log) > 0 && log[len(log)-1] == '\n' {
log = log[:len(log)-1]