fix lint issues

Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
This commit is contained in:
RainbowMango 2024-04-28 21:22:01 +08:00
parent 8cf31bfc37
commit d4b610cad6
10 changed files with 15 additions and 15 deletions

View File

@ -210,7 +210,7 @@ func (data *initData) KarmadaClient() clientset.Interface {
data.Once.Do(func() {
client, err := clientset.NewForConfig(data.controlplaneConfig)
if err != nil {
klog.Errorf("error when init karmada client, err: %w", err)
klog.Errorf("error when init karmada client, err: %v", err)
}
data.karmadaClient = client
})

View File

@ -180,7 +180,7 @@ func (c *CronFHPAController) updateRuleHistory(cronFHPA *autoscalingv1alpha1.Cro
if err := c.Client.Status().Update(context.Background(), cronFHPA); err != nil {
klog.Errorf("Fail to update CronFederatedHPA(%s/%s) rule(%s)'s next execution time:%v",
cronFHPA.Namespace, cronFHPA.Name, err)
cronFHPA.Namespace, cronFHPA.Name, rule.Name, err)
return err
}

View File

@ -232,7 +232,7 @@ func (c *Controller) tryCreateOrUpdateWorkload(clusterName string, workload *uns
clusterObj, err := helper.GetObjectFromCache(c.RESTMapper, c.InformerManager, fedKey)
if err != nil {
if !apierrors.IsNotFound(err) {
klog.Errorf("Failed to get the resource(kind=%s, %s/%s) from member cluster(%s), err is %v ", workload.GetKind(), workload.GetNamespace(), workload.GetName(), err)
klog.Errorf("Failed to get the resource(kind=%s, %s/%s) from member cluster(%s), err is %v ", workload.GetKind(), workload.GetNamespace(), workload.GetName(), clusterName, err)
return err
}
err = c.ObjectWatcher.Create(clusterName, workload)

View File

@ -138,7 +138,7 @@ func updateResourceStatus(
_, err = dynamicClient.Resource(gvr).Namespace(resource.GetNamespace()).
Patch(context.TODO(), resource.GetName(), types.JSONPatchType, patchBytes, metav1.PatchOptions{}, "status")
if err != nil {
klog.Error("Failed to update resource(%s/%s/%s), Error: %v", gvr, resource.GetNamespace(), resource.GetName(), err)
klog.Errorf("Failed to update resource(%s/%s/%s), Error: %v", gvr, resource.GetNamespace(), resource.GetName(), err)
return err
}
klog.V(3).Infof("Update resource(%s/%s/%s) status successfully.", gvr, resource.GetNamespace(), resource.GetName())

View File

@ -354,7 +354,7 @@ func (c *WorkStatusController) updateAppliedCondition(work *workv1alpha1.Work, s
func (c *WorkStatusController) reflectStatus(work *workv1alpha1.Work, clusterObj *unstructured.Unstructured) error {
statusRaw, err := c.ResourceInterpreter.ReflectStatus(clusterObj)
if err != nil {
klog.Errorf("Failed to reflect status for object(%s/%s/%s) with resourceInterpreter.",
klog.Errorf("Failed to reflect status for object(%s/%s/%s) with resourceInterpreter, err: %v",
clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName(), err)
c.EventRecorder.Eventf(work, corev1.EventTypeWarning, events.EventReasonReflectStatusFailed, "Reflect status for object(%s/%s/%s) failed, err: %s.", clusterObj.GetKind(), clusterObj.GetNamespace(), clusterObj.GetName(), err.Error())
return err

View File

@ -162,8 +162,8 @@ func (j *CommandUnjoinOption) Run(f cmdutil.Factory) error {
// Get control plane kube-apiserver client
controlPlaneRestConfig, err := f.ToRawKubeConfigLoader().ClientConfig()
if err != nil {
klog.Errorf("failed to get control plane rest config. context: %s, kube-config: %s, error: %v",
options.DefaultConfigFlags.Context, options.DefaultConfigFlags.KubeConfig, err)
klog.Errorf("failed to get control plane rest config. karmada-context: %s, kubeconfig: %s, error: %v",
*options.DefaultConfigFlags.Context, *options.DefaultConfigFlags.KubeConfig, err)
return err
}

View File

@ -106,7 +106,7 @@ func (configManager *interpreterConfigManager) updateConfiguration() {
for index, c := range configurations {
config := &configv1alpha1.ResourceInterpreterCustomization{}
if err = helper.ConvertToTypedObject(c, config); err != nil {
klog.Errorf("Failed to transform ResourceInterpreterCustomization: %w", err)
klog.Errorf("Failed to transform ResourceInterpreterCustomization: %v", err)
return
}
configs[index] = config

View File

@ -103,7 +103,7 @@ func (m *interpreterConfigManager) updateConfiguration() {
for _, c := range configurations {
unstructuredConfig, err := helper.ToUnstructured(c)
if err != nil {
klog.Errorf("Failed to transform ResourceInterpreterWebhookConfiguration: %w", err)
klog.Errorf("Failed to transform ResourceInterpreterWebhookConfiguration: %v", err)
return
}

View File

@ -92,7 +92,7 @@ func reflectDeploymentStatus(object *unstructured.Unstructured) (*runtime.RawExt
func reflectServiceStatus(object *unstructured.Unstructured) (*runtime.RawExtension, error) {
serviceType, exist, err := unstructured.NestedString(object.Object, "spec", "type")
if err != nil {
klog.Errorf("Failed to get spec.type field from %s(%s/%s)")
klog.Errorf("Failed to get spec.type field from %s(%s/%s)", object.GetKind(), object.GetNamespace(), object.GetName())
}
if !exist {
klog.Errorf("Failed to get spec.type from %s(%s/%s) which should have spec.type field.",

View File

@ -47,7 +47,7 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var res Response
if r.Body == nil {
err = errors.New("request body is empty")
klog.Errorf("bad request: %w", err)
klog.Errorf("bad request: %v", err)
res = Errored(http.StatusBadRequest, err)
wh.writeResponse(w, res)
return
@ -55,7 +55,7 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
if body, err = io.ReadAll(io.LimitReader(r.Body, MaxRespBodyLength)); err != nil {
klog.Errorf("unable to read the body from the incoming request: %w", err)
klog.Errorf("unable to read the body from the incoming request: %v", err)
res = Errored(http.StatusBadRequest, err)
wh.writeResponse(w, res)
return
@ -64,7 +64,7 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// verify the content type is accurate
if contentType := r.Header.Get("Content-Type"); contentType != "application/json" {
err = fmt.Errorf("contentType=%s, expected application/json", contentType)
klog.Errorf("unable to process a request with an unknown content type: %w", err)
klog.Errorf("unable to process a request with an unknown content type: %v", err)
res = Errored(http.StatusBadRequest, err)
wh.writeResponse(w, res)
return
@ -76,7 +76,7 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
interpreterContext.Request = &request.ResourceInterpreterRequest
_, _, err = admissionCodecs.UniversalDeserializer().Decode(body, nil, &interpreterContext)
if err != nil {
klog.Errorf("unable to decode the request: %w", err)
klog.Errorf("unable to decode the request: %v", err)
res = Errored(http.StatusBadRequest, err)
wh.writeResponse(w, res)
return
@ -97,7 +97,7 @@ func (wh *Webhook) writeResponse(w io.Writer, response Response) {
// writeResourceInterpreterResponse writes ar to w.
func (wh *Webhook) writeResourceInterpreterResponse(w io.Writer, interpreterContext configv1alpha1.ResourceInterpreterContext) {
if err := json.NewEncoder(w).Encode(interpreterContext); err != nil {
klog.Errorf("unable to encode the response: %w", err)
klog.Errorf("unable to encode the response: %v", err)
wh.writeResponse(w, Errored(http.StatusInternalServerError, err))
} else {
response := interpreterContext.Response