remove unused code of (pkg/controller)

This commit is contained in:
Guoliang Wang 2018-05-19 08:18:13 +08:00
parent 552453f6fd
commit b1ac6df4dc
8 changed files with 9 additions and 44 deletions

View File

@ -86,7 +86,6 @@ func TestHasKubeletUsages(t *testing.T) {
func TestHandle(t *testing.T) {
cases := []struct {
message string
allowed bool
recognized bool
err bool

View File

@ -32,7 +32,6 @@ var (
productionLabel = map[string]string{"type": "production"}
testLabel = map[string]string{"type": "testing"}
productionLabelSelector = labels.Set{"type": "production"}.AsSelector()
testLabelSelector = labels.Set{"type": "testing"}.AsSelector()
controllerUID = "123"
)
@ -60,12 +59,10 @@ func newPod(podName string, label map[string]string, owner metav1.Object) *v1.Po
func TestClaimPods(t *testing.T) {
controllerKind := schema.GroupVersionKind{}
type test struct {
name string
manager *PodControllerRefManager
pods []*v1.Pod
filters []func(*v1.Pod) bool
claimed []*v1.Pod
released []*v1.Pod
name string
manager *PodControllerRefManager
pods []*v1.Pod
claimed []*v1.Pod
}
var tests = []test{
{

View File

@ -25,7 +25,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",

View File

@ -27,10 +27,7 @@ import (
batchv1beta1 "k8s.io/api/batch/v1beta1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
ref "k8s.io/client-go/tools/reference"
"k8s.io/kubernetes/pkg/api/legacyscheme"
)
@ -177,27 +174,6 @@ func getTimeHash(scheduledTime time.Time) int64 {
return scheduledTime.Unix()
}
// makeCreatedByRefJson makes a json string with an object reference for use in "created-by" annotation value
func makeCreatedByRefJson(object runtime.Object) (string, error) {
createdByRef, err := ref.GetReference(legacyscheme.Scheme, object)
if err != nil {
return "", fmt.Errorf("unable to get controller reference: %v", err)
}
// TODO: this code was not safe previously - as soon as new code came along that switched to v2, old clients
// would be broken upon reading it. This is explicitly hardcoded to v1 to guarantee predictable deployment.
// We need to consistently handle this case of annotation versioning.
codec := legacyscheme.Codecs.LegacyCodec(schema.GroupVersion{Group: v1.GroupName, Version: "v1"})
createdByRefJson, err := runtime.Encode(codec, &v1.SerializedReference{
Reference: *createdByRef,
})
if err != nil {
return "", fmt.Errorf("unable to serialize controller reference: %v", err)
}
return string(createdByRefJson), nil
}
func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) {
for _, c := range j.Status.Conditions {
if (c.Type == batchv1.JobComplete || c.Type == batchv1.JobFailed) && c.Status == v1.ConditionTrue {

View File

@ -506,7 +506,6 @@ func TestFindOldReplicaSets(t *testing.T) {
Name string
deployment apps.Deployment
rsList []*apps.ReplicaSet
podList *v1.PodList
expected []*apps.ReplicaSet
expectedRequire []*apps.ReplicaSet
}{

View File

@ -468,7 +468,6 @@ func TestReplicaSet(t *testing.T) {
// Verify that multiple controllers doesn't allow the PDB to be set true.
func TestMultipleControllers(t *testing.T) {
const rcCount = 2
const podCount = 2
dc, ps := newFakeDisruptionController()
@ -610,10 +609,9 @@ func TestTwoControllers(t *testing.T) {
// code. If you update a parameter here, recalculate the correct values for
// all of them. Further down in the test, we use these to control loops, and
// that level of logic is enough complexity for me.
const collectionSize int32 = 11 // How big each collection is
const minAvailable string = "28%" // minAvailable we'll specify
const minimumOne int32 = 4 // integer minimum with one controller
const minimumTwo int32 = 7 // integer minimum with two controllers
const collectionSize int32 = 11 // How big each collection is
const minimumOne int32 = 4 // integer minimum with one controller
const minimumTwo int32 = 7 // integer minimum with two controllers
pdb, pdbName := newMinAvailablePodDisruptionBudget(t, intstr.FromString("28%"))
add(t, dc.pdbStore, pdb)

View File

@ -695,7 +695,6 @@ func TestPodStatusChange(t *testing.T) {
// Node created long time ago, node controller posted Unknown for a long period of time.
table := []struct {
fakeNodeHandler *testutil.FakeNodeHandler
daemonSets []extensions.DaemonSet
timeToPass time.Duration
newNodeStatus v1.NodeStatus
secondNodeNewStatus v1.NodeStatus

View File

@ -1240,10 +1240,8 @@ func TestGetCondition(t *testing.T) {
tests := []struct {
name string
status apps.ReplicaSetStatus
condType apps.ReplicaSetConditionType
condStatus v1.ConditionStatus
condReason string
status apps.ReplicaSetStatus
condType apps.ReplicaSetConditionType
expected bool
}{