mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Remove unused functions and make logs slightly better
This commit is contained in:
parent
71b7099944
commit
fddac63c27
@ -71,7 +71,6 @@ go_test(
|
|||||||
library = ":go_default_library",
|
library = ":go_default_library",
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api:go_default_library",
|
|
||||||
"//pkg/api/v1:go_default_library",
|
"//pkg/api/v1:go_default_library",
|
||||||
"//pkg/apis/extensions/v1beta1:go_default_library",
|
"//pkg/apis/extensions/v1beta1:go_default_library",
|
||||||
"//pkg/client/clientset_generated/clientset:go_default_library",
|
"//pkg/client/clientset_generated/clientset:go_default_library",
|
||||||
|
@ -485,6 +485,7 @@ func (nc *NodeController) Run() {
|
|||||||
oppositeTaint = *NotReadyTaintTemplate
|
oppositeTaint = *NotReadyTaintTemplate
|
||||||
} else {
|
} else {
|
||||||
// It seems that the Node is ready again, so there's no need to taint it.
|
// It seems that the Node is ready again, so there's no need to taint it.
|
||||||
|
glog.V(4).Infof("Node %v was in a taint queue, but it's ready now. Ignoring taint request.", value.Value)
|
||||||
return true, 0
|
return true, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,6 +499,8 @@ func (nc *NodeController) Run() {
|
|||||||
value.Value,
|
value.Value,
|
||||||
err))
|
err))
|
||||||
return false, 0
|
return false, 0
|
||||||
|
} else {
|
||||||
|
glog.V(4).Info("Added %v Taint to Node %v", taintToAdd, value.Value)
|
||||||
}
|
}
|
||||||
err = controller.RemoveTaintOffNode(nc.kubeClient, value.Value, &oppositeTaint, node)
|
err = controller.RemoveTaintOffNode(nc.kubeClient, value.Value, &oppositeTaint, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -508,6 +511,8 @@ func (nc *NodeController) Run() {
|
|||||||
value.Value,
|
value.Value,
|
||||||
err))
|
err))
|
||||||
return false, 0
|
return false, 0
|
||||||
|
} else {
|
||||||
|
glog.V(4).Info("Made sure that Node %v has no %v Taint", value.Value, oppositeTaint)
|
||||||
}
|
}
|
||||||
return true, 0
|
return true, 0
|
||||||
})
|
})
|
||||||
|
@ -44,41 +44,6 @@ const (
|
|||||||
retries = 5
|
retries = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
func computeTaintDifference(left []v1.Taint, right []v1.Taint) []v1.Taint {
|
|
||||||
result := []v1.Taint{}
|
|
||||||
for i := range left {
|
|
||||||
found := false
|
|
||||||
for j := range right {
|
|
||||||
if left[i] == right[j] {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
result = append(result, left[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy of 'computeTaintDifference' - long live lack of generics...
|
|
||||||
func computeTolerationDifference(left []v1.Toleration, right []v1.Toleration) []v1.Toleration {
|
|
||||||
result := []v1.Toleration{}
|
|
||||||
for i := range left {
|
|
||||||
found := false
|
|
||||||
for j := range right {
|
|
||||||
if left[i] == right[j] {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
result = append(result, left[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needed to make workqueue work
|
// Needed to make workqueue work
|
||||||
type updateItemInterface interface{}
|
type updateItemInterface interface{}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
|
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
|
||||||
"k8s.io/kubernetes/pkg/controller/node/testutil"
|
"k8s.io/kubernetes/pkg/controller/node/testutil"
|
||||||
@ -93,99 +92,6 @@ func TestFilterNoExecuteTaints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestComputeTaintDifference(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
lhs []v1.Taint
|
|
||||||
rhs []v1.Taint
|
|
||||||
expectedDifference []v1.Taint
|
|
||||||
description string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
lhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Key: "two",
|
|
||||||
Value: "two",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Key: "two",
|
|
||||||
Value: "two",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Equal sets",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
lhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
expectedDifference: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Right is empty",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Left is empty",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
lhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Key: "two",
|
|
||||||
Value: "two",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rhs: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "two",
|
|
||||||
Value: "two",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Key: "three",
|
|
||||||
Value: "three",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
expectedDifference: []v1.Taint{
|
|
||||||
{
|
|
||||||
Key: "one",
|
|
||||||
Value: "one",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: "Intersecting arrays",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, item := range testCases {
|
|
||||||
difference := computeTaintDifference(item.lhs, item.rhs)
|
|
||||||
if !api.Semantic.DeepEqual(difference, item.expectedDifference) {
|
|
||||||
t.Errorf("%v: difference in not what expected. Got %v, expected %v", item.description, difference, item.expectedDifference)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreatePod(t *testing.T) {
|
func TestCreatePod(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
description string
|
description string
|
||||||
|
@ -121,12 +121,12 @@ func (q *TimedWorkerQueue) AddWork(args *WorkArgs, createdAt time.Time, fireAt t
|
|||||||
|
|
||||||
// CancelWork removes scheduled function execution from the queue. Returns true if work was cancelled.
|
// CancelWork removes scheduled function execution from the queue. Returns true if work was cancelled.
|
||||||
func (q *TimedWorkerQueue) CancelWork(key string) bool {
|
func (q *TimedWorkerQueue) CancelWork(key string) bool {
|
||||||
glog.V(4).Infof("Cancelling TimedWorkerQueue item %v at %v", key, time.Now())
|
|
||||||
q.Lock()
|
q.Lock()
|
||||||
defer q.Unlock()
|
defer q.Unlock()
|
||||||
worker, found := q.workers[key]
|
worker, found := q.workers[key]
|
||||||
result := false
|
result := false
|
||||||
if found {
|
if found {
|
||||||
|
glog.V(4).Infof("Cancelling TimedWorkerQueue item %v at %v", key, time.Now())
|
||||||
if worker != nil {
|
if worker != nil {
|
||||||
result = true
|
result = true
|
||||||
worker.Cancel()
|
worker.Cancel()
|
||||||
|
Loading…
Reference in New Issue
Block a user