Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: rename rolloutID to planID and cleanup comments (#18663)

Danny Xu908314486422
diff --git a/backend/api/v1/revision_service.go b/backend/api/v1/revision_service.go
index 0ff619fda3..e4515dcf0c 100644
--- a/backend/api/v1/revision_service.go
+++ b/backend/api/v1/revision_service.go
@@ -193,7 +193,7 @@ func (s *RevisionService) createRevisions(
var createdRevisions []*v1pb.Revision
for i, revision := range revisions {
if revision.TaskRun != "" {
- projectID, rolloutID, stageID, taskID, taskRunID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(revision.TaskRun)
+ projectID, planID, stageID, taskID, taskRunID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(revision.TaskRun)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get taskRun from %q", revision.TaskRun))
}
@@ -205,7 +205,7 @@ func (s *RevisionService) createRevisions(
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("taskRun %q not found", revision.TaskRun))
}
if taskRun.ProjectID != projectID ||
- taskRun.PlanUID != rolloutID ||
+ taskRun.PlanUID != planID ||
taskRun.Environment != formatEnvironmentFromStageID(stageID) ||
taskRun.TaskUID != taskID {
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("taskRun %q not found", revision.TaskRun))
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index c4f6b76e6a..01fe36fb23 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -51,7 +51,7 @@ func NewRolloutService(store *store.Store, dbFactory *dbfactory.DBFactory, state
// GetRollout gets a rollout.
func (s *RolloutService) GetRollout(ctx context.Context, req *connect.Request[v1pb.GetRolloutRequest]) (*connect.Response[v1pb.Rollout], error) {
request := req.Msg
- projectID, rolloutID, err := common.GetProjectIDRolloutID(request.Name)
+ projectID, planID, err := common.GetProjectIDPlanIDFromRolloutName(request.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -66,27 +66,27 @@ func (s *RolloutService) GetRollout(ctx context.Context, req *connect.Request[v1
}
// getRolloutWithTasks inlined
- rollout, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
+ plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get plan, error: %v", err))
}
- if rollout == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", rolloutID, projectID))
+ if plan == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", planID, projectID))
}
// Check if the plan has a rollout
- if rollout.Config == nil || !rollout.Config.HasRollout {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", rolloutID, projectID))
+ if plan.Config == nil || !plan.Config.HasRollout {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", planID, projectID))
}
- tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &rolloutID})
+ tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &planID})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get tasks, error: %v", err))
}
- rolloutV1, err := convertToRollout(ctx, s.store, project, rollout, tasks)
+ rolloutV1, err := convertToRollout(ctx, s.store, project, plan, tasks)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert to rollout, error: %v", err))
}
@@ -248,7 +248,7 @@ func (s *RolloutService) CreateRollout(ctx context.Context, req *connect.Request
// ListTaskRuns lists rollout task runs.
func (s *RolloutService) ListTaskRuns(ctx context.Context, req *connect.Request[v1pb.ListTaskRunsRequest]) (*connect.Response[v1pb.ListTaskRunsResponse], error) {
request := req.Msg
- projectID, rolloutID, maybeStageID, maybeTaskID, err := common.GetProjectIDRolloutIDMaybeStageIDMaybeTaskID(request.Parent)
+ projectID, planID, maybeStageID, maybeTaskID, err := common.GetProjectIDPlanIDMaybeStageIDMaybeTaskID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -264,17 +264,17 @@ func (s *RolloutService) ListTaskRuns(ctx context.Context, req *connect.Request[
}
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get rollout, error: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", rolloutID, projectID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", planID, projectID))
}
taskRuns, err := s.store.ListTaskRuns(ctx, &store.FindTaskRunMessage{
- PlanUID: &rolloutID,
+ PlanUID: &planID,
Environment: maybeStageID,
TaskUID: maybeTaskID,
})
@@ -394,31 +394,31 @@ func CreateRolloutAndPendingTasks(
// GetTaskRun gets a task run.
func (s *RolloutService) GetTaskRun(ctx context.Context, req *connect.Request[v1pb.GetTaskRunRequest]) (*connect.Response[v1pb.TaskRun], error) {
request := req.Msg
- projectID, rolloutID, _, _, taskRunUID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(request.Name)
+ projectID, planID, _, _, taskRunUID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(request.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get rollout, error: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", rolloutID, projectID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", planID, projectID))
}
taskRun, err := s.store.GetTaskRunV1(ctx, &store.FindTaskRunMessage{
UID: &taskRunUID,
- PlanUID: &rolloutID,
+ PlanUID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get task run, error: %v", err))
}
if taskRun == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("task run %d not found in rollout %d", taskRunUID, rolloutID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("task run %d not found in rollout %d", taskRunUID, planID))
}
taskRunV1, err := convertToTaskRun(ctx, s.store, s.stateCfg, taskRun)
@@ -430,7 +430,7 @@ func (s *RolloutService) GetTaskRun(ctx context.Context, req *connect.Request[v1
func (s *RolloutService) GetTaskRunLog(ctx context.Context, req *connect.Request[v1pb.GetTaskRunLogRequest]) (*connect.Response[v1pb.TaskRunLog], error) {
request := req.Msg
- _, _, _, _, taskRunUID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(request.Parent)
+ _, _, _, _, taskRunUID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get task run uid, error: %v", err))
}
@@ -443,7 +443,7 @@ func (s *RolloutService) GetTaskRunLog(ctx context.Context, req *connect.Request
func (s *RolloutService) GetTaskRunSession(ctx context.Context, req *connect.Request[v1pb.GetTaskRunSessionRequest]) (*connect.Response[v1pb.TaskRunSession], error) {
request := req.Msg
- _, _, _, taskUID, taskRunUID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(request.Parent)
+ _, _, _, taskUID, taskRunUID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get task run uid, error: %v", err))
}
@@ -582,7 +582,7 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
if len(request.Tasks) == 0 {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("The tasks in request cannot be empty"))
}
- projectID, rolloutID, _, err := common.GetProjectIDRolloutIDMaybeStageID(request.Parent)
+ projectID, planID, _, err := common.GetProjectIDPlanIDMaybeStageID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -596,22 +596,20 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %v not found", projectID))
}
- // Rollout ID is Plan ID
- // Verify plan exists instead of pipeline
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find plan for rollout, error: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", rolloutID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", planID))
}
issueN, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
- PlanUID: &rolloutID,
ProjectID: &projectID,
+ PlanUID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find issue, error: %v", err))
@@ -621,7 +619,7 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
taskEnvironments := map[string][]int{}
taskIDsToRunMap := map[int]bool{}
for _, task := range request.Tasks {
- _, _, stageID, taskID, err := common.GetProjectIDRolloutIDStageIDTaskID(task)
+ _, _, stageID, taskID, err := common.GetProjectIDPlanIDStageIDTaskID(task)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -641,7 +639,7 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
}
// Get all tasks in the same environment
- stageToRunTasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &rolloutID, Environment: &environmentToRun})
+ stageToRunTasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &planID, Environment: &environmentToRun})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to list tasks, error: %v", err))
}
@@ -719,7 +717,7 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
// BatchSkipTasks skips tasks in batch.
func (s *RolloutService) BatchSkipTasks(ctx context.Context, req *connect.Request[v1pb.BatchSkipTasksRequest]) (*connect.Response[v1pb.BatchSkipTasksResponse], error) {
request := req.Msg
- projectID, rolloutID, _, err := common.GetProjectIDRolloutIDMaybeStageID(request.Parent)
+ projectID, planID, _, err := common.GetProjectIDPlanIDMaybeStageID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -733,27 +731,26 @@ func (s *RolloutService) BatchSkipTasks(ctx context.Context, req *connect.Reques
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %v not found", projectID))
}
- // Rollout ID is Plan ID
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find plan for rollout, error: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", rolloutID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", planID))
}
issueN, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
- PlanUID: &rolloutID,
ProjectID: &projectID,
+ PlanUID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find issue, error: %v", err))
}
- tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &rolloutID})
+ tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &planID})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to list tasks, error: %v", err))
}
@@ -771,7 +768,7 @@ func (s *RolloutService) BatchSkipTasks(ctx context.Context, req *connect.Reques
var tasksToSkip []*store.TaskMessage
environmentSet := map[string]struct{}{}
for _, task := range request.Tasks {
- _, _, _, taskID, err := common.GetProjectIDRolloutIDStageIDTaskID(task)
+ _, _, _, taskID, err := common.GetProjectIDPlanIDStageIDTaskID(task)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -825,7 +822,7 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, req *connect.R
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("task runs cannot be empty"))
}
- projectID, rolloutID, stageID, _, err := common.GetProjectIDRolloutIDStageIDMaybeTaskID(request.Parent)
+ projectID, planID, stageID, _, err := common.GetProjectIDPlanIDStageIDMaybeTaskID(request.Parent)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -840,28 +837,27 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, req *connect.R
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %v not found", projectID))
}
- // Rollout ID is Plan ID
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find plan for rollout, error: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", rolloutID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout (plan) %v not found", planID))
}
issueN, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
- PlanUID: &rolloutID,
ProjectID: &projectID,
+ PlanUID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find issue, error: %v", err))
}
for _, taskRun := range request.TaskRuns {
- _, _, taskRunStageID, _, _, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(taskRun)
+ _, _, taskRunStageID, _, _, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(taskRun)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -886,7 +882,7 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, req *connect.R
var taskRunIDs []int
for _, taskRun := range request.TaskRuns {
- _, _, _, _, taskRunID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(taskRun)
+ _, _, _, _, taskRunID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(taskRun)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
@@ -937,7 +933,7 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, req *connect.R
func (s *RolloutService) PreviewTaskRunRollback(ctx context.Context, req *connect.Request[v1pb.PreviewTaskRunRollbackRequest]) (*connect.Response[v1pb.PreviewTaskRunRollbackResponse], error) {
request := req.Msg
- _, _, _, taskUID, taskRunUID, err := common.GetProjectIDRolloutIDStageIDTaskIDTaskRunID(request.Name)
+ _, _, _, taskUID, taskRunUID, err := common.GetProjectIDPlanIDStageIDTaskIDTaskRunID(request.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get task run uid, error: %v", err))
}
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index cc10ebc30c..d796d4972f 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -870,27 +870,27 @@ func (s *SQLService) Export(ctx context.Context, req *connect.Request[v1pb.Expor
func (s *SQLService) doExportFromIssue(ctx context.Context, requestName string) (*v1pb.ExportResponse, error) {
// Try to parse as rollout name first (more specific), then fallback to stage name
- var rolloutID int64
+ var planID int64
var projectID string
var err error
- projectID, rolloutID, err = common.GetProjectIDRolloutID(requestName)
+ projectID, planID, err = common.GetProjectIDPlanIDFromRolloutName(requestName)
if err != nil {
// If rollout parsing fails, try parsing as stage name
- projectID, rolloutID, _, err = common.GetProjectIDRolloutIDMaybeStageID(requestName)
+ projectID, planID, _, err = common.GetProjectIDPlanIDMaybeStageID(requestName)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to parse request name as rollout or stage: %v", err))
}
}
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{
- UID: &rolloutID,
ProjectID: &projectID,
+ UID: &planID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get rollout: %v", err))
}
if plan == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", rolloutID, projectID))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("rollout %d not found in project %s", planID, projectID))
}
tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &plan.UID})
diff --git a/backend/common/resource_name.go b/backend/common/resource_name.go
index e4fdb65999..4d80c2f387 100644
--- a/backend/common/resource_name.go
+++ b/backend/common/resource_name.go
@@ -255,8 +255,8 @@ func GetProjectIDPlanIDFromPlanCheckRun(name string) (string, int64, error) {
return projectID, int64(planID), nil
}
-// GetProjectIDRolloutID returns the project ID and rollout ID (which is plan ID) from a resource name.
-func GetProjectIDRolloutID(name string) (string, int64, error) {
+// GetProjectIDPlanIDFromRolloutName returns the project ID and plan ID from a resource name.
+func GetProjectIDPlanIDFromRolloutName(name string) (string, int64, error) {
if !strings.HasSuffix(name, "/rollout") {
return "", 0, errors.Errorf("invalid rollout name %q, expected suffix /rollout", name)
}
@@ -264,8 +264,8 @@ func GetProjectIDRolloutID(name string) (string, int64, error) {
return GetProjectIDPlanID(planName)
}
-// GetProjectIDRolloutIDMaybeStageID returns the project ID, rollout ID, and maybe stage ID from a resource name.
-func GetProjectIDRolloutIDMaybeStageID(name string) (string, int64, *string, error) {
+// GetProjectIDPlanIDMaybeStageID returns the project ID, plan ID, and maybe stage ID from a resource name.
+func GetProjectIDPlanIDMaybeStageID(name string) (string, int64, *string, error) {
parts := strings.Split(name, "/rollout")
if len(parts) != 2 {
return "", 0, nil, errors.Errorf("invalid rollout stage name %q", name)
@@ -289,8 +289,8 @@ func GetProjectIDRolloutIDMaybeStageID(name string) (string, int64, *string, err
return projectID, planID, maybeStageID, nil
}
-// GetProjectIDRolloutIDStageIDMaybeTaskID returns the project ID, rollout ID, and maybe stage ID and maybe task ID from a resource name.
-func GetProjectIDRolloutIDStageIDMaybeTaskID(name string) (string, int64, string, *int, error) {
+// GetProjectIDPlanIDStageIDMaybeTaskID returns the project ID, plan ID, and maybe stage ID and maybe task ID from a resource name.
+func GetProjectIDPlanIDStageIDMaybeTaskID(name string) (string, int64, string, *int, error) {
parts := strings.Split(name, "/rollout")
if len(parts) != 2 {
return "", 0, "", nil, errors.Errorf("invalid rollout task name %q", name)
@@ -319,8 +319,8 @@ func GetProjectIDRolloutIDStageIDMaybeTaskID(name string) (string, int64, string
return projectID, planID, stageID, maybeTaskID, nil
}
-// GetProjectIDRolloutIDMaybeStageIDMaybeTaskID returns the project ID, rollout ID, and maybe stage ID and maybe task ID from a resource name.
-func GetProjectIDRolloutIDMaybeStageIDMaybeTaskID(name string) (string, int64, *string, *int, error) {
+// GetProjectIDPlanIDMaybeStageIDMaybeTaskID returns the project ID, plan ID, and maybe stage ID and maybe task ID from a resource name.
+func GetProjectIDPlanIDMaybeStageIDMaybeTaskID(name string) (string, int64, *string, *int, error) {
parts := strings.Split(name, "/rollout")
if len(parts) != 2 {
return "", 0, nil, nil, errors.Errorf("invalid rollout task name %q", name)
@@ -352,8 +352,8 @@ func GetProjectIDRolloutIDMaybeStageIDMaybeTaskID(name string) (string, int64, *
return projectID, planID, maybeStageID, maybeTaskID, nil
}
-// GetProjectIDRolloutIDStageIDTaskID returns the project ID, rollout ID, stage ID, and task ID from a resource name.
-func GetProjectIDRolloutIDStageIDTaskID(name string) (string, int64, string, int, error) {
+// GetProjectIDPlanIDStageIDTaskID returns the project ID, plan ID, stage ID, and task ID from a resource name.
+func GetProjectIDPlanIDStageIDTaskID(name string) (string, int64, string, int, error) {
parts := strings.Split(name, "/rollout")
if len(parts) != 2 {
return "", 0, "", 0, errors.Errorf("invalid rollout task name %q", name)
@@ -378,8 +378,8 @@ func GetProjectIDRolloutIDStageIDTaskID(name string) (string, int64, string, int
return projectID, planID, stageID, taskID, nil
}
-// GetProjectIDRolloutIDStageIDTaskIDTaskRunID returns the project ID, rollout ID, stage ID, task ID and task run ID from a resource name.
-func GetProjectIDRolloutIDStageIDTaskIDTaskRunID(name string) (string, int64, string, int, int, error) {
+// GetProjectIDPlanIDStageIDTaskIDTaskRunID returns the project ID, plan ID, stage ID, task ID and task run ID from a resource name.
+func GetProjectIDPlanIDStageIDTaskIDTaskRunID(name string) (string, int64, string, int, int, error) {
parts := strings.Split(name, "/rollout")
if len(parts) != 2 {
return "", 0, "", 0, 0, errors.Errorf("invalid rollout task run name %q", name)
diff --git a/backend/runner/taskrun/running_scheduler.go b/backend/runner/taskrun/running_scheduler.go
index 68e751ad8b..6f6db6ea4b 100644
--- a/backend/runner/taskrun/running_scheduler.go
+++ b/backend/runner/taskrun/running_scheduler.go
@@ -155,12 +155,12 @@ func (s *Scheduler) scheduleRunningTaskRun(ctx context.Context, taskRun *store.T
return errors.Errorf("project %v not found", plan.ProjectID)
}
- rolloutID := strconv.FormatInt(plan.UID, 10)
+ planID := strconv.FormatInt(plan.UID, 10)
maxRunningTaskRunsPerRollout := int(project.Setting.GetParallelTasksPerRollout())
if maxRunningTaskRunsPerRollout <= 0 {
maxRunningTaskRunsPerRollout = defaultRolloutMaxRunningTaskRuns
}
- if s.stateCfg.RolloutOutstandingTasks.Increment(rolloutID+"/"+task.InstanceID, maxRunningTaskRunsPerRollout) {
+ if s.stateCfg.RolloutOutstandingTasks.Increment(planID+"/"+task.InstanceID, maxRunningTaskRunsPerRollout) {
s.stateCfg.TaskRunSchedulerInfo.Store(taskRun.ID, &storepb.SchedulerInfo{
ReportTime: timestamppb.Now(),
WaitingCause: &storepb.SchedulerInfo_WaitingCause{
@@ -176,7 +176,7 @@ func (s *Scheduler) scheduleRunningTaskRun(ctx context.Context, taskRun *store.T
revertRolloutConnectionsIncrement := true
defer func() {
if revertRolloutConnectionsIncrement {
- s.stateCfg.RolloutOutstandingTasks.Decrement(rolloutID + "/" + task.InstanceID)
+ s.stateCfg.RolloutOutstandingTasks.Decrement(planID + "/" + task.InstanceID)
}
}()
diff --git a/frontend/src/components/AuditLog/AuditLogDataTable.vue b/frontend/src/components/AuditLog/AuditLogDataTable.vue
index 28b584caf8..fc8982767a 100644
--- a/frontend/src/components/AuditLog/AuditLogDataTable.vue
+++ b/frontend/src/components/AuditLog/AuditLogDataTable.vue
@@ -22,7 +22,7 @@ import { ProjectV1Name } from "@/components/v2";
import { UserLink } from "@/components/v2/Model/cells";
import {
extractUserId,
- getProjectIdRolloutUidStageUid,
+ getProjectIdPlanUidStageUidFromRolloutName,
projectNamePrefix,
rolloutNamePrefix,
} from "@/store/modules/v1/common";
@@ -256,11 +256,12 @@ const getViewLink = (auditLog: AuditLog): string | null => {
if (!name) {
return null;
}
- const [projectId, rolloutId, _] = getProjectIdRolloutUidStageUid(name);
- if (!projectId || !rolloutId) {
+ const [projectId, planId, _] =
+ getProjectIdPlanUidStageUidFromRolloutName(name);
+ if (!projectId || !planId) {
return null;
}
- return `${projectNamePrefix}${projectId}/${rolloutNamePrefix}${rolloutId}`;
+ return `${projectNamePrefix}${projectId}/${rolloutNamePrefix}${planId}`;
}
}
return null;
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
index 4693e253cc..64cb20e842 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/TaskName.vue
@@ -31,9 +31,10 @@ import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
import {
databaseForTask,
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractSchemaVersionFromTask,
+ extractStageNameFromTaskName,
extractStageUID,
extractTaskUID,
issueV1Slug,
@@ -58,8 +59,8 @@ const link = computed(() => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
params: {
projectId: extractProjectResourceName(task.name),
- rolloutId: extractRolloutUID(task.name),
- stageId: extractStageUID(task.name),
+ planId: extractPlanUIDFromRolloutName(task.name),
+ stageId: extractStageUID(extractStageNameFromTaskName(task.name)),
taskId: extractTaskUID(task.name),
},
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index 901ab66848..7f183f92a7 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -88,7 +88,10 @@ import {
CreateRolloutRequestSchema,
Task_Type,
} from "@/types/proto-es/v1/rollout_service_pb";
-import { extractProjectResourceName, extractRolloutUID } from "@/utils";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+} from "@/utils";
import { CreateButton, CreateIssueButton, RolloutCreatePanel } from "./create";
import { ExportArchiveDownloadAction } from "./export";
import RolloutReadyLink from "./RolloutReadyLink.vue";
@@ -283,7 +286,7 @@ const handleCreateRollout = async () => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId: extractRolloutUID(createdRollout.name),
+ planId: extractPlanUIDFromRolloutName(createdRollout.name),
},
});
} catch (error) {
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/RolloutReadyLink.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/RolloutReadyLink.vue
index 8eb75d23c1..7d3c16ef40 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/RolloutReadyLink.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/RolloutReadyLink.vue
@@ -3,7 +3,7 @@
<NButton icon-placement="right" quaternary>
<TaskStatus :status="rolloutStatus" size="tiny" />
<span class="mx-1">{{ $t("common.rollout") }}</span>
- <span>#{{ rolloutUID }}</span>
+ <span>#{{ planID }}</span>
<template #icon>
<ArrowUpRightIcon class="opacity-60" />
</template>
@@ -20,8 +20,8 @@ import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL } from "@/router/dashboard/projectV1";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
getRolloutStatus,
} from "@/utils";
@@ -32,16 +32,16 @@ const rolloutStatus = computed(() => {
return getRolloutStatus(rollout.value);
});
-const rolloutUID = computed(() => {
+const planID = computed(() => {
if (!rollout.value?.name) return "";
- return extractRolloutUID(rollout.value.name);
+ return extractPlanUIDFromRolloutName(rollout.value.name);
});
const rolloutRoute = computed(() => ({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
params: {
projectId: extractProjectResourceName(plan.value.name),
- rolloutId: extractRolloutUID(rollout.value?.name ?? ""),
+ planId: extractPlanUIDFromRolloutName(rollout.value?.name ?? ""),
},
}));
</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/RolloutCreatePanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/RolloutCreatePanel.vue
index 9d080a0782..7c75c74975 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/RolloutCreatePanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/RolloutCreatePanel.vue
@@ -80,7 +80,10 @@ import { rolloutServiceClientConnect } from "@/grpcweb";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL } from "@/router/dashboard/projectV1";
import { pushNotification } from "@/store";
import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
-import { extractProjectResourceName, extractRolloutUID } from "@/utils";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+} from "@/utils";
import type { ActionContext } from "../registry/types";
const props = defineProps<{
@@ -163,7 +166,7 @@ const handleConfirm = async () => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId: extractRolloutUID(createdRollout.name),
+ planId: extractPlanUIDFromRolloutName(createdRollout.name),
},
});
} catch (error) {
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue
index 45d316ac95..ad4adb0e46 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/IssueReviewButton.vue
@@ -182,8 +182,8 @@ import { PlanCheckRun_Status } from "@/types/proto-es/v1/plan_service_pb";
import { Task_Type } from "@/types/proto-es/v1/rollout_service_pb";
import {
extractIssueUID,
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
flattenTaskV1List,
} from "@/utils";
@@ -363,7 +363,7 @@ const handlePostActionNavigation = (
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
params: {
projectId: extractProjectResourceName(issueValue.name),
- rolloutId: extractRolloutUID(rolloutValue.name),
+ planId: extractPlanUIDFromRolloutName(rolloutValue.name),
},
});
});
diff --git a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/StageName.vue b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/StageName.vue
index 8ddbce690c..6bb6c117aa 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/StageName.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/StageName.vue
@@ -18,8 +18,8 @@ import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboard
import { useEnvironmentV1Store } from "@/store";
import type { Stage } from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractStageUID,
} from "@/utils";
@@ -36,7 +36,7 @@ const link = computed(() => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: extractProjectResourceName(stage.name),
- rolloutId: extractRolloutUID(stage.name),
+ planId: extractPlanUIDFromRolloutName(stage.name),
stageId: extractStageUID(stage.name),
},
};
diff --git a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
index 263e73aeb8..baf2c13e51 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue
@@ -74,7 +74,11 @@ import { EnvironmentV1Name } from "@/components/v2";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboard/projectV1";
import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
import { Advice_Level } from "@/types/proto-es/v1/sql_service_pb";
-import { extractProjectResourceName, getStageStatus } from "@/utils";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+ getStageStatus,
+} from "@/utils";
import { usePlanCheckStatus, usePlanContext } from "../../logic";
import ChecksDrawer from "../ChecksView/ChecksDrawer.vue";
import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";
@@ -94,16 +98,16 @@ const getEnvironmentEntity = (environmentName: string) => {
const navigateToStage = (stageName: string) => {
if (!rollout?.value) return;
- const rolloutId = rollout.value.name.split("/").pop();
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
const stageId = stageName.split("/").pop();
- if (!rolloutId || !stageId) return;
+ if (!planId || !stageId) return;
router.push({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId,
+ planId,
stageId,
},
});
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
index c4b1f5121e..c34c5503d9 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection/ApprovalStepItem.vue
@@ -89,7 +89,8 @@ import { RotateCcwIcon, ThumbsUp, User, X } from "lucide-vue-next";
import { NButton, NTimelineItem } from "naive-ui";
import { computed, ref, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
-import { usePlanContext } from "@/components/Plan/logic";
+import { useIssueContext } from "@/components/IssueV1";
+import { tryUsePlanContext } from "@/components/Plan/logic";
import { issueServiceClientConnect } from "@/grpcweb";
import {
pushNotification,
@@ -129,7 +130,10 @@ const props = defineProps<{
const { t } = useI18n();
const { project } = useCurrentProjectV1();
-const { events } = usePlanContext();
+
+// Try to get plan context, fallback to issue context if not available (legacy layout)
+const planContext = tryUsePlanContext();
+const issueContext = planContext ? undefined : useIssueContext();
const currentUser = useCurrentUserV1();
const userStore = useUserStore();
const roleStore = useRoleStore();
@@ -156,9 +160,12 @@ const handleReRequestReview = async () => {
name: props.issue.name,
});
await issueServiceClientConnect.requestIssue(request);
-
// Emit event to trigger issue refresh
- events.emit("perform-issue-review-action", { action: "ISSUE_REVIEW" });
+ if (planContext) {
+ planContext.events.emit("status-changed", { eager: true });
+ } else {
+ issueContext?.events.emit("status-changed", { eager: true });
+ }
pushNotification({
module: "bytebase",
diff --git a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue
index 739d231b2f..19ba1e0a40 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/Sidebar/DatabaseChangeSection.vue
@@ -77,7 +77,11 @@ import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboard
import { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";
import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";
import { Advice_Level } from "@/types/proto-es/v1/sql_service_pb";
-import { extractProjectResourceName, getStageStatus } from "@/utils";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+ getStageStatus,
+} from "@/utils";
import { usePlanCheckStatus, usePlanContext } from "../../../logic";
import ChecksDrawer from "../../ChecksView/ChecksDrawer.vue";
import PlanCheckStatusCount from "../../PlanCheckStatusCount.vue";
@@ -101,16 +105,16 @@ const getEnvironmentEntity = (environmentName: string) => {
const navigateToStage = (stageName: string) => {
if (!rollout?.value) return;
- const rolloutId = rollout.value.name.split("/").pop();
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
const stageId = stageName.split("/").pop();
- if (!rolloutId || !stageId) return;
+ if (!planId || !stageId) return;
router.push({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId,
+ planId,
stageId,
},
});
diff --git a/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue
index 16ca1f4b70..ed7f7f2059 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue
@@ -70,8 +70,8 @@ import {
TaskRun_Status,
} from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractTaskUID,
flattenTaskV1List,
} from "@/utils";
@@ -271,7 +271,7 @@ const getTaskRouteParams = (taskRun: TaskRun) => {
const taskParts = task.name.split("/");
- const rolloutId = extractRolloutUID(rollout.value.name);
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
const stageIndex = taskParts.indexOf("stages");
@@ -282,7 +282,7 @@ const getTaskRouteParams = (taskRun: TaskRun) => {
const stageId = taskParts[stageIndex + 1];
const taskId = taskParts[taskIndex + 1];
- return { rolloutId, stageId, taskId };
+ return { planId, stageId, taskId };
};
// Get database for selected task run
@@ -301,7 +301,7 @@ const navigateToTaskDetail = (taskRun: TaskRun) => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId: params.rolloutId,
+ planId: params.planId,
stageId: params.stageId || "_", // Use placeholder for empty stageId
taskId: params.taskId,
},
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 14bb182200..b90134aa6e 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -11,7 +11,7 @@ import type {
} from "../components/HeaderSection/Actions/unified";
export type PlanEvents = Emittery<{
- "status-changed": { eager?: boolean };
+ "status-changed": { eager: boolean };
"perform-issue-review-action": {
action: IssueReviewAction;
};
@@ -49,6 +49,10 @@ export const usePlanContext = () => {
return context;
};
+export const tryUsePlanContext = () => {
+ return inject(KEY);
+};
+
export const usePlanContextWithIssue = () => {
const context = inject(KEY)!;
if (!context.issue.value) {
diff --git a/frontend/src/components/Plan/logic/initialize/index.ts b/frontend/src/components/Plan/logic/initialize/index.ts
index e24295a075..9b695bf6d5 100644
--- a/frontend/src/components/Plan/logic/initialize/index.ts
+++ b/frontend/src/components/Plan/logic/initialize/index.ts
@@ -28,10 +28,10 @@ export function useInitializePlan(
projectId: MaybeRef<string>,
planId: MaybeRef<string | undefined>,
issueId: MaybeRef<string | undefined>,
- rolloutId?: MaybeRef<string | undefined>
+ legacyRolloutId?: MaybeRef<string | undefined>
) {
const isCreating = computed(() => {
- const id = unref(planId) || unref(issueId) || unref(rolloutId);
+ const id = unref(planId) || unref(issueId) || unref(legacyRolloutId);
return id?.toLowerCase() === "create";
});
@@ -44,9 +44,9 @@ export function useInitializePlan(
if (uid > 0) return String(uid);
return String(UNKNOWN_ID);
}
- // Otherwise, if rolloutId is provided, we'll fetch the plan from the rollout
- if (unref(rolloutId)) {
- const id = unref(rolloutId)!;
+ // Otherwise, if legacyRolloutId is provided, we'll fetch the plan from the rollout
+ if (unref(legacyRolloutId)) {
+ const id = unref(legacyRolloutId)!;
if (id.toLowerCase() === "create") return String(EMPTY_ID);
// For rollout-based initialization, return a special marker
return `rollout:${id}`;
@@ -85,9 +85,9 @@ export function useInitializePlan(
);
} else if (uid.startsWith("rollout:")) {
// Fetch plan from rollout
- const rolloutUid = uid.substring(8);
+ const planUid = uid.substring(8);
const rolloutRequest = create(GetRolloutRequestSchema, {
- name: `${projectNamePrefix}${projectId}/plans/${rolloutUid}/rollout`,
+ name: `${projectNamePrefix}${projectId}/plans/${planUid}/rollout`,
});
const newRollout =
@@ -95,9 +95,7 @@ export function useInitializePlan(
rolloutResult = newRollout;
if (!rolloutResult.plan) {
- throw new Error(
- `Rollout ${rolloutUid} does not have an associated plan`
- );
+ throw new Error(`Rollout ${planUid} does not have an associated plan`);
}
// Fetch the plan using the rollout's plan reference
@@ -155,8 +153,10 @@ export function useInitializePlan(
const newRollout =
await rolloutServiceClientConnect.getRollout(rolloutRequest);
rolloutResult = newRollout;
- } catch {
+ } catch (error) {
+ console.error("Failed to fetch rollout:", error);
// Rollout might not exist yet, that's ok
+ rolloutResult = undefined;
}
}
} else {
@@ -183,8 +183,10 @@ export function useInitializePlan(
const newRollout =
await rolloutServiceClientConnect.getRollout(rolloutRequest);
rolloutResult = newRollout;
- } catch {
+ } catch (error) {
+ console.error("Failed to fetch rollout:", error);
// Rollout might not exist yet, that's ok
+ rolloutResult = undefined;
}
}
}
diff --git a/frontend/src/components/Plan/logic/poller/utils.ts b/frontend/src/components/Plan/logic/poller/utils.ts
index 47fccc9245..866ac9d8f4 100644
--- a/frontend/src/components/Plan/logic/poller/utils.ts
+++ b/frontend/src/components/Plan/logic/poller/utils.ts
@@ -61,9 +61,14 @@ export const refreshRollout = async (
const rolloutRequest = create(GetRolloutRequestSchema, {
name: rolloutName,
});
- const newRollout =
- await rolloutServiceClientConnect.getRollout(rolloutRequest);
- rollout.value = newRollout;
+ try {
+ const newRollout =
+ await rolloutServiceClientConnect.getRollout(rolloutRequest);
+ rollout.value = newRollout;
+ } catch (error) {
+ console.error("Failed to refresh rollout", error);
+ // Rollout might not exist yet
+ }
};
export const refreshIssue = async (
@@ -105,6 +110,10 @@ export const refreshTaskRuns = async (
const request = create(ListTaskRunsRequestSchema, {
parent,
});
- const response = await rolloutServiceClientConnect.listTaskRuns(request);
- taskRuns.value = response.taskRuns;
+ try {
+ const response = await rolloutServiceClientConnect.listTaskRuns(request);
+ taskRuns.value = response.taskRuns;
+ } catch (error) {
+ console.error("Failed to refresh task runs", error);
+ }
};
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index e6e1e85447..49ca26d36e 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -29,8 +29,8 @@ import type {
Task_Status,
} from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
getStageStatus,
stringifyTaskStatus,
} from "@/utils";
@@ -69,7 +69,7 @@ const columnList = computed(
return (
<div class={`flex items-center overflow-hidden gap-x-2`}>
<div class="whitespace-nowrap text-control opacity-60">
- {extractRolloutUID(rollout.name)}
+ {extractPlanUIDFromRolloutName(rollout.name)}
</div>
{rollout.title ? (
<NPerformantEllipsis class="truncate">
@@ -193,7 +193,7 @@ const rowProps = (rollout: Rollout) => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
params: {
projectId: extractProjectResourceName(rollout.name),
- rolloutId: extractRolloutUID(rollout.name),
+ planId: extractPlanUIDFromRolloutName(rollout.name),
},
};
if (e.ctrlKey || e.metaKey) {
diff --git a/frontend/src/components/RolloutV1/components/RolloutBreadcrumb.vue b/frontend/src/components/RolloutV1/components/RolloutBreadcrumb.vue
index 3d6500c44d..3d21fb4796 100644
--- a/frontend/src/components/RolloutV1/components/RolloutBreadcrumb.vue
+++ b/frontend/src/components/RolloutV1/components/RolloutBreadcrumb.vue
@@ -1,5 +1,5 @@
<template>
- <nav v-if="rolloutUID" class="inline-flex items-center text-sm">
+ <nav v-if="planID" class="inline-flex items-center text-sm">
<template v-for="(item, index) in breadcrumbItems" :key="index">
<span v-if="index > 0" class="mx-2 text-gray-400 font-mono">/</span>
<RouterLink
@@ -31,8 +31,8 @@ import { useEnvironmentV1Store } from "@/store";
import {
extractIssueUID,
extractPlanUID,
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
} from "@/utils";
interface BreadcrumbItem {
@@ -61,9 +61,9 @@ const issueUID = computed(() => {
return extractIssueUID(issue.value.name);
});
-const rolloutUID = computed(() => {
+const planID = computed(() => {
if (!rollout.value?.name) return "";
- return extractRolloutUID(rollout.value.name);
+ return extractPlanUIDFromRolloutName(rollout.value.name);
});
// Route params for stage/task views
@@ -114,10 +114,10 @@ const breadcrumbItems = computed<BreadcrumbItem[]>(() => {
// Rollout - clickable when viewing task detail
items.push({
- label: `${t("common.rollout")} #${rolloutUID.value}`,
+ label: `${t("common.rollout")} #${planID.value}`,
route: {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
- params: { projectId: projectId.value, rolloutId: rolloutUID.value },
+ params: { projectId: projectId.value, planId: planID.value },
},
clickable: hasTask,
});
@@ -130,7 +130,7 @@ const breadcrumbItems = computed<BreadcrumbItem[]>(() => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: projectId.value,
- rolloutId: rolloutUID.value,
+ planId: planID.value,
stageId: stageId.value,
},
},
diff --git a/frontend/src/components/RolloutV1/components/RolloutView.vue b/frontend/src/components/RolloutV1/components/RolloutView.vue
index bd389a63e8..c8b1d1c9f3 100644
--- a/frontend/src/components/RolloutV1/components/RolloutView.vue
+++ b/frontend/src/components/RolloutV1/components/RolloutView.vue
@@ -45,7 +45,10 @@ import { useCurrentProjectV1 } from "@/store";
import { pushNotification } from "@/store/modules/notification";
import type { Stage } from "@/types/proto-es/v1/rollout_service_pb";
import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
-import { extractProjectResourceName, extractRolloutUID } from "@/utils";
+import {
+ extractPlanUIDFromRolloutName,
+ extractProjectResourceName,
+} from "@/utils";
import { useStageSelection } from "./composables/useStageSelection";
import { useTaskInstancePreload } from "./composables/useTaskInstancePreload";
import StageContentView from "./StageContentView.vue";
@@ -86,13 +89,13 @@ watch(
if (isReady && stage && !currentRouteStageId) {
// Auto-selected a stage but no stageId in route, navigate to it
const stageId = stage.name.split("/").pop();
- const rolloutId = extractRolloutUID(rollout.value.name);
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
router.replace({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId: rolloutId || "_",
+ planId: planId || "_",
stageId: stageId || "_",
},
});
@@ -102,15 +105,16 @@ watch(
);
const handleStageSelect = (stage: Stage) => {
+ // Navigate to the proper stage route
// Navigate to the proper stage route
const stageId = stage.name.split("/").pop();
- const rolloutId = extractRolloutUID(rollout.value.name);
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
router.push({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- rolloutId: rolloutId || "_",
+ planId: planId || "_",
stageId: stageId || "_",
},
});
diff --git a/frontend/src/components/RolloutV1/components/TaskItem.vue b/frontend/src/components/RolloutV1/components/TaskItem.vue
index c451194eb7..b873920a84 100644
--- a/frontend/src/components/RolloutV1/components/TaskItem.vue
+++ b/frontend/src/components/RolloutV1/components/TaskItem.vue
@@ -235,8 +235,8 @@ import { taskRunNamePrefix, useSheetV1Store } from "@/store";
import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractStageNameFromTaskName,
extractStageUID,
extractTaskUID,
@@ -304,7 +304,7 @@ const handleActionConfirm = () => {
const taskDetailRoute = computed(() => {
const projectName = extractProjectResourceName(props.task.name);
- const rolloutId = extractRolloutUID(props.task.name);
+ const planId = extractPlanUIDFromRolloutName(props.task.name);
const stageName = extractStageNameFromTaskName(props.task.name);
const stageId = extractStageUID(stageName);
const taskId = extractTaskUID(props.task.name);
@@ -313,7 +313,7 @@ const taskDetailRoute = computed(() => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
params: {
projectId: projectName,
- rolloutId: rolloutId || "-",
+ planId: planId || "-",
stageId: stageId || "-",
taskId: taskId || "-",
},
diff --git a/frontend/src/components/RolloutV1/components/TaskRolloutActionPanel.vue b/frontend/src/components/RolloutV1/components/TaskRolloutActionPanel.vue
index a0ea8df2fc..ae1adb1bc8 100644
--- a/frontend/src/components/RolloutV1/components/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/RolloutV1/components/TaskRolloutActionPanel.vue
@@ -272,7 +272,7 @@ import {
usePolicyByParentAndType,
} from "@/store";
import {
- getProjectIdRolloutUidStageUidTaskUid,
+ getProjectIdPlanUidStageUidTaskUidFromRolloutName,
projectNamePrefix,
rolloutNamePrefix,
stageNamePrefix,
@@ -781,11 +781,11 @@ const cancelTasks = async () => {
// Group tasks by stage first
const tasksByStage = new Map<string, Task[]>();
for (const task of eligibleTasks.value) {
- // Extract stage name from task path: projects/{projectId}/rollouts/{rolloutId}/stages/{stageId}/tasks/...
- const [projectId, rolloutId, stageId] =
- getProjectIdRolloutUidStageUidTaskUid(task.name);
- if (projectId && rolloutId && stageId) {
- const stageName = `${projectNamePrefix}${projectId}/${rolloutNamePrefix}${rolloutId}/${stageNamePrefix}${stageId}`;
+ // Extract stage name from task path: projects/{projectId}/plans/{planId}/rollout/stages/{stageId}/tasks/...
+ const [projectId, planId, stageId] =
+ getProjectIdPlanUidStageUidTaskUidFromRolloutName(task.name);
+ if (projectId && planId && stageId) {
+ const stageName = `${projectNamePrefix}${projectId}/${rolloutNamePrefix}${planId}/${stageNamePrefix}${stageId}`;
if (!tasksByStage.has(stageName)) {
tasksByStage.set(stageName, []);
}
diff --git a/frontend/src/components/RolloutV1/components/TaskRunRollbackDrawer.vue b/frontend/src/components/RolloutV1/components/TaskRunRollbackDrawer.vue
index 2170d2a2cd..37d0866820 100644
--- a/frontend/src/components/RolloutV1/components/TaskRunRollbackDrawer.vue
+++ b/frontend/src/components/RolloutV1/components/TaskRunRollbackDrawer.vue
@@ -157,8 +157,8 @@ import { SheetSchema } from "@/types/proto-es/v1/sheet_service_pb";
import {
databaseForTask,
extractPlanUID,
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
hasProjectPermissionV2,
} from "@/utils";
import TaskTable from "./TaskTable.vue";
@@ -323,8 +323,8 @@ const handleConfirm = async () => {
// Create the plan
const plan = create(PlanSchema, {
name: `${project.value.name}/plans/${uuidv4()}`,
- title: `Rollback for rollout#${extractRolloutUID(props.rollout.name)}`,
- description: `This plan is created to rollback ${rollbackPreviews.value.length} task(s) in rollout #${extractRolloutUID(props.rollout.name)}`,
+ title: `Rollback for rollout#${extractPlanUIDFromRolloutName(props.rollout.name)}`,
+ description: `This plan is created to rollback ${rollbackPreviews.value.length} task(s) in rollout #${extractPlanUIDFromRolloutName(props.rollout.name)}`,
specs,
});
diff --git a/frontend/src/components/RolloutV1/components/TaskTable.vue b/frontend/src/components/RolloutV1/components/TaskTable.vue
index ca8bdb262d..6a25527563 100644
--- a/frontend/src/components/RolloutV1/components/TaskTable.vue
+++ b/frontend/src/components/RolloutV1/components/TaskTable.vue
@@ -32,14 +32,15 @@ import { usePlanContextWithRollout } from "@/components/Plan/logic";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import { useRolloutViewContext } from "@/components/RolloutV1/logic/context";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL } from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1, useDatabaseV1Store } from "@/store";
+import { useDatabaseV1Store } from "@/store";
import { getTimeForPbTimestampProtoEs } from "@/types";
import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractSchemaVersionFromTask,
+ extractStageNameFromTaskName,
humanizeTs,
} from "@/utils";
@@ -63,7 +64,6 @@ const emit = defineEmits<{
const { t } = useI18n();
const router = useRouter();
const databaseStore = useDatabaseV1Store();
-const { project } = useCurrentProjectV1();
const { rollout, mergedStages } = useRolloutViewContext();
const { taskRuns } = usePlanContextWithRollout();
@@ -130,11 +130,11 @@ const getTaskRouteParams = (task: Task) => {
const stage = stageMap.value.get(task.name);
if (!stage) return null;
- const rolloutId = extractRolloutUID(rollout.value.name);
+ const planId = extractPlanUIDFromRolloutName(rollout.value.name);
const stageId = stage.name.split("/").pop();
const taskId = task.name.split("/").pop();
- return { rolloutId, stageId, taskId };
+ return { planId, stageId, taskId };
};
// Row click handler
@@ -144,9 +144,9 @@ const handleRowClick = (task: Task) => {
router.push({
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
params: {
- projectId: extractProjectResourceName(project.value.name),
- rolloutId: params.rolloutId,
- stageId: params.stageId || "_", // Use placeholder for empty stageId
+ projectId: extractProjectResourceName(task.name),
+ planId: extractPlanUIDFromRolloutName(task.name),
+ stageId: extractStageNameFromTaskName(task.name),
taskId: params.taskId,
},
});
diff --git a/frontend/src/components/RolloutV1/components/TaskView.vue b/frontend/src/components/RolloutV1/components/TaskView.vue
index 6b5da8fb12..b1f366d3e5 100644
--- a/frontend/src/components/RolloutV1/components/TaskView.vue
+++ b/frontend/src/components/RolloutV1/components/TaskView.vue
@@ -168,7 +168,7 @@ import TaskRunTable from "./TaskRunTable.vue";
import TaskStatusActions from "./TaskStatusActions.vue";
const props = defineProps<{
- rolloutId: string;
+ planId: string;
stageId: string;
taskId: string;
}>();
diff --git a/frontend/src/components/RolloutV1/components/composables/useTaskNavigation.ts b/frontend/src/components/RolloutV1/components/composables/useTaskNavigation.ts
index 5f4e5f4b5a..9eb3a3fe53 100644
--- a/frontend/src/components/RolloutV1/components/composables/useTaskNavigation.ts
+++ b/frontend/src/components/RolloutV1/components/composables/useTaskNavigation.ts
@@ -2,8 +2,8 @@ import { useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL } from "@/router/dashboard/projectV1";
import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
import {
+ extractPlanUIDFromRolloutName,
extractProjectResourceName,
- extractRolloutUID,
extractStageNameFromTaskName,
extractStageUID,
extractTaskUID,
@@ -16,7 +16,7 @@ export const useTaskNavigation = () => {
// Task name format: projects/{project}/rollouts/{rollout}/stages/{stage}/tasks/{task}
// Use utility functions for consistent parsing
const projectName = extractProjectResourceName(task.name);
- const rolloutId = extractRolloutUID(task.name);
+ const planId = extractPlanUIDFromRolloutName(task.name);
// Extract stage ID from the task's name (Task → Stage relationship)
const stageName = extractStageNameFromTaskName(task.name);
@@ -28,7 +28,7 @@ export const useTaskNavigation = () => {
name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
params: {
projectId: projectName,
- rolloutId: rolloutId || "-",
+ planId: planId || "-",
stageId: stageId || "-",
taskId: taskId || "-",
},
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 599f123561..b85bbdcd99 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -81,7 +81,7 @@ const issueRoutes: RouteRecordRaw[] = [
const rolloutRoutes: RouteRecordRaw[] = [
{
- path: "rollouts/:rolloutId",
+ path: "rollouts/:planId",
component: () => import("@/views/project/RolloutLayout.vue"),
props: true,
meta: {
diff --git a/frontend/src/store/modules/rollout.ts b/frontend/src/store/modules/rollout.ts
index 2d9733267e..618398d7d4 100644
--- a/frontend/src/store/modules/rollout.ts
+++ b/frontend/src/store/modules/rollout.ts
@@ -143,7 +143,11 @@ export const useRolloutByName = (name: MaybeRef<string>) => {
const cached = store.getRolloutByName(name);
if (!isValidRolloutName(cached.name)) {
ready.value = false;
- await store.fetchRolloutByName(name);
+ try {
+ await store.fetchRolloutByName(name);
+ } catch {
+ // ignore
+ }
ready.value = true;
}
},
diff --git a/frontend/src/store/modules/v1/common.ts b/frontend/src/store/modules/v1/common.ts
index b6a7fdba7a..e0bfeb643a 100644
--- a/frontend/src/store/modules/v1/common.ts
+++ b/frontend/src/store/modules/v1/common.ts
@@ -89,7 +89,9 @@ export const getProjectNamePlanIdPlanCheckRunId = (name: string): string[] => {
return [tokens[0], tokens[1], tokens[2]];
};
-export const getProjectIdRolloutUidStageUid = (name: string): string[] => {
+export const getProjectIdPlanUidStageUidFromRolloutName = (
+ name: string
+): string[] => {
const parts = name.split("/rollout");
if (parts.length !== 2) {
return ["", "", ""];
@@ -110,7 +112,7 @@ export const getProjectIdRolloutUidStageUid = (name: string): string[] => {
return [projectId, planId, suffixParts[2]];
};
-export const getProjectIdRolloutUidStageUidTaskUid = (
+export const getProjectIdPlanUidStageUidTaskUidFromRolloutName = (
name: string
): string[] => {
const parts = name.split("/rollout");
@@ -243,7 +245,7 @@ export const getProjectNameReleaseId = (name: string): string[] => {
return tokens;
};
-export const getProjectNameRolloutId = (name: string): string[] => {
+export const getProjectNamePlanIdFromRolloutName = (name: string): string[] => {
if (!name.endsWith("/rollout")) {
return ["", ""];
}
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 8f52fc58c5..cce2a60c86 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -86,17 +86,28 @@ const composeIssue = async (
const request = create(GetRolloutRequestSchema, {
name: rolloutName,
});
- const response = await rolloutServiceClientConnect.getRollout(request);
- issue.rolloutEntity = response;
+ try {
+ const response = await rolloutServiceClientConnect.getRollout(request);
+ issue.rolloutEntity = response;
+ } catch (e) {
+ // Rollout might not exist yet
+ console.error(e);
+ }
}
if (hasProjectPermissionV2(projectEntity, "bb.taskRuns.list")) {
const request = create(ListTaskRunsRequestSchema, {
parent: `${rolloutName}/stages/-/tasks/-`,
});
- const response = await rolloutServiceClientConnect.listTaskRuns(request);
- const taskRuns = response.taskRuns;
- issue.rolloutTaskRunList = taskRuns;
+ try {
+ const response =
+ await rolloutServiceClientConnect.listTaskRuns(request);
+ const taskRuns = response.taskRuns;
+ issue.rolloutTaskRunList = taskRuns;
+ } catch (e) {
+ // Rollout might not exist yet
+ console.error(e);
+ }
}
}
diff --git a/frontend/src/types/rollout.ts b/frontend/src/types/rollout.ts
index d1dbc42816..e10f22fffe 100644
--- a/frontend/src/types/rollout.ts
+++ b/frontend/src/types/rollout.ts
@@ -1,5 +1,5 @@
import { create as createProto } from "@bufbuild/protobuf";
-import { getProjectNameRolloutId } from "@/store/modules/v1/common";
+import { getProjectNamePlanIdFromRolloutName } from "@/store/modules/v1/common";
import { EMPTY_ID, UNKNOWN_ID } from "./const";
import type { Rollout } from "./proto-es/v1/rollout_service_pb";
import { RolloutSchema } from "./proto-es/v1/rollout_service_pb";
@@ -22,7 +22,7 @@ export const unknownRollout = (): Rollout => {
export const isValidRolloutName = (name: unknown): name is string => {
if (typeof name !== "string") return false;
- const [projectName, rolloutName] = getProjectNameRolloutId(name);
+ const [projectName, rolloutName] = getProjectNamePlanIdFromRolloutName(name);
return Boolean(
projectName &&
projectName !== String(UNKNOWN_ID) &&
diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.ts
index e8e990d059..30e6a51cff 100644
--- a/frontend/src/utils/v1/issue/rollout.ts
+++ b/frontend/src/utils/v1/issue/rollout.ts
@@ -26,7 +26,7 @@ import {
} from "@/types/proto-es/v1/rollout_service_pb";
import { flattenTaskV1List } from "./issue";
-export const extractRolloutUID = (name: string) => {
+export const extractPlanUIDFromRolloutName = (name: string) => {
const pattern = /(?:^|\/)plans\/([^/]+)\/rollout(?:$|\/)/;
const matches = name.match(pattern);
return matches?.[1] ?? "";
diff --git a/frontend/src/views/project/RolloutLayout.vue b/frontend/src/views/project/RolloutLayout.vue
index b5ee73e2c3..a66c751944 100644
--- a/frontend/src/views/project/RolloutLayout.vue
+++ b/frontend/src/views/project/RolloutLayout.vue
@@ -44,7 +44,7 @@ import { useBodyLayoutContext } from "@/layouts/common";
const props = defineProps<{
projectId: string;
- rolloutId: string;
+ planId: string;
}>();
const { t } = useI18n();
@@ -58,9 +58,9 @@ const {
isInitializing,
} = useInitializePlan(
toRef(props, "projectId"),
- undefined, // planId - not used for rollout routes
+ toRef(props, "planId"), // planId
undefined, // issueId - not used for rollout routes
- toRef(props, "rolloutId")
+ undefined // legacyRolloutId - deprecated, using planId
);
const planBaseContext = useBasePlanContext({
isCreating,
@@ -114,3 +114,4 @@ const documentTitle = computed(() => {
useTitle(documentTitle);
</script>
+```