Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused code of (pkg/controller) #64061

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/controller/certificates/approver/sarapprove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestHasKubeletUsages(t *testing.T) {

func TestHandle(t *testing.T) {
cases := []struct {
message string
allowed bool
recognized bool
err bool
Expand Down
11 changes: 4 additions & 7 deletions pkg/controller/controller_ref_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{
{
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/cronjob/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 0 additions & 24 deletions pkg/controller/cronjob/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/deployment/util/deployment_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}{
Expand Down
8 changes: 3 additions & 5 deletions pkg/controller/disruption/disruption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/replicaset/replica_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}{
Expand Down