Skip to content

Commit

Permalink
Merge pull request kubernetes#129072 from kannon92/add-validation-con…
Browse files Browse the repository at this point in the history
…tainer-log-max

add kubelet validation for containerLogMaxFiles
  • Loading branch information
k8s-ci-robot authored Dec 12, 2024
2 parents 4c2acdd + a0b7401 commit c3d0002
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kubelet/apis/config/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration, featur
allErrors = append(allErrors, fmt.Errorf("invalid configuration: containerLogMonitorInterval must be a positive time duration greater than or equal to 3s"))
}

if kc.ContainerLogMaxFiles <= 1 {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: containerLogMaxFiles must be greater than 1"))
}

if kc.PodLogsDir == "" {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: podLogsDir was not specified"))
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/kubelet/apis/config/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var (
},
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ContainerLogMaxWorkers: 1,
ContainerLogMaxFiles: 5,
ContainerLogMonitorInterval: metav1.Duration{Duration: 10 * time.Second},
SingleProcessOOMKill: ptr.To(!kubeletutil.IsCgroup2UnifiedMode()),
CrashLoopBackOff: kubeletconfig.CrashLoopBackOffConfig{
Expand Down Expand Up @@ -700,6 +701,13 @@ func TestValidateKubeletConfiguration(t *testing.T) {
return config
},
errMsg: `invalid configuration: pod logs path "/🧪" mut contains ASCII characters only`,
}, {
name: "invalid containerLogMaxFiles",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
conf.ContainerLogMaxFiles = 1
return conf
},
errMsg: "invalid configuration: containerLogMaxFiles must be greater than 1",
}, {
name: "invalid ContainerRuntimeEndpoint",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
Expand Down

0 comments on commit c3d0002

Please sign in to comment.