Skip to content

Commit 8a495cb

Browse files
committed
Clean up error messages (ST1005)
1 parent e06912c commit 8a495cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+126
-128
lines changed

pkg/kubelet/active_deadline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func newActiveDeadlineHandler(
5151

5252
// check for all required fields
5353
if clock == nil || podStatusProvider == nil || recorder == nil {
54-
return nil, fmt.Errorf("Required arguments must not be nil: %v, %v, %v", clock, podStatusProvider, recorder)
54+
return nil, fmt.Errorf("required arguments must not be nil: %v, %v, %v", clock, podStatusProvider, recorder)
5555
}
5656
return &activeDeadlineHandler{
5757
clock: clock,

pkg/kubelet/apis/podresources/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func GetClient(socket string, connectionTimeout time.Duration, maxMsgSize int) (
3838

3939
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
4040
if err != nil {
41-
return nil, nil, fmt.Errorf("Error dialing socket %s: %v", socket, err)
41+
return nil, nil, fmt.Errorf("error dialing socket %s: %v", socket, err)
4242
}
4343
return podresourcesapi.NewPodResourcesListerClient(conn), conn, nil
4444
}

pkg/kubelet/certificate/bootstrap/bootstrap.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,32 +235,32 @@ func isClientConfigStillValid(kubeconfigPath string) (bool, error) {
235235
}
236236
bootstrapClientConfig, err := loadRESTClientConfig(kubeconfigPath)
237237
if err != nil {
238-
utilruntime.HandleError(fmt.Errorf("Unable to read existing bootstrap client config: %v", err))
238+
utilruntime.HandleError(fmt.Errorf("unable to read existing bootstrap client config: %v", err))
239239
return false, nil
240240
}
241241
transportConfig, err := bootstrapClientConfig.TransportConfig()
242242
if err != nil {
243-
utilruntime.HandleError(fmt.Errorf("Unable to load transport configuration from existing bootstrap client config: %v", err))
243+
utilruntime.HandleError(fmt.Errorf("unable to load transport configuration from existing bootstrap client config: %v", err))
244244
return false, nil
245245
}
246246
// has side effect of populating transport config data fields
247247
if _, err := transport.TLSConfigFor(transportConfig); err != nil {
248-
utilruntime.HandleError(fmt.Errorf("Unable to load TLS configuration from existing bootstrap client config: %v", err))
248+
utilruntime.HandleError(fmt.Errorf("unable to load TLS configuration from existing bootstrap client config: %v", err))
249249
return false, nil
250250
}
251251
certs, err := certutil.ParseCertsPEM(transportConfig.TLS.CertData)
252252
if err != nil {
253-
utilruntime.HandleError(fmt.Errorf("Unable to load TLS certificates from existing bootstrap client config: %v", err))
253+
utilruntime.HandleError(fmt.Errorf("unable to load TLS certificates from existing bootstrap client config: %v", err))
254254
return false, nil
255255
}
256256
if len(certs) == 0 {
257-
utilruntime.HandleError(fmt.Errorf("Unable to read TLS certificates from existing bootstrap client config: %v", err))
257+
utilruntime.HandleError(fmt.Errorf("unable to read TLS certificates from existing bootstrap client config: %v", err))
258258
return false, nil
259259
}
260260
now := time.Now()
261261
for _, cert := range certs {
262262
if now.After(cert.NotAfter) {
263-
utilruntime.HandleError(fmt.Errorf("Part of the existing bootstrap client certificate is expired: %s", cert.NotAfter))
263+
utilruntime.HandleError(fmt.Errorf("part of the existing bootstrap client certificate is expired: %s", cert.NotAfter))
264264
return false, nil
265265
}
266266
}

pkg/kubelet/cm/cgroup_manager_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (m *cgroupManagerImpl) Destroy(cgroupConfig *CgroupConfig) error {
303303

304304
// Delete cgroups using libcontainers Managers Destroy() method
305305
if err = manager.Destroy(); err != nil {
306-
return fmt.Errorf("Unable to destroy cgroup paths for cgroup %v : %v", cgroupConfig.Name, err)
306+
return fmt.Errorf("unable to destroy cgroup paths for cgroup %v : %v", cgroupConfig.Name, err)
307307
}
308308

309309
return nil
@@ -346,14 +346,14 @@ func setSupportedSubsystems(cgroupConfig *libcontainerconfigs.Cgroup) error {
346346
for sys, required := range getSupportedSubsystems() {
347347
if _, ok := cgroupConfig.Paths[sys.Name()]; !ok {
348348
if required {
349-
return fmt.Errorf("Failed to find subsystem mount for required subsystem: %v", sys.Name())
349+
return fmt.Errorf("failed to find subsystem mount for required subsystem: %v", sys.Name())
350350
}
351351
// the cgroup is not mounted, but its not required so continue...
352352
klog.V(6).Infof("Unable to find subsystem mount for optional subsystem: %v", sys.Name())
353353
continue
354354
}
355355
if err := sys.Set(cgroupConfig.Paths[sys.Name()], cgroupConfig); err != nil {
356-
return fmt.Errorf("Failed to set config for supported subsystems : %v", err)
356+
return fmt.Errorf("failed to set config for supported subsystems : %v", err)
357357
}
358358
}
359359
return nil
@@ -560,14 +560,14 @@ func getStatsSupportedSubsystems(cgroupPaths map[string]string) (*libcontainercg
560560
for sys, required := range getSupportedSubsystems() {
561561
if _, ok := cgroupPaths[sys.Name()]; !ok {
562562
if required {
563-
return nil, fmt.Errorf("Failed to find subsystem mount for required subsystem: %v", sys.Name())
563+
return nil, fmt.Errorf("failed to find subsystem mount for required subsystem: %v", sys.Name())
564564
}
565565
// the cgroup is not mounted, but its not required so continue...
566566
klog.V(6).Infof("Unable to find subsystem mount for optional subsystem: %v", sys.Name())
567567
continue
568568
}
569569
if err := sys.GetStats(cgroupPaths[sys.Name()], stats); err != nil {
570-
return nil, fmt.Errorf("Failed to get stats for supported subsystems : %v", err)
570+
return nil, fmt.Errorf("failed to get stats for supported subsystems : %v", err)
571571
}
572572
}
573573
return stats, nil

pkg/kubelet/cm/container_manager_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
214214
// If there is more than one line (table headers) in /proc/swaps, swap is enabled and we should
215215
// error out unless --fail-swap-on is set to false.
216216
if len(swapLines) > 1 {
217-
return nil, fmt.Errorf("Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: %v", swapLines)
217+
return nil, fmt.Errorf("running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: %v", swapLines)
218218
}
219219
}
220220

@@ -395,7 +395,7 @@ func setupKernelTunables(option KernelTunableBehavior) error {
395395

396396
switch option {
397397
case KernelTunableError:
398-
errList = append(errList, fmt.Errorf("Invalid kernel flag: %v, expected value: %v, actual value: %v", flag, expectedValue, val))
398+
errList = append(errList, fmt.Errorf("invalid kernel flag: %v, expected value: %v, actual value: %v", flag, expectedValue, val))
399399
case KernelTunableWarn:
400400
klog.V(2).Infof("Invalid kernel flag: %v, expected value: %v, actual value: %v", flag, expectedValue, val)
401401
case KernelTunableModify:

pkg/kubelet/cm/cpumanager/state/state_checkpoint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func NewCheckpointState(stateDir, checkpointName, policyName string) (State, err
5151
}
5252

5353
if err := stateCheckpoint.restoreState(); err != nil {
54+
//lint:ignore ST1005 user-facing error message
5455
return nil, fmt.Errorf("could not restore state from checkpoint: %v\n"+
5556
"Please drain this node and delete the CPU manager checkpoint file %q before restarting Kubelet.",
5657
err, path.Join(stateDir, checkpointName))

pkg/kubelet/cm/devicemanager/manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ func (m *ManagerImpl) RegisterPlugin(pluginName string, endpoint string, version
276276

277277
e, err := newEndpointImpl(endpoint, pluginName, m.callback)
278278
if err != nil {
279-
return fmt.Errorf("Failed to dial device plugin with socketPath %s: %v", endpoint, err)
279+
return fmt.Errorf("failed to dial device plugin with socketPath %s: %v", endpoint, err)
280280
}
281281

282282
options, err := e.client.GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
283283
if err != nil {
284-
return fmt.Errorf("Failed to get device plugin options: %v", err)
284+
return fmt.Errorf("failed to get device plugin options: %v", err)
285285
}
286286

287287
m.registerEndpoint(pluginName, options, e)
@@ -697,7 +697,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
697697
m.mutex.Lock()
698698
m.allocatedDevices = m.podDevices.devices()
699699
m.mutex.Unlock()
700-
return fmt.Errorf("Unknown Device Plugin %s", resource)
700+
return fmt.Errorf("unknown Device Plugin %s", resource)
701701
}
702702

703703
devs := allocDevices.UnsortedList()
@@ -717,7 +717,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
717717
}
718718

719719
if len(resp.ContainerResponses) == 0 {
720-
return fmt.Errorf("No containers return in allocation response %v", resp)
720+
return fmt.Errorf("no containers return in allocation response %v", resp)
721721
}
722722

723723
// Update internal cached podDevices state.

pkg/kubelet/cm/node_container_manager_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (cm *containerManagerImpl) validateNodeAllocatable() error {
237237
}
238238

239239
if len(errors) > 0 {
240-
return fmt.Errorf("Invalid Node Allocatable configuration. %s", strings.Join(errors, " "))
240+
return fmt.Errorf("invalid Node Allocatable configuration. %s", strings.Join(errors, " "))
241241
}
242242
return nil
243243
}

pkg/kubelet/config/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ func (s *sourceURL) extractFromURL() error {
138138
}
139139

140140
return fmt.Errorf("%v: received '%v', but couldn't parse as "+
141-
"single (%v) or multiple pods (%v).\n",
141+
"single (%v) or multiple pods (%v)",
142142
s.url, string(data), singlePodErr, multiPodErr)
143143
}

pkg/kubelet/container/sync_result.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ func (p *PodSyncResult) Fail(err error) {
116116
func (p *PodSyncResult) Error() error {
117117
errlist := []error{}
118118
if p.SyncError != nil {
119-
errlist = append(errlist, fmt.Errorf("failed to SyncPod: %v\n", p.SyncError))
119+
errlist = append(errlist, fmt.Errorf("failed to SyncPod: %v", p.SyncError))
120120
}
121121
for _, result := range p.SyncResults {
122122
if result.Error != nil {
123-
errlist = append(errlist, fmt.Errorf("failed to %q for %q with %v: %q\n", result.Action, result.Target,
123+
errlist = append(errlist, fmt.Errorf("failed to %q for %q with %v: %q", result.Action, result.Target,
124124
result.Error, result.Message))
125125
}
126126
}

0 commit comments

Comments
 (0)