Skip to content

Commit

Permalink
koordlet: fix some fmt err
Browse files Browse the repository at this point in the history
Signed-off-by: acejilam <acejilam@gmail.com>
  • Loading branch information
ls-2018 committed Mar 25, 2024
1 parent 38b449f commit ccdad84
Show file tree
Hide file tree
Showing 24 changed files with 86 additions and 75 deletions.
14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/descheduler/controllers/migration/evict.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CreatePodMigrationJob(ctx context.Context, pod *corev1.Pod, evictOptions fr

err := client.Create(ctx, job)
if err != nil {
klog.Errorf("Failed to create PodMigrationJob for Pod %s/s, err: %v", pod.Namespace, pod.Name, err)
klog.Errorf("Failed to create PodMigrationJob for Pod %s/%s, err: %v", pod.Namespace, pod.Name, err)
return err
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func (k *kidledcoldPageCollector) Enabled() bool {
kidledConfig := system.NewDefaultKidledConfig()
err := system.SetKidledScanPeriodInSeconds(kidledConfig.ScanPeriodInseconds)
if err != nil {
klog.V(4).Infof("cold page collector start kidled err:", err)
klog.V(4).Infof("cold page collector start kidled err: %v", err)
return false
}
err = system.SetKidledUseHierarchy(kidledConfig.UseHierarchy)
if err != nil {
klog.V(4).Infof("cold page collector start kidled err:", err)
klog.V(4).Infof("cold page collector start kidled err: %v", err)
return false
}
system.SetIsStartColdMemory(true)
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/qosmanager/framework/pod_qos_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func InjectQOSGreyCtrlPlugins(pod *corev1.Pod, policyType QOSPolicyType, policy
klog.Warningf("running qos grey control plugin %v for pod %v failed", name, util.GetPodKey(pod))
} else if pluginInjected {
klog.V(5).Infof("running qos grey control plugin %v for pod %v success, policy detail %v",
name, util.GetPodKey(pod))
name, util.GetPodKey(pod), policy)
injected = true
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/koordlet/qosmanager/plugins/cpuevict/cpu_evict.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (c *cpuEvictor) calculateMilliRelease(thresholdConfig *slov1alpha1.Resource
if milliRelease > 0 {
klog.V(4).Infof("cpuEvict by ResourceSatisfaction start to evict, milliRelease: %v,"+
"current status (BEUsage:%v, BERequest:%v, BELimit:%v, BERealLimit:%v, BEAllocatable:%v)",
currentBECPUMilliUsage, currentBECPUMilliRequest, currentBECPUMilliLimit, currentBECPUMilliRealLimit,
milliRelease, currentBECPUMilliUsage, currentBECPUMilliRequest, currentBECPUMilliLimit, currentBECPUMilliRealLimit,
beCPUMilliAllocatable)
}
return milliRelease
Expand Down Expand Up @@ -305,7 +305,7 @@ func (c *cpuEvictor) killAndEvictBEPodsRelease(node *corev1.Node, bePodInfos []*
killedPods = append(killedPods, bePod.pod)
cpuMilliReleased = cpuMilliReleased + bePod.milliRequest

klog.V(5).Infof("cpuEvict pick pod %s/%s to evict", util.GetPodKey(bePod.pod))
klog.V(5).Infof("cpuEvict pick pod %s to evict", util.GetPodKey(bePod.pod))
}

c.evictor.EvictPodsIfNotEvicted(killedPods, node, resourceexecutor.EvictPodByBECPUSatisfaction, message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (r *CPUSuppress) recoverCPUSetForBECPUManager() {
}
resourceStatus, err := apiext.GetResourceStatus(podMeta.Pod.Annotations)
if err != nil {
klog.Warningf("get resource status for pod %s failed, error %v", podMeta.Key())
klog.Warningf("get resource status for pod %s failed, error %v", podMeta.Key(), err.Error())
continue
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/koordlet/runtimehooks/hooks/coresched/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (p *Plugin) addCookie(pids []uint32, groupID string) (uint64, []uint32, err
// TODO: refactor to resource updater.
func (p *Plugin) assignCookie(pids, siblingPIDs []uint32, groupID string, targetCookieID uint64) ([]uint32, []uint32, error) {
if len(pids) <= 0 {
klog.V(6).Infof("aborted to assign PIDs cookie for group %s, target cookie %v, no PID",
klog.V(6).Infof("aborted to assign PIDs cookie for group %d, target cookie %v, no PID",
targetCookieID, groupID)
return nil, nil, nil
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func (p *Plugin) clearCookie(pids []uint32, groupID string, lastCookieID uint64)

failedPIDs, err := p.cse.Clear(sysutil.CoreSchedScopeThreadGroup, pidsToClear.GetAllSorted()...)
if err != nil {
klog.V(4).Infof("failed to clear cookie for group, last cookie %v, PID %v failed of %v, total %v, err: %s",
klog.V(4).Infof("failed to clear cookie for group %v, last cookie %v, PID %v failed of %v, total %v, err: %s",
groupID, lastCookieID, len(failedPIDs), pidsToClear.GetAllSorted(), len(pids), err)
pidsToClear.DeleteAny(failedPIDs...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/runtimehooks/hooks/groupidentity/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (b *bvtPlugin) ruleUpdateCb(target *statesinformer.CallbackTarget) error {
kubeQOSParentDir := koordletutil.GetPodQoSRelativePath(kubeQOS)
podCgroupDirs, err := koordletutil.GetCgroupPathsByTargetDepth(sysutil.CPUBVTWarpNsName, kubeQOSParentDir, koordletutil.PodCgroupPathRelativeDepth)
if err != nil {
klog.Infof("get pod cgroup paths failed, qos %s, err: %w", kubeQOS, err)
klog.Infof("get pod cgroup paths failed, qos %s, err: %v", kubeQOS, err.Error())
continue
}
for _, cgroupDir := range podCgroupDirs {
Expand Down
6 changes: 3 additions & 3 deletions pkg/koordlet/runtimehooks/protocol/container_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *ContainerRequest) FromNri(pod *api.PodSandbox, container *api.Container

spec, err := apiext.GetExtendedResourceSpec(pod.GetAnnotations())
if err != nil {
klog.V(4).Infof("failed to get ExtendedResourceSpec from nri via annotation, container %s/%s, err: %s",
klog.V(4).Infof("failed to get ExtendedResourceSpec from nri via annotation, container %s/%s, name: %s, err: %s",
c.PodMeta.Namespace, c.PodMeta.Name, c.ContainerMeta.Name, err)
}
if spec != nil && spec.Containers != nil {
Expand All @@ -112,7 +112,7 @@ func (c *ContainerRequest) FromProxy(req *runtimeapi.ContainerResourceHookReques
// retrieve ExtendedResources from pod annotations
spec, err := apiext.GetExtendedResourceSpec(req.GetPodAnnotations())
if err != nil {
klog.V(4).Infof("failed to get ExtendedResourceSpec from proxy via annotation, container %s/%s, err: %s",
klog.V(4).Infof("failed to get ExtendedResourceSpec from proxy via annotation, container %s/%s, name: %s, err: %s",
c.PodMeta.Namespace, c.PodMeta.Name, c.ContainerMeta.Name, err)
}
if spec != nil && spec.Containers != nil {
Expand Down Expand Up @@ -166,7 +166,7 @@ func (c *ContainerRequest) FromReconciler(podMeta *statesinformer.PodMeta, conta
// retrieve ExtendedResources from container spec and pod annotations (prefer container spec)
specFromAnnotations, err := apiext.GetExtendedResourceSpec(podMeta.Pod.Annotations)
if err != nil {
klog.V(4).Infof("failed to get ExtendedResourceSpec from reconciler via annotation, container %s/%s, err: %s",
klog.V(4).Infof("failed to get ExtendedResourceSpec from reconciler via annotation, container %s/%s, name: %s, err: %s",
c.PodMeta.Namespace, c.PodMeta.Name, c.ContainerMeta.Name, err)
}
if specFromContainer != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/runtimehooks/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *Rule) runUpdateCallbacks(target *statesinformer.CallbackTarget) {
for _, callbackFn := range r.callbacks {
if err := callbackFn(target); err != nil {
cbName := runtime.FuncForPC(reflect.ValueOf(callbackFn).Pointer()).Name()
klog.Warningf("executing %s callback function %s failed, error %v", r.name, cbName)
klog.Warningf("executing %s callback function %s failed, error %v", r.name, cbName, err.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/statesinformer/impl/callback_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *callbackRunner) Start(stopCh <-chan struct{}) {
case cbCtx := <-s.callbackChans[cbType]:
cbObj := s.getObjByType(cbType, cbCtx)
if cbObj == nil {
klog.Warningf("callback runner with type %v is not exist")
klog.Warningf("callback runner with type %T is not exist", cbObj)
} else {
s.runCallbacks(cbType, cbObj)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/statesinformer/impl/states_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *podsInformer) Start(stopCh <-chan struct{}) {
go s.syncKubeletLoop(s.config.KubeletSyncInterval, stopCh)
go func() {
if err := s.pleg.Run(stopCh); err != nil {
klog.Fatalf("Unable to run the pleg: ", err)
klog.Fatalf("Unable to run the pleg: %v", err.Error())
}
}()

Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/util/meminfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func GetHugePagesInfo(nodeDir string) (map[uint64]*HugePagesInfo, error) {
hugepageDir := system.GetNUMAHugepagesDir(nodeDir)
hugeDirs, err := os.ReadDir(hugepageDir)
if err != nil {
klog.Warningf("failed to read hugepage dir %s, err: %w", hugepageDir, err)
klog.Warningf("failed to read hugepage dir %s, err: %v", hugepageDir, err)
return hugePagesInfo, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/koordlet/util/system/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func InitSupportConfigs() {
initCgroupsVersion()
HostSystemInfo = collectVersionInfo()
if isResctrlSupported, err := IsSupportResctrl(); err != nil {
klog.Warningf("failed to check resctrl support status, use %d, err: %v", isResctrlSupported, err)
klog.Warningf("failed to check resctrl support status, use %v, err: %v", isResctrlSupported, err)
} else {
klog.V(4).Infof("resctrl supported: %v", isResctrlSupported)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/httputil/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (p *ReverseProxy) handleUpgradeResponse(rw http.ResponseWriter, req *http.R

conn, brw, err := hj.Hijack()
if err != nil {
p.getErrorHandler()(rw, req, fmt.Errorf("Hijack failed on protocol switch: %v", err))
p.getErrorHandler()(rw, req, fmt.Errorf("hijack failed on protocol switch: %v", err))
return
}
defer conn.Close()
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/metrics/expire_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (e *metricGC) UpdateStatus(metricName string, labels prometheus.Labels) {
err := e.updateStatus(time.Now().Unix(), metricName, labels)
e.globalLock.RUnlock()
if err != nil {
klog.Errorf("failed to update status for metric %s, err: %s", metricName)
klog.Errorf("failed to update status for metric %s, err: %s", metricName, err.Error())
}
}

Expand All @@ -271,7 +271,7 @@ func (e *metricGC) RemoveStatus(metricName string, labels prometheus.Labels) {
err := e.removeStatus(metricName, labels)
e.globalLock.RUnlock()
if err != nil {
klog.Errorf("failed to remove status for metric %s, err: %s", metricName)
klog.Errorf("failed to remove status for metric %s, err: %s", metricName, err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/api_debug_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func RegisterDebugAPIProvider(name string, provider http.Handler) {
func InstallDebugAPIHandler(server *webhook.Server) {
for name, provider := range debugAPIProviderMap {
server.Register(name, provider)
klog.Infof("Success register debug api handler, name:%v, tcpAddr:%v", name)
klog.Infof("Success register debug api handler, name:%v, tcpAddr:%s:%d", name, server.Host, server.Port)
}
}
2 changes: 1 addition & 1 deletion pkg/webhook/pod/mutating/extended_resource_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (h *PodMutatingHandler) mutateByExtendedResources(pod *corev1.Pod) error {
}
if reflect.DeepEqual(extendedResourceSpec, spec) {
// if resource requirements not changed, just return
klog.V(6).Infof("extended resource spec of pod %s/%s unchanged, skip patch the annotation")
klog.V(6).Infof("extended resource spec of pod %s/%s unchanged, skip patch the annotation", pod.Namespace, pod.Name)
return nil
}

Expand Down
36 changes: 18 additions & 18 deletions test/e2e/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ limitations under the License.
// The command line flags all get stored in a private flag set. The
// developer of the E2E test suite decides how they are exposed. Options
// include:
// - exposing as normal flags in the actual command line:
// CopyFlags(Flags, flag.CommandLine)
// - populate via test/e2e/framework/viperconfig:
// viperconfig.ViperizeFlags("my-config.yaml", "", Flags)
// - a combination of both:
// CopyFlags(Flags, flag.CommandLine)
// viperconfig.ViperizeFlags("my-config.yaml", "", flag.CommandLine)
// - exposing as normal flags in the actual command line:
// CopyFlags(Flags, flag.CommandLine)
// - populate via test/e2e/framework/viperconfig:
// viperconfig.ViperizeFlags("my-config.yaml", "", Flags)
// - a combination of both:
// CopyFlags(Flags, flag.CommandLine)
// viperconfig.ViperizeFlags("my-config.yaml", "", flag.CommandLine)
//
// Instead of defining flags one-by-one, test developers annotate a
// structure with tags and then call a single function. This is the
Expand All @@ -39,16 +39,16 @@ limitations under the License.
//
// For example, a file storage/csi.go might define:
//
// var scaling struct {
// NumNodes int `default:"1" description:"number of nodes to run on"`
// Master string
// }
// _ = config.AddOptions(&scaling, "storage.csi.scaling")
// var scaling struct {
// NumNodes int `default:"1" description:"number of nodes to run on"`
// Master string
// }
// _ = config.AddOptions(&scaling, "storage.csi.scaling")
//
// This defines the following command line flags:
//
// -storage.csi.scaling.numNodes=<int> - number of nodes to run on (default: 1)
// -storage.csi.scaling.master=<string>
// -storage.csi.scaling.numNodes=<int> - number of nodes to run on (default: 1)
// -storage.csi.scaling.master=<string>
//
// All fields in the structure must be exported and have one of the following
// types (same as in the `flag` package):
Expand All @@ -64,10 +64,10 @@ limitations under the License.
//
// Each basic entry may have a tag with these optional keys:
//
// usage: additional explanation of the option
// default: the default value, in the same format as it would
// be given on the command line and true/false for
// a boolean
// usage: additional explanation of the option
// default: the default value, in the same format as it would
// be given on the command line and true/false for
// a boolean
//
// The names of the final configuration options are a combination of an
// optional common prefix for all options in the structure and the
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/framework/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ var codeFilterRE = regexp.MustCompile(`/github.com/onsi/ginkgo/`)
// entries coming from Ginkgo.
//
// This is a modified copy of PruneStack in https://github.com/onsi/ginkgo/blob/f90f37d87fa6b1dd9625e2b1e83c23ffae3de228/internal/codelocation/code_location.go#L25:
// - simplified API and thus renamed (calls debug.Stack() instead of taking a parameter)
// - source code filtering updated to be specific to Kubernetes
// - optimized to use bytes and in-place slice filtering from
// https://github.com/golang/go/wiki/SliceTricks#filter-in-place
// - simplified API and thus renamed (calls debug.Stack() instead of taking a parameter)
// - source code filtering updated to be specific to Kubernetes
// - optimized to use bytes and in-place slice filtering from
// https://github.com/golang/go/wiki/SliceTricks#filter-in-place
func PrunedStack(skip int) []byte {
fullStackTrace := debug.Stack()
stack := bytes.Split(fullStackTrace, []byte("\n"))
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/framework/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,15 @@ var functionArgs = regexp.MustCompile(`([[:alpha:]]+)\(.*\)`)
// testFailureOutput matches TestFailureOutput() and its source followed by additional stack entries:
//
// github.com/koordinator-sh/koordinator/test/e2e/framework_test.TestFailureOutput(0xc000558800)
//
// /nvme/gopath/src/github.com/koordinator-sh/koordinator/test/e2e/framework/log/log_test.go:73 +0x1c9
//
// testing.tRunner(0xc000558800, 0x1af2848)
// /nvme/gopath/go/src/testing/testing.go:865 +0xc0
//
// /nvme/gopath/go/src/testing/testing.go:865 +0xc0
//
// created by testing.(*T).Run
//
// /nvme/gopath/go/src/testing/testing.go:916 +0x35a
var testFailureOutput = regexp.MustCompile(`(?m)^github.com/koordinator-sh/koordinator/test/e2e/framework_test\.TestFailureOutput\(.*\n\t.*(\n.*\n\t.*)*`)

Expand Down
24 changes: 14 additions & 10 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,18 +1345,22 @@ func taintExists(taints []v1.Taint, taintToFind *v1.Taint) bool {

// WatchEventSequenceVerifier ...
// manages a watch for a given resource, ensures that events take place in a given order, retries the test on failure
// testContext cancelation signal across API boundries, e.g: context.TODO()
// dc sets up a client to the API
// resourceType specify the type of resource
// namespace select a namespace
// resourceName the name of the given resource
// listOptions options used to find the resource, recommended to use listOptions.labelSelector
// expectedWatchEvents array of events which are expected to occur
// scenario the test itself
// retryCleanup a function to run which ensures that there are no dangling resources upon test failure
//
// testContext cancelation signal across API boundries, e.g: context.TODO()
// dc sets up a client to the API
// resourceType specify the type of resource
// namespace select a namespace
// resourceName the name of the given resource
// listOptions options used to find the resource, recommended to use listOptions.labelSelector
// expectedWatchEvents array of events which are expected to occur
// scenario the test itself
// retryCleanup a function to run which ensures that there are no dangling resources upon test failure
//
// this tooling relies on the test to return the events as they occur
// the entire scenario must be run to ensure that the desired watch events arrive in order (allowing for interweaving of watch events)
// if an expected watch event is missing we elect to clean up and run the entire scenario again
//
// if an expected watch event is missing we elect to clean up and run the entire scenario again
//
// we try the scenario three times to allow the sequencing to fail a couple of times
func WatchEventSequenceVerifier(ctx context.Context, dc dynamic.Interface, resourceType schema.GroupVersionResource, namespace string, resourceName string, listOptions metav1.ListOptions, expectedWatchEvents []watch.Event, scenario func(*watchtools.RetryWatcher) []watch.Event, retryCleanup func() error) {
listWatcher := &cache.ListWatch{
Expand Down
12 changes: 7 additions & 5 deletions test/e2e/generated/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8604,11 +8604,13 @@ var _bindata = map[string]func() (*asset, error){
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
//
// data/
// foo.txt
// img/
// a.png
// b.png
//
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
Expand Down

0 comments on commit ccdad84

Please sign in to comment.