k8s.io/kubernetes@v1.29.3/pkg/kubelet/nodeshutdown/nodeshutdown_manager.go (about) 1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package nodeshutdown 18 19 import ( 20 "time" 21 22 v1 "k8s.io/api/core/v1" 23 "k8s.io/client-go/tools/record" 24 "k8s.io/klog/v2" 25 kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" 26 "k8s.io/kubernetes/pkg/kubelet/eviction" 27 "k8s.io/kubernetes/pkg/kubelet/lifecycle" 28 "k8s.io/kubernetes/pkg/kubelet/prober" 29 "k8s.io/utils/clock" 30 ) 31 32 // Manager interface provides methods for Kubelet to manage node shutdown. 33 type Manager interface { 34 Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult 35 Start() error 36 ShutdownStatus() error 37 } 38 39 // Config represents Manager configuration 40 type Config struct { 41 Logger klog.Logger 42 ProbeManager prober.Manager 43 Recorder record.EventRecorder 44 NodeRef *v1.ObjectReference 45 GetPodsFunc eviction.ActivePodsFunc 46 KillPodFunc eviction.KillPodFunc 47 SyncNodeStatusFunc func() 48 ShutdownGracePeriodRequested time.Duration 49 ShutdownGracePeriodCriticalPods time.Duration 50 ShutdownGracePeriodByPodPriority []kubeletconfig.ShutdownGracePeriodByPodPriority 51 StateDirectory string 52 Clock clock.Clock 53 } 54 55 // managerStub is a fake node shutdown managerImpl . 56 type managerStub struct{} 57 58 // Admit returns a fake Pod admission which always returns true 59 func (managerStub) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult { 60 return lifecycle.PodAdmitResult{Admit: true} 61 } 62 63 // Start is a no-op always returning nil for non linux platforms. 64 func (managerStub) Start() error { 65 return nil 66 } 67 68 // ShutdownStatus is a no-op always returning nil for non linux platforms. 69 func (managerStub) ShutdownStatus() error { 70 return nil 71 }