mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	remove unused code of (pkg/controller)
This commit is contained in:
		| @@ -86,7 +86,6 @@ func TestHasKubeletUsages(t *testing.T) { | |||||||
|  |  | ||||||
| func TestHandle(t *testing.T) { | func TestHandle(t *testing.T) { | ||||||
| 	cases := []struct { | 	cases := []struct { | ||||||
| 		message    string |  | ||||||
| 		allowed    bool | 		allowed    bool | ||||||
| 		recognized bool | 		recognized bool | ||||||
| 		err        bool | 		err        bool | ||||||
|   | |||||||
| @@ -32,7 +32,6 @@ var ( | |||||||
| 	productionLabel         = map[string]string{"type": "production"} | 	productionLabel         = map[string]string{"type": "production"} | ||||||
| 	testLabel               = map[string]string{"type": "testing"} | 	testLabel               = map[string]string{"type": "testing"} | ||||||
| 	productionLabelSelector = labels.Set{"type": "production"}.AsSelector() | 	productionLabelSelector = labels.Set{"type": "production"}.AsSelector() | ||||||
| 	testLabelSelector       = labels.Set{"type": "testing"}.AsSelector() |  | ||||||
| 	controllerUID           = "123" | 	controllerUID           = "123" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -60,12 +59,10 @@ func newPod(podName string, label map[string]string, owner metav1.Object) *v1.Po | |||||||
| func TestClaimPods(t *testing.T) { | func TestClaimPods(t *testing.T) { | ||||||
| 	controllerKind := schema.GroupVersionKind{} | 	controllerKind := schema.GroupVersionKind{} | ||||||
| 	type test struct { | 	type test struct { | ||||||
| 		name     string | 		name    string | ||||||
| 		manager  *PodControllerRefManager | 		manager *PodControllerRefManager | ||||||
| 		pods     []*v1.Pod | 		pods    []*v1.Pod | ||||||
| 		filters  []func(*v1.Pod) bool | 		claimed []*v1.Pod | ||||||
| 		claimed  []*v1.Pod |  | ||||||
| 		released []*v1.Pod |  | ||||||
| 	} | 	} | ||||||
| 	var tests = []test{ | 	var tests = []test{ | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ go_library( | |||||||
|         "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_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/labels:go_default_library", | ||||||
|         "//staging/src/k8s.io/apimachinery/pkg/runtime: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/types:go_default_library", | ||||||
|         "//staging/src/k8s.io/apimachinery/pkg/util/errors: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", |         "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", | ||||||
|   | |||||||
| @@ -27,10 +27,7 @@ import ( | |||||||
| 	batchv1beta1 "k8s.io/api/batch/v1beta1" | 	batchv1beta1 "k8s.io/api/batch/v1beta1" | ||||||
| 	"k8s.io/api/core/v1" | 	"k8s.io/api/core/v1" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/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" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	ref "k8s.io/client-go/tools/reference" |  | ||||||
| 	"k8s.io/kubernetes/pkg/api/legacyscheme" | 	"k8s.io/kubernetes/pkg/api/legacyscheme" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -177,27 +174,6 @@ func getTimeHash(scheduledTime time.Time) int64 { | |||||||
| 	return scheduledTime.Unix() | 	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) { | func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) { | ||||||
| 	for _, c := range j.Status.Conditions { | 	for _, c := range j.Status.Conditions { | ||||||
| 		if (c.Type == batchv1.JobComplete || c.Type == batchv1.JobFailed) && c.Status == v1.ConditionTrue { | 		if (c.Type == batchv1.JobComplete || c.Type == batchv1.JobFailed) && c.Status == v1.ConditionTrue { | ||||||
|   | |||||||
| @@ -506,7 +506,6 @@ func TestFindOldReplicaSets(t *testing.T) { | |||||||
| 		Name            string | 		Name            string | ||||||
| 		deployment      apps.Deployment | 		deployment      apps.Deployment | ||||||
| 		rsList          []*apps.ReplicaSet | 		rsList          []*apps.ReplicaSet | ||||||
| 		podList         *v1.PodList |  | ||||||
| 		expected        []*apps.ReplicaSet | 		expected        []*apps.ReplicaSet | ||||||
| 		expectedRequire []*apps.ReplicaSet | 		expectedRequire []*apps.ReplicaSet | ||||||
| 	}{ | 	}{ | ||||||
|   | |||||||
| @@ -468,7 +468,6 @@ func TestReplicaSet(t *testing.T) { | |||||||
|  |  | ||||||
| // Verify that multiple controllers doesn't allow the PDB to be set true. | // Verify that multiple controllers doesn't allow the PDB to be set true. | ||||||
| func TestMultipleControllers(t *testing.T) { | func TestMultipleControllers(t *testing.T) { | ||||||
| 	const rcCount = 2 |  | ||||||
| 	const podCount = 2 | 	const podCount = 2 | ||||||
|  |  | ||||||
| 	dc, ps := newFakeDisruptionController() | 	dc, ps := newFakeDisruptionController() | ||||||
| @@ -610,10 +609,9 @@ func TestTwoControllers(t *testing.T) { | |||||||
| 	// code.  If you update a parameter here, recalculate the correct values for | 	// 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 | 	// all of them.  Further down in the test, we use these to control loops, and | ||||||
| 	// that level of logic is enough complexity for me. | 	// that level of logic is enough complexity for me. | ||||||
| 	const collectionSize int32 = 11   // How big each collection is | 	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 minimumOne int32 = 4        // integer minimum with one controller | 	const minimumTwo int32 = 7      // integer minimum with two controllers | ||||||
| 	const minimumTwo int32 = 7        // integer minimum with two controllers |  | ||||||
|  |  | ||||||
| 	pdb, pdbName := newMinAvailablePodDisruptionBudget(t, intstr.FromString("28%")) | 	pdb, pdbName := newMinAvailablePodDisruptionBudget(t, intstr.FromString("28%")) | ||||||
| 	add(t, dc.pdbStore, pdb) | 	add(t, dc.pdbStore, pdb) | ||||||
|   | |||||||
| @@ -695,7 +695,6 @@ func TestPodStatusChange(t *testing.T) { | |||||||
| 	// Node created long time ago, node controller posted Unknown for a long period of time. | 	// Node created long time ago, node controller posted Unknown for a long period of time. | ||||||
| 	table := []struct { | 	table := []struct { | ||||||
| 		fakeNodeHandler     *testutil.FakeNodeHandler | 		fakeNodeHandler     *testutil.FakeNodeHandler | ||||||
| 		daemonSets          []extensions.DaemonSet |  | ||||||
| 		timeToPass          time.Duration | 		timeToPass          time.Duration | ||||||
| 		newNodeStatus       v1.NodeStatus | 		newNodeStatus       v1.NodeStatus | ||||||
| 		secondNodeNewStatus v1.NodeStatus | 		secondNodeNewStatus v1.NodeStatus | ||||||
|   | |||||||
| @@ -1240,10 +1240,8 @@ func TestGetCondition(t *testing.T) { | |||||||
| 	tests := []struct { | 	tests := []struct { | ||||||
| 		name string | 		name string | ||||||
|  |  | ||||||
| 		status     apps.ReplicaSetStatus | 		status   apps.ReplicaSetStatus | ||||||
| 		condType   apps.ReplicaSetConditionType | 		condType apps.ReplicaSetConditionType | ||||||
| 		condStatus v1.ConditionStatus |  | ||||||
| 		condReason string |  | ||||||
|  |  | ||||||
| 		expected bool | 		expected bool | ||||||
| 	}{ | 	}{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Guoliang Wang
					Guoliang Wang