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