Skip to content

Commit a9c1acc

Browse files
committed
Fix staticchecks ST1005,S1002,S1008,S1039 in pkg/kubelet
1 parent 1f708f6 commit a9c1acc

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

pkg/kubelet/cm/topologymanager/policy_single_numa_node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ func filterSingleNumaHints(allResourcesHints [][]TopologyHint) [][]TopologyHint
4949
for _, oneResourceHints := range allResourcesHints {
5050
var filtered []TopologyHint
5151
for _, hint := range oneResourceHints {
52-
if hint.NUMANodeAffinity == nil && hint.Preferred == true {
52+
if hint.NUMANodeAffinity == nil && hint.Preferred {
5353
filtered = append(filtered, hint)
5454
}
55-
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 && hint.Preferred == true {
55+
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 && hint.Preferred {
5656
filtered = append(filtered, hint)
5757
}
5858
}

pkg/kubelet/cm/topologymanager/topology_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"sync"
2222

2323
cadvisorapi "github.com/google/cadvisor/info/v1"
24-
"k8s.io/api/core/v1"
24+
v1 "k8s.io/api/core/v1"
2525
"k8s.io/klog/v2"
2626
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/bitmask"
2727
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
@@ -114,7 +114,7 @@ func (th *TopologyHint) IsEqual(topologyHint TopologyHint) bool {
114114
// or `a` NUMANodeAffinity attribute is narrower than `b` NUMANodeAffinity attribute.
115115
func (th *TopologyHint) LessThan(other TopologyHint) bool {
116116
if th.Preferred != other.Preferred {
117-
return th.Preferred == true
117+
return th.Preferred
118118
}
119119
return th.NUMANodeAffinity.IsNarrowerThan(other.NUMANodeAffinity)
120120
}

pkg/kubelet/container/ref_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package container
1919
import (
2020
"testing"
2121

22-
"k8s.io/api/core/v1"
22+
v1 "k8s.io/api/core/v1"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
_ "k8s.io/kubernetes/pkg/apis/core/install"
2525
)
@@ -46,7 +46,7 @@ func TestFieldPath(t *testing.T) {
4646

4747
for name, item := range table {
4848
res, err := fieldPath(item.pod, item.container)
49-
if item.success == false {
49+
if !item.success {
5050
if err == nil {
5151
t.Errorf("%v: unexpected non-error", name)
5252
}

pkg/kubelet/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ func GetNodenameForKernel(hostname string, hostDomainName string, setHostnameAsF
3333
kernelHostname := hostname
3434
// FQDN has to be 64 chars to fit in the Linux nodename kernel field (specification 64 chars and the null terminating char).
3535
const fqdnMaxLen = 64
36-
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN == true {
36+
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN {
3737
fqdn := fmt.Sprintf("%s.%s", hostname, hostDomainName)
3838
// FQDN has to be shorter than hostnameMaxLen characters.
3939
if len(fqdn) > fqdnMaxLen {
40-
return "", fmt.Errorf("Failed to construct FQDN from pod hostname and cluster domain, FQDN %s is too long (%d characters is the max, %d characters requested)", fqdn, fqdnMaxLen, len(fqdn))
40+
return "", fmt.Errorf("failed to construct FQDN from pod hostname and cluster domain, FQDN %s is too long (%d characters is the max, %d characters requested)", fqdn, fqdnMaxLen, len(fqdn))
4141
}
4242
kernelHostname = fqdn
4343
}

pkg/kubelet/volumemanager/reconciler/reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func (rc *reconciler) cleanupMounts(volume podVolume) {
456456
// to unmount both volume and device in the same routine.
457457
err := rc.operationExecutor.UnmountVolume(mountedVolume, rc.actualStateOfWorld, rc.kubeletPodsDir)
458458
if err != nil {
459-
klog.Errorf(mountedVolume.GenerateErrorDetailed(fmt.Sprintf("volumeHandler.UnmountVolumeHandler for UnmountVolume failed"), err).Error())
459+
klog.Errorf(mountedVolume.GenerateErrorDetailed("volumeHandler.UnmountVolumeHandler for UnmountVolume failed", err).Error())
460460
return
461461
}
462462
}

0 commit comments

Comments
 (0)