feat(ui): enhance workflow logs display
This commit is contained in:
@@ -8,8 +8,9 @@ type WorkflowLog struct {
|
||||
Meta
|
||||
WorkflowId string `json:"workflowId" db:"workflowId"`
|
||||
RunId string `json:"workflorunIdwId" db:"runId"`
|
||||
NodeId string `json:"nodeId"`
|
||||
NodeName string `json:"nodeName"`
|
||||
NodeId string `json:"nodeId" db:"nodeId"`
|
||||
NodeName string `json:"nodeName" db:"nodeName"`
|
||||
Timestamp int64 `json:"timestamp" db:"timestamp"` // 毫秒级时间戳
|
||||
Level string `json:"level" db:"level"`
|
||||
Message string `json:"message" db:"message"`
|
||||
Data map[string]any `json:"data" db:"data"`
|
||||
|
||||
@@ -90,14 +90,6 @@ func (d *DeployerProvider) WithLogger(logger *slog.Logger) deployer.Deployer {
|
||||
}
|
||||
|
||||
func (d *DeployerProvider) Deploy(ctx context.Context, certPem string, privkeyPem string) (*deployer.DeployResult, error) {
|
||||
// 上传证书到 SCM
|
||||
upres, err := d.sslUploader.Upload(ctx, certPem, privkeyPem)
|
||||
if err != nil {
|
||||
return nil, xerrors.Wrap(err, "failed to upload certificate file")
|
||||
} else {
|
||||
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
|
||||
}
|
||||
|
||||
// 根据部署资源类型决定部署方式
|
||||
switch d.config.ResourceType {
|
||||
case RESOURCE_TYPE_CERTIFICATE:
|
||||
|
||||
@@ -22,7 +22,7 @@ func (r *WorkflowLogRepository) ListByWorkflowRunId(ctx context.Context, workflo
|
||||
records, err := app.GetApp().FindRecordsByFilter(
|
||||
domain.CollectionNameWorkflowLog,
|
||||
"runId={:runId}",
|
||||
"-created",
|
||||
"timestamp",
|
||||
0, 0,
|
||||
dbx.Params{"runId": workflowRunId},
|
||||
)
|
||||
@@ -66,6 +66,7 @@ func (r *WorkflowLogRepository) Save(ctx context.Context, workflowLog *domain.Wo
|
||||
record.Set("runId", workflowLog.RunId)
|
||||
record.Set("nodeId", workflowLog.NodeId)
|
||||
record.Set("nodeName", workflowLog.NodeName)
|
||||
record.Set("timestamp", workflowLog.Timestamp)
|
||||
record.Set("level", workflowLog.Level)
|
||||
record.Set("message", workflowLog.Message)
|
||||
record.Set("data", workflowLog.Data)
|
||||
@@ -102,6 +103,7 @@ func (r *WorkflowLogRepository) castRecordToModel(record *core.Record) (*domain.
|
||||
RunId: record.GetString("runId"),
|
||||
NodeId: record.GetString("nodeId"),
|
||||
NodeName: record.GetString("nodeName"),
|
||||
Timestamp: int64(record.GetInt("timestamp")),
|
||||
Level: record.GetString("level"),
|
||||
Message: record.GetString("message"),
|
||||
Data: logdata,
|
||||
|
||||
@@ -80,6 +80,7 @@ func (w *workflowInvoker) processNode(ctx context.Context, node *domain.Workflow
|
||||
log.RunId = w.runId
|
||||
log.NodeId = current.Id
|
||||
log.NodeName = current.Name
|
||||
log.Timestamp = record.Time.UnixMilli()
|
||||
log.Level = record.Level.String()
|
||||
log.Message = record.Message
|
||||
log.Data = record.Data
|
||||
|
||||
@@ -42,7 +42,7 @@ func (n *applyNode) Process(ctx context.Context) error {
|
||||
|
||||
// 检测是否可以跳过本次执行
|
||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||
n.logger.Warn(fmt.Sprintf("skip this application, because %s", skipReason))
|
||||
n.logger.Info(fmt.Sprintf("skip this application, because %s", skipReason))
|
||||
return nil
|
||||
} else if skipReason != "" {
|
||||
n.logger.Info(fmt.Sprintf("continue to apply, because %s", skipReason))
|
||||
@@ -124,7 +124,7 @@ func (n *applyNode) checkCanSkip(ctx context.Context, lastOutput *domain.Workflo
|
||||
renewalInterval := time.Duration(currentNodeConfig.SkipBeforeExpiryDays) * time.Hour * 24
|
||||
expirationTime := time.Until(lastCertificate.ExpireAt)
|
||||
if expirationTime > renewalInterval {
|
||||
return true, fmt.Sprintf("the certificate has already been issued (expires in %dD, next renewal in %dD)", int(expirationTime.Hours()/24), currentNodeConfig.SkipBeforeExpiryDays)
|
||||
return true, fmt.Sprintf("the certificate has already been issued (expires in %dd, next renewal in %dd)", int(expirationTime.Hours()/24), currentNodeConfig.SkipBeforeExpiryDays)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (n *deployNode) Process(ctx context.Context) error {
|
||||
// 检测是否可以跳过本次执行
|
||||
if lastOutput != nil && certificate.CreatedAt.Before(lastOutput.UpdatedAt) {
|
||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||
n.logger.Warn(fmt.Sprintf("skip this deployment, because %s", skipReason))
|
||||
n.logger.Info(fmt.Sprintf("skip this deployment, because %s", skipReason))
|
||||
return nil
|
||||
} else if skipReason != "" {
|
||||
n.logger.Info(fmt.Sprintf("continue to deploy, because %s", skipReason))
|
||||
|
||||
@@ -40,7 +40,7 @@ func (n *uploadNode) Process(ctx context.Context) error {
|
||||
|
||||
// 检测是否可以跳过本次执行
|
||||
if skippable, skipReason := n.checkCanSkip(ctx, lastOutput); skippable {
|
||||
n.logger.Warn(fmt.Sprintf("skip this upload, because %s", skipReason))
|
||||
n.logger.Info(fmt.Sprintf("skip this upload, because %s", skipReason))
|
||||
return nil
|
||||
} else if skipReason != "" {
|
||||
n.logger.Info(fmt.Sprintf("continue to upload, because %s", skipReason))
|
||||
|
||||
Reference in New Issue
Block a user