diff --git a/cmd/fetcherfs/main.go b/cmd/fetcherfs/main.go index 08abfa7ec2..b3ff8b1116 100644 --- a/cmd/fetcherfs/main.go +++ b/cmd/fetcherfs/main.go @@ -44,7 +44,7 @@ func main() { err = fs.Serve(c, *fetcherFs) if err != nil { - log.Errorln("serve failed %s", err) + log.Errorf("serve failed %s", err) } } diff --git a/pkg/compute/tasks/baremetal_delete_task.go b/pkg/compute/tasks/baremetal_delete_task.go index 4f9b0225d0..a21b446e09 100644 --- a/pkg/compute/tasks/baremetal_delete_task.go +++ b/pkg/compute/tasks/baremetal_delete_task.go @@ -60,7 +60,7 @@ func (self *BaremetalDeleteTask) OnInit(ctx context.Context, obj db.IStandaloneM func (self *BaremetalDeleteTask) OnDeleteBaremetalComplete(ctx context.Context, baremetal *models.SHost, body jsonutils.JSONObject) { err := baremetal.RealDelete(ctx, self.UserCred) if err != nil { - log.Errorln("RealDelete fail %s", err) + log.Errorf("RealDelete fail %s", err) self.OnFailure(ctx, baremetal, jsonutils.Marshal(err)) return } diff --git a/pkg/hostman/guestman/guesttasks.go b/pkg/hostman/guestman/guesttasks.go index 426603aa2a..02354f6560 100644 --- a/pkg/hostman/guestman/guesttasks.go +++ b/pkg/hostman/guestman/guesttasks.go @@ -1035,7 +1035,7 @@ func (s *SGuestSnapshotDeleteTask) onReloadBlkdevSucc(err string) { func (s *SGuestSnapshotDeleteTask) onSnapshotBlkdevFail(res string) { snapshotPath := path.Join(s.disk.GetSnapshotDir(), s.convertSnapshot) if output, err := procutils.NewCommand("mv", "-f", s.tmpPath, snapshotPath).Output(); err != nil { - log.Errorln("mv %s to %s failed: %s, %s", s.tmpPath, snapshotPath, err, output) + log.Errorf("mv %s to %s failed: %s, %s", s.tmpPath, snapshotPath, err, output) } s.taskFailed("Reload blkdev failed") } diff --git a/pkg/hostman/storageman/disk_local.go b/pkg/hostman/storageman/disk_local.go index 5ec79b285d..1dcd51d1c4 100644 --- a/pkg/hostman/storageman/disk_local.go +++ b/pkg/hostman/storageman/disk_local.go @@ -144,7 +144,7 @@ func (d *SLocalDisk) Resize(ctx context.Context, params interface{}) (jsonutils. sizeMb, _ := diskInfo.Int("size") disk, err := qemuimg.NewQemuImage(d.GetPath()) if err != nil { - log.Errorln(err) + log.Errorf("qemuimg.NewQemuImage %s fail: %s", d.GetPath(), err) return nil, err } if err := disk.Resize(int(sizeMb)); err != nil { @@ -163,15 +163,13 @@ func (d *SLocalDisk) Resize(ctx context.Context, params interface{}) (jsonutils. func (d *SLocalDisk) CreateFromImageFuse(ctx context.Context, url string, size int64) error { log.Infof("Create from image fuse %s", url) - var ( - localPath = d.Storage.GetFuseTmpPath() - mntPath = path.Join(d.Storage.GetFuseMountPath(), d.Id) - contentPath = path.Join(mntPath, "content") - newImg, err = qemuimg.NewQemuImage(d.getPath()) - ) + localPath := d.Storage.GetFuseTmpPath() + mntPath := path.Join(d.Storage.GetFuseMountPath(), d.Id) + contentPath := path.Join(mntPath, "content") + newImg, err := qemuimg.NewQemuImage(d.getPath()) if err != nil { - log.Errorln(err) + log.Errorf("qemuimg.NewQemuImage %s fail: %s", d.getPath(), err) return err } @@ -344,14 +342,14 @@ func (d *SLocalDisk) CreateSnapshot(snapshotId string) error { if !fileutils2.Exists(snapshotDir) { output, err := procutils.NewCommand("mkdir", "-p", snapshotDir).Output() if err != nil { - log.Errorln("mkdir %s failed: %s", snapshotDir, output) + log.Errorf("mkdir %s failed: %s", snapshotDir, output) return errors.Wrapf(err, "mkdir %s failed: %s", snapshotDir, output) } } snapshotPath := path.Join(snapshotDir, snapshotId) output, err := procutils.NewCommand("mv", "-f", d.getPath(), snapshotPath).Output() if err != nil { - log.Errorln("mv %s to %s failed %s", d.getPath(), snapshotPath, output) + log.Errorf("mv %s to %s failed %s", d.getPath(), snapshotPath, output) return errors.Wrapf(err, "mv %s to %s failed %s", d.getPath(), snapshotPath, output) } img, err := qemuimg.NewQemuImage(d.getPath()) diff --git a/pkg/keystone/driver/ldap/sync.go b/pkg/keystone/driver/ldap/sync.go index 878b85fe70..89a01c6242 100644 --- a/pkg/keystone/driver/ldap/sync.go +++ b/pkg/keystone/driver/ldap/sync.go @@ -181,7 +181,7 @@ func (self *SLDAPDriver) syncUsers(ctx context.Context, cli *ldaputils.SLDAPClie if err != nil { return nil, errors.Wrap(err, "searchLDAP") } - log.Debugf("syncUsers: ldapSearch entries: %s", entries) + log.Debugf("syncUsers: ldapSearch entries: %#v", entries) userIds := make([]string, 0) userIdMap := make(map[string]string) for i := range entries { diff --git a/pkg/monitor/models/alertdashboard.go b/pkg/monitor/models/alertdashboard.go index dcf5411904..4f8161c91b 100644 --- a/pkg/monitor/models/alertdashboard.go +++ b/pkg/monitor/models/alertdashboard.go @@ -101,12 +101,12 @@ func (man *SAlertDashBoardManager) ValidateCreateData( for _, query := range data.CommonMetricInputQuery.MetricQuery { if len(query.Comparator) != 0 { if !utils.IsInStringArray(getQueryEvalType(query.Comparator), validators.EvaluatorDefaultTypes) { - return data, httperrors.NewInputParameterError("the Comparator is illegal:", query.Comparator) + return data, httperrors.NewInputParameterError("the Comparator is illegal: %s", query.Comparator) } } if len(query.Reduce) != 0 { if _, ok := monitor.AlertReduceFunc[query.Reduce]; !ok { - return data, httperrors.NewInputParameterError("the reduce is illegal", query.Reduce) + return data, httperrors.NewInputParameterError("the reduce is illegal %s", query.Reduce) } } } @@ -249,12 +249,12 @@ func (dash *SAlertDashBoard) ValidateUpdateData( } if len(query.Comparator) != 0 { if !utils.IsInStringArray(getQueryEvalType(query.Comparator), validators.EvaluatorDefaultTypes) { - return data, httperrors.NewInputParameterError("the Comparator is illegal:", query.Comparator) + return data, httperrors.NewInputParameterError("the Comparator is illegal: %s", query.Comparator) } } if len(query.Reduce) != 0 { if _, ok := monitor.AlertReduceFunc[query.Reduce]; !ok { - return data, httperrors.NewInputParameterError("the reduce is illegal", query.Reduce) + return data, httperrors.NewInputParameterError("the reduce is illegal: %s", query.Reduce) } } } diff --git a/pkg/monitor/models/commonalert.go b/pkg/monitor/models/commonalert.go index 04e8f14bb1..c9628a4b2c 100644 --- a/pkg/monitor/models/commonalert.go +++ b/pkg/monitor/models/commonalert.go @@ -104,10 +104,10 @@ func (man *SCommonAlertManager) ValidateCreateData( } else { for _, query := range data.CommonMetricInputQuery.MetricQuery { if !utils.IsInStringArray(getQueryEvalType(query.Comparator), validators.EvaluatorDefaultTypes) { - return data, httperrors.NewInputParameterError("the Comparator is illegal:", query.Comparator) + return data, httperrors.NewInputParameterError("the Comparator is illegal: %s", query.Comparator) } if _, ok := monitor.AlertReduceFunc[query.Reduce]; !ok { - return data, httperrors.NewInputParameterError("the reduce is illegal", query.Reduce) + return data, httperrors.NewInputParameterError("the reduce is illegal: %s", query.Reduce) } if query.Threshold == 0 { return data, httperrors.NewInputParameterError("threshold is meaningless") @@ -669,10 +669,10 @@ func (alert *SCommonAlert) ValidateUpdateData( return data, errors.Wrap(err, "metric_query Unmarshal error") } if !utils.IsInStringArray(getQueryEvalType(query.Comparator), validators.EvaluatorDefaultTypes) { - return data, httperrors.NewInputParameterError("the Comparator is illegal:", query.Comparator) + return data, httperrors.NewInputParameterError("the Comparator is illegal: %s", query.Comparator) } if _, ok := monitor.AlertReduceFunc[query.Reduce]; !ok { - return data, httperrors.NewInputParameterError("the reduce is illegal", query.Reduce) + return data, httperrors.NewInputParameterError("the reduce is illegal: %s", query.Reduce) } if query.Threshold == 0 { return data, httperrors.NewInputParameterError("threshold is meaningless") diff --git a/pkg/monitor/models/suggestsysrule.go b/pkg/monitor/models/suggestsysrule.go index 2641b275f1..dcce5cd652 100644 --- a/pkg/monitor/models/suggestsysrule.go +++ b/pkg/monitor/models/suggestsysrule.go @@ -167,7 +167,7 @@ func (man *SSuggestSysRuleManager) ValidateCreateData( return data, err } } else if rule != nil { - return data, httperrors.NewDuplicateResourceError("type %s rule already exists") + return data, httperrors.NewDuplicateResourceError("type %s rule already exists", data.Type) } drvType := monitor.SuggestDriverType(data.Type)