Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type JobInfo struct {
StartTime int64 `bson:"start_time" json:"start_time"`
EndTime int64 `bson:"end_time" json:"end_time"`
Duration int64 `bson:"duration" json:"duration"`
// IsDebug marks if the job belongs to a debug workflow run.
IsDebug bool `bson:"is_debug" json:"is_debug"`
// ServiceType, ServiceName and ServiceModule are used exclusively for build & deploy jobs
ServiceType string `bson:"service_type" json:"service_type"`
ServiceName string `bson:"service_name" json:"service_name"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ type WorkflowTaskCtx struct {
WorkflowDisplayName string
ProjectName string
ProjectDisplayName string
IsDebug bool
TaskID int64
Remark string
RetryNum int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func runJob(ctx context.Context, job *commonmodels.JobTask, workflowCtx *commonm
logger.Infof("finish job: %s,status: %s", job.Name, job.Status)
setJobFinalStatusContext(job, workflowCtx)
ack()
if workflowCtx.IsDebug {
logger.Infof("skip updating debug job info into db")
return
}
logger.Infof("updating job info into db...")
err := jobCtl.SaveInfo(ctx)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func workLoadDeployStat(kubeClient client.Client, namespace string, labelMaps []
case "ImagePullBackOff", "ErrImagePull", "CrashLoopBackOff", "ErrImageNeverPull":
logContent := fmt.Sprintf("pod: %s, %s: %s", pod.Name, cs.State.Waiting.Reason, cs.State.Waiting.Message)
jobLogManager.SaveJobLog(logContent)
return fmt.Errorf(logContent)
return fmt.Errorf("%s", logContent)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,29 +492,29 @@ func (c *IstioReleaseJobCtl) Run(ctx context.Context) {
targetReplica := int32(c.jobTaskSpec.Replicas)
deployment.Spec.Replicas = &targetReplica

c.Infof("updating the original workload %s with the new image: %s", deployment.Name, c.jobTaskSpec.Targets.Image)
c.ack()
c.Infof("updating the original workload %s with the new image: %s", deployment.Name, c.jobTaskSpec.Targets.Image)
c.ack()

if err := updater.UpdateDeploymentV2(ctx, c.jobTaskSpec.ClusterID, c.jobTaskSpec.Namespace, deployment.Name, func(d *appsv1.Deployment) error {
var oldImg string
for i, container := range d.Spec.Template.Spec.Containers {
if container.Name == c.jobTaskSpec.Targets.ContainerName {
oldImg = container.Image
d.Spec.Template.Spec.Containers[i].Image = c.jobTaskSpec.Targets.Image
if err := updater.UpdateDeploymentV2(ctx, c.jobTaskSpec.ClusterID, c.jobTaskSpec.Namespace, deployment.Name, func(d *appsv1.Deployment) error {
var oldImg string
for i, container := range d.Spec.Template.Spec.Containers {
if container.Name == c.jobTaskSpec.Targets.ContainerName {
oldImg = container.Image
d.Spec.Template.Spec.Containers[i].Image = c.jobTaskSpec.Targets.Image
}
}
if d.Annotations == nil {
d.Annotations = make(map[string]string)
}
d.Annotations[config.ZadigLastAppliedReplicas] = strconv.Itoa(int(*d.Spec.Replicas))
d.Annotations[config.ZadigLastAppliedImage] = oldImg
targetReplica := int32(c.jobTaskSpec.Replicas)
d.Spec.Replicas = &targetReplica
return nil
}); err != nil {
c.Errorf("update origin deployment: %s failed: %v", deployment.Name, err)
return
}
if d.Annotations == nil {
d.Annotations = make(map[string]string)
}
d.Annotations[config.ZadigLastAppliedReplicas] = strconv.Itoa(int(*d.Spec.Replicas))
d.Annotations[config.ZadigLastAppliedImage] = oldImg
targetReplica := int32(c.jobTaskSpec.Replicas)
d.Spec.Replicas = &targetReplica
return nil
}); err != nil {
c.Errorf("update origin deployment: %s failed: %v", deployment.Name, err)
return
}
Comment thread
leebrouse marked this conversation as resolved.

// waiting for original deployment to run
c.Infof("Waiting for deployment: %s to start", c.jobTaskSpec.Targets.WorkloadName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (s *junitReportCtl) AfterRun(ctx context.Context) error {
if s.junitReportSpec.TestName == "" {
return nil
}
// 过滤掉debug tag任务
Comment thread
leebrouse marked this conversation as resolved.
if s.workflowCtx.IsDebug {
return nil
}
var testTaskStat *commonmodels.TestTaskStat
var isNew bool
testTaskStat, _ = commonrepo.NewTestTaskStatColl().FindTestTaskStat(&commonrepo.TestTaskStatOption{Name: s.junitReportSpec.TestName})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"time"

"github.com/google/uuid"
"github.com/koderover/zadig/v2/pkg/tool/clientmanager"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/rand"

config2 "github.com/koderover/zadig/v2/pkg/config"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/config"
commonmodels "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/repository/models"
Expand All @@ -41,6 +41,7 @@ import (
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/workflowstat"
"github.com/koderover/zadig/v2/pkg/setting"
"github.com/koderover/zadig/v2/pkg/tool/cache"
"github.com/koderover/zadig/v2/pkg/tool/clientmanager"
e "github.com/koderover/zadig/v2/pkg/tool/errors"
"github.com/koderover/zadig/v2/pkg/tool/kube/getter"
"github.com/koderover/zadig/v2/pkg/tool/kube/podexec"
Expand Down Expand Up @@ -231,6 +232,7 @@ func (c *workflowCtl) Run(ctx context.Context, concurrency int) {
WorkflowDisplayName: c.workflowTask.WorkflowDisplayName,
ProjectName: c.workflowTask.ProjectName,
ProjectDisplayName: c.workflowTask.ProjectDisplayName,
IsDebug: c.workflowTask.IsDebug,
Remark: c.workflowTask.Remark,
TaskID: c.workflowTask.TaskID,
RetryNum: c.workflowTask.RetryNum,
Expand Down
7 changes: 7 additions & 0 deletions pkg/microservice/aslan/core/stat/service/build_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ func getTaskDateMap(productName string, startTimestamp int64) (map[string][]inte
if err := v4Cursor.Decode(&workflowTask); err != nil {
return taskDateMap, fmt.Errorf("decode workflow v4 task err:%v", err)
}
if workflowTask.IsDebug {
continue
}
time := time.Unix(workflowTask.CreateTime, 0)
date := time.Format(config.Date)
if _, isExist := taskDateMap[date]; isExist {
Expand Down Expand Up @@ -349,6 +352,10 @@ func GetLatestTenBuildMeasure(productNames []string, log *zap.SugaredLogger) ([]
if err := cursor.Decode(&workflowTask); err != nil {
return nil, fmt.Errorf("decode workflow v4 task err:%v", err)
}
// 过滤掉debug tag任务
if workflowTask.IsDebug {
continue
}
containBuild := false
for _, stage := range workflowTask.Stages {
for _, job := range stage.Jobs {
Expand Down
3 changes: 3 additions & 0 deletions pkg/microservice/aslan/core/stat/service/test_stat_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func GetRecentTestTask(projects []string, number int, logger *zap.SugaredLogger)
// Build response
recentTasks := make([]*RecentTestTask, 0, len(workflowTasks))
for _, task := range workflowTasks {
if task.IsDebug {
continue
}
// Extract test name from workflow display name
testName := task.WorkflowDisplayName
if testName == "" && task.WorkflowArgs != nil {
Expand Down
Loading