Skip to content

Commit

Permalink
minor refactor createworkloadhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Mar 14, 2022
1 parent e55dcd4 commit 15b98e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cluster/calcium/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Calcium) RemoveWorkload(ctx context.Context, ids []string, force bool)
},
// then
func(ctx context.Context) (err error) {
if err = c.doRemoveWorkload(ctx, workload, force); err != nil {
if err = c.doRemoveWorkload(ctx, workload, force); err == nil {
log.Infof(ctx, "[RemoveWorkload] Workload %s removed", workload.ID)
}
return err
Expand Down Expand Up @@ -110,6 +110,7 @@ func (c *Calcium) doRemoveWorkloadSync(ctx context.Context, ids []string) error
}

for m := range ch {
// TODO deal with failed
log.Debugf(ctx, "[doRemoveWorkloadSync] Removed %s", m.WorkloadID)
}
return nil
Expand Down
12 changes: 2 additions & 10 deletions cluster/calcium/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,9 @@ func (h *CreateWorkloadHandler) Handle(ctx context.Context, raw interface{}) (er
defer cancel()

if _, err = h.calcium.GetWorkload(ctx, wrk.ID); err == nil {
// workload meta exists
ch, err := h.calcium.RemoveWorkload(ctx, []string{wrk.ID}, true)
if err != nil {
return logger.Err(ctx, err)
}
for msg := range ch {
if !msg.Success {
logger.Errorf(ctx, "failed to remove workload")
}
if err = h.calcium.doRemoveWorkloadSync(ctx, []string{wrk.ID}); err != nil {
return err
}
logger.Infof(ctx, "workload with meta removed")
return nil
}

Expand Down

0 comments on commit 15b98e8

Please sign in to comment.