Skip to content

Commit

Permalink
Merge pull request #82968 from uzuku/fix-golint-failures
Browse files Browse the repository at this point in the history
Fix golint failures of pkg/kubelet/status/...
  • Loading branch information
k8s-ci-robot authored Oct 7, 2019
2 parents 24424e2 + 5a2e6bd commit 7c4ba59
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 0 additions & 2 deletions hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ pkg/kubelet/pod/testing
pkg/kubelet/preemption
pkg/kubelet/remote
pkg/kubelet/stats
pkg/kubelet/status
pkg/kubelet/status/testing
pkg/kubelet/sysctl
pkg/kubelet/types
pkg/kubemark
Expand Down
11 changes: 8 additions & 3 deletions pkg/kubelet/status/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ import (
)

const (
// UnknownContainerStatuses says that all container statuses are unknown.
UnknownContainerStatuses = "UnknownContainerStatuses"
PodCompleted = "PodCompleted"
ContainersNotReady = "ContainersNotReady"
// PodCompleted says that all related containers have succeeded.
PodCompleted = "PodCompleted"
// ContainersNotReady says that one or more containers are not ready.
ContainersNotReady = "ContainersNotReady"
// ContainersNotInitialized says that one or more init containers have not succeeded.
ContainersNotInitialized = "ContainersNotInitialized"
ReadinessGatesNotReady = "ReadinessGatesNotReady"
// ReadinessGatesNotReady says that one or more pod readiness gates are not ready.
ReadinessGatesNotReady = "ReadinessGatesNotReady"
)

// GenerateContainersReadyCondition returns the status of "ContainersReady" condition.
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubelet/status/status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type PodStatusProvider interface {
GetPodStatus(uid types.UID) (v1.PodStatus, bool)
}

// An object which provides guarantees that a pod can be safely deleted.
// PodDeletionSafetyProvider provides guarantees that a pod can be safely deleted.
type PodDeletionSafetyProvider interface {
// A function which returns true if the pod can safely be deleted
PodResourcesAreReclaimed(pod *v1.Pod, status v1.PodStatus) bool
Expand Down Expand Up @@ -115,6 +115,7 @@ type Manager interface {

const syncPeriod = 10 * time.Second

// NewManager returns a functional Manager.
func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager, podDeletionSafety PodDeletionSafetyProvider) Manager {
return &manager{
kubeClient: kubeClient,
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubelet/status/testing/fake_pod_deletion_safety.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ package testing

import "k8s.io/api/core/v1"

// FakePodDeletionSafetyProvider is a fake PodDeletionSafetyProvider for test.
type FakePodDeletionSafetyProvider struct{}

// PodResourcesAreReclaimed implements PodDeletionSafetyProvider.
// Always reports that all pod resources are reclaimed.
func (f *FakePodDeletionSafetyProvider) PodResourcesAreReclaimed(pod *v1.Pod, status v1.PodStatus) bool {
return true
}
2 changes: 2 additions & 0 deletions pkg/kubelet/status/testing/mock_pod_status_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import (
"k8s.io/apimachinery/pkg/types"
)

// MockStatusProvider mocks a PodStatusProvider.
type MockStatusProvider struct {
mock.Mock
}

// GetPodStatus implements PodStatusProvider.
func (m *MockStatusProvider) GetPodStatus(uid types.UID) (v1.PodStatus, bool) {
args := m.Called(uid)
return args.Get(0).(v1.PodStatus), args.Bool(1)
Expand Down

0 comments on commit 7c4ba59

Please sign in to comment.