diff --git a/cluster-autoscaler/Makefile b/cluster-autoscaler/Makefile index 4724c1e1456b..f55476ac7521 100644 --- a/cluster-autoscaler/Makefile +++ b/cluster-autoscaler/Makefile @@ -1,10 +1,7 @@ ALL_ARCH = amd64 arm64 s390x all: $(addprefix build-arch-,$(ALL_ARCH)) -# TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer. -# Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649 -# This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated. -GO_TEST_DEFAULT_ANALYZERS?=atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests +GO_TEST_DEFAULT_ANALYZERS?=atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests,printf TAG?=dev FLAGS= LDFLAGS?=-s @@ -58,7 +55,7 @@ test-build-tags: done test-unit: clean build - go test --test.short -race ./... -vet="${GO_TEST_DEFAULT_ANALYZERS}" ${TAGS_FLAG} + go test --test.short -race $$(go list ./... | grep -v vendor | grep -v sdk-go | grep -v go-sdk) -vet="${GO_TEST_DEFAULT_ANALYZERS}" ${TAGS_FLAG} dev-release: dev-release-arch-$(GOARCH) diff --git a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go index 6b7d1633309f..c3b303ca0c49 100644 --- a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go +++ b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go @@ -375,7 +375,7 @@ func (m *asgCache) DeleteInstances(instances []*AwsInstanceRef) error { if err != nil { return err } - klog.V(4).Infof(*resp.Activity.Description) + klog.V(4).Infof("%s", *resp.Activity.Description) // Proactively decrement the size so autoscaler makes better decisions commonAsg.curSize-- diff --git a/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/aws/session/shared_config.go b/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/aws/session/shared_config.go index 180713a0af2d..67056c8df7e6 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/aws/session/shared_config.go +++ b/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/aws/session/shared_config.go @@ -349,7 +349,7 @@ func (cfg *sharedConfig) setFromIniFiles(profiles map[string]struct{}, profile s if cfg.hasSSOTokenProviderConfiguration() { skippedFiles = 0 for _, f := range files { - section, ok := f.IniData.GetSection(fmt.Sprintf(ssoSectionPrefix + strings.TrimSpace(cfg.SSOSessionName))) + section, ok := f.IniData.GetSection(ssoSectionPrefix + strings.TrimSpace(cfg.SSOSessionName)) if ok { var ssoSession ssoSession ssoSession.setFromIniSection(section) diff --git a/cluster-autoscaler/cloudprovider/azure/azure_util.go b/cluster-autoscaler/cloudprovider/azure/azure_util.go index 8e90464de6b0..2d6b3c4a902a 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_util.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_util.go @@ -259,7 +259,7 @@ func normalizeForK8sVMASScalingUp(templateMap map[string]interface{}) error { if ok && resourceType == nsgResourceType { if nsgIndex != -1 { err := fmt.Errorf("found 2 resources with type %s in the template. There should only be 1", nsgResourceType) - klog.Errorf(err.Error()) + klog.Errorf("%s", err.Error()) return err } nsgIndex = index @@ -267,7 +267,7 @@ func normalizeForK8sVMASScalingUp(templateMap map[string]interface{}) error { if ok && resourceType == rtResourceType { if rtIndex != -1 { err := fmt.Errorf("found 2 resources with type %s in the template. There should only be 1", rtResourceType) - klog.Warningf(err.Error()) + klog.Warningf("%s", err.Error()) return err } rtIndex = index @@ -296,7 +296,7 @@ func normalizeForK8sVMASScalingUp(templateMap map[string]interface{}) error { indexesToRemove := []int{} if nsgIndex == -1 { err := fmt.Errorf("found no resources with type %s in the template. There should have been 1", nsgResourceType) - klog.Errorf(err.Error()) + klog.Errorf("%s", err.Error()) return err } if rtIndex == -1 { diff --git a/cluster-autoscaler/cloudprovider/baiducloud/baiducloud-sdk-go/util/util.go b/cluster-autoscaler/cloudprovider/baiducloud/baiducloud-sdk-go/util/util.go index 9ef032e50f71..0f6fed5468ee 100644 --- a/cluster-autoscaler/cloudprovider/baiducloud/baiducloud-sdk-go/util/util.go +++ b/cluster-autoscaler/cloudprovider/baiducloud/baiducloud-sdk-go/util/util.go @@ -566,7 +566,7 @@ func Debug(title, message string) { klog.V(5).Infof("----------------------------DEBUG: start of %s ----------------------------", title) } - klog.V(5).Infof(message) + klog.V(5).Infof("%s", message) if title != "" { klog.V(5).Infof("----------------------------DEBUG: end of %s------------------------------", title) diff --git a/cluster-autoscaler/cloudprovider/civo/civo-cloud-sdk-go/errors.go b/cluster-autoscaler/cloudprovider/civo/civo-cloud-sdk-go/errors.go index 0bcd9553ef83..f28b2a580a18 100644 --- a/cluster-autoscaler/cloudprovider/civo/civo-cloud-sdk-go/errors.go +++ b/cluster-autoscaler/cloudprovider/civo/civo-cloud-sdk-go/errors.go @@ -1072,7 +1072,7 @@ func decodeError(err error) error { err := errors.New(msg.String()) return KubernetesClusterInvalidNameError.wrap(err) default: - err := fmt.Errorf(fmt.Sprintf("Unknown error response - status: %s, code: %d, reason: %s", errorData.Status, errorData.Code, errorData.Reason)) + err := fmt.Errorf("Unknown error response - status: %s, code: %d, reason: %s", errorData.Status, errorData.Code, errorData.Reason) return CommonError.wrap(err) } } diff --git a/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr/types.go b/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr/types.go index 29b569a84651..ec5cd955a3af 100644 --- a/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr/types.go +++ b/cluster-autoscaler/cloudprovider/huaweicloud/huaweicloud-sdk-go-v3/core/sdkerr/types.go @@ -133,5 +133,5 @@ func (sr ServiceResponseError) Error() string { if err != nil { return fmt.Sprintf("{\"ErrorMessage\": \"%s\",\"ErrorCode\": \"%s\"}", sr.ErrorMessage, sr.ErrorCode) } - return fmt.Sprintf(string(data)) + return string(data) } diff --git a/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_cache.go b/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_cache.go index 72bf533879dc..ee1f5e76ac74 100644 --- a/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_cache.go +++ b/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_cache.go @@ -213,7 +213,7 @@ func (c *instancePoolCache) findInstanceByDetails(ociInstance ocicommon.OciRef) if c.unownedInstances[ociInstance] { // We already know this instance is not part of a configured pool. Return early and avoid additional API calls. - klog.V(4).Infof("Node " + ociInstance.Name + " is known to not be a member of any of the specified instance pool(s)") + klog.V(4).Infof("Node %s is known to not be a member of any of the specified instance pool(s)", ociInstance.Name) return nil, errInstanceInstancePoolNotFound } @@ -307,7 +307,7 @@ func (c *instancePoolCache) findInstanceByDetails(ociInstance ocicommon.OciRef) } c.unownedInstances[ociInstance] = true - klog.V(4).Infof(ociInstance.Name + " is not a member of any of the specified instance pool(s)") + klog.V(4).Infof("%s is not a member of any of the specified instance pool(s)", ociInstance.Name) return nil, errInstanceInstancePoolNotFound } diff --git a/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_manager.go b/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_manager.go index 6aa36f0509e0..ae0839c26225 100644 --- a/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_manager.go +++ b/cluster-autoscaler/cloudprovider/oci/instancepools/oci_instance_pool_manager.go @@ -6,12 +6,13 @@ package instancepools import ( "fmt" - npconsts "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/nodepools/consts" "os" "strconv" "strings" "time" + npconsts "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/nodepools/consts" + ocicommon "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/common" "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/instancepools/consts" @@ -310,8 +311,7 @@ func (m *InstancePoolManagerImpl) GetInstancePoolNodes(ip InstancePoolNodeGroup) func (m *InstancePoolManagerImpl) GetInstancePoolForInstance(instanceDetails ocicommon.OciRef) (*InstancePoolNodeGroup, error) { if m.cfg.Global.UseNonMemberAnnotation && instanceDetails.InstancePoolID == consts.OciInstancePoolIDNonPoolMember { // Instance is not part of a configured pool. Return early and avoid additional API calls. - klog.V(4).Infof(instanceDetails.Name + " is not a member of any of the specified instance pool(s) and already annotated as " + - consts.OciInstancePoolIDNonPoolMember) + klog.V(4).Infof("%s is not a member of any of the specified instance pool(s) and already annotated as %s", instanceDetails.Name, consts.OciInstancePoolIDNonPoolMember) return nil, errInstanceInstancePoolNotFound } diff --git a/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/credentials/sts_provider.go b/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/credentials/sts_provider.go index c4904c40414f..1c90bbf1d281 100644 --- a/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/credentials/sts_provider.go +++ b/cluster-autoscaler/cloudprovider/volcengine/volcengine-go-sdk/volcengine/credentials/sts_provider.go @@ -62,7 +62,7 @@ func (s *StsProvider) Retrieve() (Value, error) { if _err != nil { return Value{}, _err } - return Value{}, fmt.Errorf(string(bb)) + return Value{}, fmt.Errorf("%s", string(bb)) } return Value{}, err }