Skip to content

Commit be0f604

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
Remove unused code
1 parent 7877b7b commit be0f604

File tree

10 files changed

+21
-515
lines changed

10 files changed

+21
-515
lines changed

Diff for: pkg/controller/clusterstate/api/cluster_info.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
/*
2-
Copyright 2017 The Kubernetes Authors.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
/*
172
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
183
194
Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2813
See the License for the specific language governing permissions and
2914
limitations under the License.
3015
*/
16+
3117
package api
3218

3319
// ClusterInfo is a snapshot of cluster by cache.

Diff for: pkg/controller/clusterstate/api/helpers.go

+1-81
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
/*
2-
Copyright 2017 The Kubernetes Authors.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
/*
172
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
183
194
Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,78 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2813
See the License for the specific language governing permissions and
2914
limitations under the License.
3015
*/
16+
3117
package api
3218

3319
import (
34-
"fmt"
35-
3620
v1 "k8s.io/api/core/v1"
3721
)
3822

39-
func getTaskStatus(pod *v1.Pod) TaskStatus {
40-
switch pod.Status.Phase {
41-
case v1.PodRunning:
42-
if pod.DeletionTimestamp != nil {
43-
return Releasing
44-
}
45-
46-
return Running
47-
case v1.PodPending:
48-
if pod.DeletionTimestamp != nil {
49-
return Releasing
50-
}
51-
52-
if len(pod.Spec.NodeName) == 0 {
53-
return Pending
54-
}
55-
return Bound
56-
case v1.PodUnknown:
57-
return Unknown
58-
case v1.PodSucceeded:
59-
return Succeeded
60-
case v1.PodFailed:
61-
return Failed
62-
}
63-
64-
return Unknown
65-
}
66-
67-
func AllocatedStatus(status TaskStatus) bool {
68-
switch status {
69-
case Bound, Binding, Running, Allocated:
70-
return true
71-
default:
72-
return false
73-
}
74-
}
75-
76-
func MergeErrors(errs ...error) error {
77-
msg := "errors: "
78-
79-
foundErr := false
80-
i := 1
81-
82-
for _, e := range errs {
83-
if e != nil {
84-
if foundErr {
85-
msg = fmt.Sprintf("%s, %d: ", msg, i)
86-
} else {
87-
msg = fmt.Sprintf("%s %d: ", msg, i)
88-
}
89-
90-
msg = fmt.Sprintf("%s%v", msg, e)
91-
foundErr = true
92-
i++
93-
}
94-
}
95-
96-
if foundErr {
97-
return fmt.Errorf("%s", msg)
98-
}
99-
100-
return nil
101-
}
102-
10323
func NewStringsMap(source map[string]string) map[string]string {
10424
target := make(map[string]string)
10525

Diff for: pkg/controller/clusterstate/api/histogram_info.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,73 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package api
1718

1819
import (
19-
"github.com/prometheus/client_golang/prometheus"
2020
"math"
2121

22+
"github.com/prometheus/client_golang/prometheus"
23+
2224
"k8s.io/klog/v2"
2325
)
2426

2527
const (
26-
BucketCount = 20 //Must be > 0
27-
tolerance = 0.1
28+
BucketCount = 20 // Must be > 0
29+
tolerance = 0.1
2830
)
31+
2932
type ResourceHistogram struct {
3033
MilliCPU *prometheus.Histogram
3134
Memory *prometheus.Histogram
3235
GPU *prometheus.Histogram
3336
}
3437

3538
func NewResourceHistogram(min *Resource, max *Resource) *ResourceHistogram {
36-
3739
start := max.MilliCPU
3840
width := 1.0
3941
count := 2
4042
diff := math.Abs(min.MilliCPU - max.MilliCPU)
4143
if diff >= tolerance {
4244
start = min.MilliCPU
43-
width = (diff/(BucketCount - 1))
45+
width = (diff / (BucketCount - 1))
4446
count = BucketCount + 1
4547
}
4648
klog.V(10).Infof("[NewResourceHistogram] Start histogram numbers for CPU: start=%f, width=%f, count=%d",
4749
start, width, count)
4850
millicpuHist := prometheus.NewHistogram(prometheus.HistogramOpts{
49-
Name: "millicpu",
50-
Buckets: prometheus.LinearBuckets(start, width, count),})
51+
Name: "millicpu",
52+
Buckets: prometheus.LinearBuckets(start, width, count)})
5153

5254
start = max.Memory
5355
width = 1.0
5456
count = 2
5557
diff = math.Abs(min.Memory - max.Memory)
5658
if diff >= tolerance {
5759
start = min.Memory
58-
width = (diff/(BucketCount - 1))
60+
width = (diff / (BucketCount - 1))
5961
count = BucketCount + 1
6062
}
6163
klog.V(10).Infof("[NewResourceHistogram] Start histogram numbers for Memory: start=%f, width=%f, count=%d",
6264
start, width, count)
6365
memoryHist := prometheus.NewHistogram(prometheus.HistogramOpts{
64-
Name: "memory",
65-
Buckets: prometheus.LinearBuckets(start, width, count),})
66+
Name: "memory",
67+
Buckets: prometheus.LinearBuckets(start, width, count)})
6668

6769
start = float64(max.GPU)
6870
width = 1.0
6971
count = 2
7072
diff = math.Abs(float64(min.GPU - max.GPU))
7173
if diff >= tolerance {
7274
start = float64(min.GPU)
73-
width = (diff/(BucketCount - 1))
75+
width = (diff / (BucketCount - 1))
7476
count = BucketCount + 1
7577
}
7678
klog.V(10).Infof("[NewResourceHistogram] Start histogram numbers for GPU: start=%f, width=%f, count=%d",
7779
start, width, count)
7880
gpuHist := prometheus.NewHistogram(prometheus.HistogramOpts{
79-
Name: "gpu",
80-
Buckets: prometheus.LinearBuckets(start, width, count),})
81+
Name: "gpu",
82+
Buckets: prometheus.LinearBuckets(start, width, count)})
8183

8284
rh := &ResourceHistogram{
8385
MilliCPU: &millicpuHist,
@@ -92,5 +94,3 @@ func (rh *ResourceHistogram) Observer(r *Resource) {
9294
(*rh.Memory).Observe(r.Memory)
9395
(*rh.GPU).Observe(float64(r.GPU))
9496
}
95-
96-

Diff for: pkg/controller/clusterstate/api/node_info.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
/*
2-
Copyright 2017 The Kubernetes Authors.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
/*
172
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
183
194
Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2813
See the License for the specific language governing permissions and
2914
limitations under the License.
3015
*/
16+
3117
package api
3218

3319
import (

Diff for: pkg/controller/clusterstate/api/node_info_test.go

-45
This file was deleted.

0 commit comments

Comments
 (0)