Skip to content

Commit

Permalink
UPSTREAM: <carry>: add max_housekeeping_interval
Browse files Browse the repository at this point in the history
OpenShift-Rebase-Source: 3b2555a
  • Loading branch information
rphillips authored and sanchezl committed Dec 20, 2022
1 parent f0b7524 commit 53d0b69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/kubelet/app/options/globalflags_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func addCadvisorFlags(fs *pflag.FlagSet) {

// e2e node tests rely on this
register(global, local, "housekeeping_interval")
register(global, local, "max_housekeeping_interval")

// These flags were implicit from cadvisor, and are mistakes that should be registered deprecated:
const deprecated = "This is a cadvisor flag that was mistakenly registered with the Kubelet. Due to legacy concerns, it will follow the standard CLI deprecation timeline before being removed."
Expand Down
7 changes: 7 additions & 0 deletions pkg/kubelet/cadvisor/cadvisor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ const defaultHousekeepingInterval = 10 * time.Second
const allowDynamicHousekeeping = true

func init() {
maxHouseKeeping := maxHousekeepingInterval.String()
if value := os.Getenv("OPENSHIFT_MAX_HOUSEKEEPING_INTERVAL_DURATION"); value != "" {
klog.Infof("Detected OPENSHIFT_MAX_HOUSEKEEPING_INTERVAL_DURATION: %v", value)
maxHouseKeeping = value
}
// Override cAdvisor flag defaults.
flagOverrides := map[string]string{
// Override the default cAdvisor housekeeping interval.
"housekeeping_interval": defaultHousekeepingInterval.String(),
// Override the default max cAdvisor housekeeping interval.
"max_housekeeping_interval": maxHouseKeeping,
// Disable event storage by default.
"event_storage_event_limit": "default=0",
"event_storage_age_limit": "default=0",
Expand Down
16 changes: 12 additions & 4 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ const (
// housekeeping is running no new pods are started or deleted).
housekeepingWarningDuration = time.Second * 15

// Period for performing eviction monitoring.
// ensure this is kept in sync with internal cadvisor housekeeping.
evictionMonitoringPeriod = time.Second * 10

// The path in containers' filesystems where the hosts file is mounted.
linuxEtcHostsPath = "/etc/hosts"
windowsEtcHostsPath = "C:\\Windows\\System32\\drivers\\etc\\hosts"
Expand Down Expand Up @@ -196,8 +192,20 @@ var (
// ContainerLogsDir can be overwrited for testing usage
ContainerLogsDir = DefaultContainerLogsDir
etcHostsPath = getContainerEtcHostsPath()
// Period for performing eviction monitoring.
// ensure this is kept in sync with internal cadvisor housekeeping.
evictionMonitoringPeriod = time.Second * 10
)

func init() {
if value := os.Getenv("OPENSHIFT_EVICTION_MONITORING_PERIOD_DURATION"); value != "" {
if duration, err := time.ParseDuration(value); err == nil {
klog.Infof("Detected OPENSHIFT_EVICTION_MONITORING_PERIOD_DURATION: %v", value)
evictionMonitoringPeriod = duration
}
}
}

func getContainerEtcHostsPath() string {
if sysruntime.GOOS == "windows" {
return windowsEtcHostsPath
Expand Down

0 comments on commit 53d0b69

Please sign in to comment.