Skip to content

Commit 1ad0c8b

Browse files
committed
fix: small bug fixes
Some small bug fixes that came up during code review - `handleError` returns wrong error variable in `swarm/pgbackrest_restore.go` - empty `Statuses` slice filters out all tasks in `task/service.go` - error logged unconditionally regardless of `logTaskEvent` outcome in `workflows/common.go`
1 parent e3a314d commit 1ad0c8b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

server/internal/orchestrator/swarm/pgbackrest_restore.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ func (p *PgBackRestRestore) Create(ctx context.Context, rc *resource.Context) er
9191
}
9292

9393
t, err := p.startTask(ctx, taskSvc)
94+
if err != nil {
95+
return err
96+
}
97+
9498
handleError := func(cause error) error {
9599
p.failTask(logger, taskSvc, t, cause)
96-
return err
100+
return cause
97101
}
98102

99103
svcResource, err := resource.FromContext[*PostgresService](rc, PostgresServiceResourceIdentifier(p.InstanceID))

server/internal/task/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func matchesFilters(task *Task, opts TaskListOptions) bool {
275275
if opts.Type != "" && task.Type != opts.Type {
276276
return false
277277
}
278-
if !slices.Contains(opts.Statuses, task.Status) {
278+
if len(opts.Statuses) > 0 && !slices.Contains(opts.Statuses, task.Status) {
279279
return false
280280
}
281281
if opts.NodeName != "" && (task == nil || task.NodeName != opts.NodeName) {

server/internal/workflows/common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ func (w *Workflows) cancelTask(
191191
Message: "task successfully canceled",
192192
Fields: map[string]any{"status": "canceled"},
193193
})
194-
logger.With("error", err).Error("failed to log task event")
195-
194+
if err != nil {
195+
logger.With("error", err).Error("failed to log task event")
196+
}
196197
}
197198

198199
func (w *Workflows) getNodeResources(

0 commit comments

Comments
 (0)