mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix staticchecks ST1005,S1002,S1008,S1039 in pkg/kubelet
This commit is contained in:
parent
1f708f6e62
commit
a9c1acc044
@ -49,10 +49,10 @@ func filterSingleNumaHints(allResourcesHints [][]TopologyHint) [][]TopologyHint
|
||||
for _, oneResourceHints := range allResourcesHints {
|
||||
var filtered []TopologyHint
|
||||
for _, hint := range oneResourceHints {
|
||||
if hint.NUMANodeAffinity == nil && hint.Preferred == true {
|
||||
if hint.NUMANodeAffinity == nil && hint.Preferred {
|
||||
filtered = append(filtered, hint)
|
||||
}
|
||||
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 && hint.Preferred == true {
|
||||
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 && hint.Preferred {
|
||||
filtered = append(filtered, hint)
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"sync"
|
||||
|
||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/bitmask"
|
||||
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
|
||||
@ -114,7 +114,7 @@ func (th *TopologyHint) IsEqual(topologyHint TopologyHint) bool {
|
||||
// or `a` NUMANodeAffinity attribute is narrower than `b` NUMANodeAffinity attribute.
|
||||
func (th *TopologyHint) LessThan(other TopologyHint) bool {
|
||||
if th.Preferred != other.Preferred {
|
||||
return th.Preferred == true
|
||||
return th.Preferred
|
||||
}
|
||||
return th.NUMANodeAffinity.IsNarrowerThan(other.NUMANodeAffinity)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package container
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
)
|
||||
@ -46,7 +46,7 @@ func TestFieldPath(t *testing.T) {
|
||||
|
||||
for name, item := range table {
|
||||
res, err := fieldPath(item.pod, item.container)
|
||||
if item.success == false {
|
||||
if !item.success {
|
||||
if err == nil {
|
||||
t.Errorf("%v: unexpected non-error", name)
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ func GetNodenameForKernel(hostname string, hostDomainName string, setHostnameAsF
|
||||
kernelHostname := hostname
|
||||
// FQDN has to be 64 chars to fit in the Linux nodename kernel field (specification 64 chars and the null terminating char).
|
||||
const fqdnMaxLen = 64
|
||||
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN == true {
|
||||
if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN {
|
||||
fqdn := fmt.Sprintf("%s.%s", hostname, hostDomainName)
|
||||
// FQDN has to be shorter than hostnameMaxLen characters.
|
||||
if len(fqdn) > fqdnMaxLen {
|
||||
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))
|
||||
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))
|
||||
}
|
||||
kernelHostname = fqdn
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ func (rc *reconciler) cleanupMounts(volume podVolume) {
|
||||
// to unmount both volume and device in the same routine.
|
||||
err := rc.operationExecutor.UnmountVolume(mountedVolume, rc.actualStateOfWorld, rc.kubeletPodsDir)
|
||||
if err != nil {
|
||||
klog.Errorf(mountedVolume.GenerateErrorDetailed(fmt.Sprintf("volumeHandler.UnmountVolumeHandler for UnmountVolume failed"), err).Error())
|
||||
klog.Errorf(mountedVolume.GenerateErrorDetailed("volumeHandler.UnmountVolumeHandler for UnmountVolume failed", err).Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user