Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: relate task with parent app on create job #444

Merged
merged 1 commit into from
Apr 29, 2024
Merged
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
7 changes: 5 additions & 2 deletions internal/repository/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type IAppServeAppRepository interface {

IsAppServeAppExist(ctx context.Context, appId string) (int64, error)
IsAppServeAppNameExist(ctx context.Context, orgId string, appName string) (int64, error)
CreateTask(ctx context.Context, task *model.AppServeAppTask) (taskId string, err error)
CreateTask(ctx context.Context, task *model.AppServeAppTask, appId string) (taskId string, err error)
UpdateStatus(ctx context.Context, appId string, taskId string, status string, output string) error
UpdateEndpoint(ctx context.Context, appId string, taskId string, endpoint string, previewEndpoint string, helmRevision int32) error
GetTaskCountById(ctx context.Context, appId string) (int64, error)
Expand All @@ -53,8 +53,11 @@ func (r *AppServeAppRepository) CreateAppServeApp(ctx context.Context, app *mode
}

// Update creates new appServeApp task for existing appServeApp.
func (r *AppServeAppRepository) CreateTask(ctx context.Context, task *model.AppServeAppTask) (string, error) {
func (r *AppServeAppRepository) CreateTask(ctx context.Context, task *model.AppServeAppTask, appId string) (string, error) {
task.ID = uuid.New().String()
if len(appId) > 0 {
task.AppServeAppId = appId
}
res := r.db.WithContext(ctx).Create(task)
if res.Error != nil {
return "", res.Error
Expand Down
9 changes: 5 additions & 4 deletions internal/usecase/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (u *AppServeAppUsecase) CreateAppServeApp(ctx context.Context, app *model.A
return "", "", errors.Wrap(err, "Failed to create app.")
}

taskId, err := u.repo.CreateTask(ctx, task)
taskId, err := u.repo.CreateTask(ctx, task, appId)
if err != nil {
log.Error(ctx, err)
return "", "", errors.Wrap(err, "Failed to create task.")
Expand Down Expand Up @@ -395,7 +395,7 @@ func (u *AppServeAppUsecase) DeleteAppServeApp(ctx context.Context, appId string
CreatedAt: time.Now(),
}

taskId, err := u.repo.CreateTask(ctx, appTask)
taskId, err := u.repo.CreateTask(ctx, appTask, "")
if err != nil {
log.Error(ctx, "taskId = ", taskId)
log.Error(ctx, "Failed to create delete task. Err:", err)
Expand Down Expand Up @@ -503,7 +503,8 @@ func (u *AppServeAppUsecase) UpdateAppServeApp(ctx context.Context, appId string
log.Debug(ctx, "After transform, extraEnv: ", extEnv)
}

taskId, err := u.repo.CreateTask(ctx, appTask)
// TODO: Check if appId is necessary here.
taskId, err := u.repo.CreateTask(ctx, appTask, appId)
if err != nil {
log.Info(ctx, "taskId = ", taskId)
return "", fmt.Errorf("failed to update app-serve application. Err: %s", err)
Expand Down Expand Up @@ -728,7 +729,7 @@ func (u *AppServeAppUsecase) RollbackAppServeApp(ctx context.Context, appId stri
task.RollbackVersion = targetVer

// Creates new task record from the target task
newTaskId, err := u.repo.CreateTask(ctx, task)
newTaskId, err := u.repo.CreateTask(ctx, task, "")
if err != nil {
log.Info(ctx, "taskId = ", newTaskId)
return "", fmt.Errorf("failed to rollback app-serve application. Err: %s", err)
Expand Down
Loading