Use non-default directory for pod logs and limit path to ASCII characters

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2023-02-20 11:59:43 -08:00
parent 19d9405a1c
commit ff4f2907c5
6 changed files with 25 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"path/filepath"
"time"
"unicode"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -300,5 +301,13 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration, featur
allErrors = append(allErrors, fmt.Errorf("invalid configuration: pod logs path %q must be normalized", kc.PodLogsDir))
}
// Since pod logs path is used in metrics, make sure it contains only ASCII characters.
for _, c := range kc.PodLogsDir {
if c > unicode.MaxASCII {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: pod logs path %q mut contains ASCII characters only", kc.PodLogsDir))
break
}
}
return utilerrors.NewAggregate(allErrors)
}