Skip to content

result an error not deleting workloads after a crash #2392

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (n *NodeClient) DeploymentList(ctx context.Context) (dls []gridtypes.Deploy
return
}

// DeploymentGet gets a deployment via contract ID
// DeploymentChanges gets a deployment changes via contract ID
func (n *NodeClient) DeploymentChanges(ctx context.Context, contractID uint64) (changes []gridtypes.Workload, err error) {
const cmd = "zos.deployment.changes"
in := args{
Expand Down
4 changes: 2 additions & 2 deletions pkg/container/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ func (c *Module) handlerEventTaskExit(ctx context.Context, ns string, event *eve
<-time.After(restartDelay) // wait for 2 seconds
reason = c.start(ns, event.ContainerID)
} else {
reason = fmt.Errorf("deleting container due to so many crashes")
reason = fmt.Errorf("container failed due to so many crashes")
}

if reason != nil {
log.Debug().Err(reason).Msg("deleting container due to restart error")
log.Debug().Err(reason).Msg("resulting error for container due to restart error")

stub := stubs.NewProvisionStub(c.client)
if err := stub.DecommissionCached(ctx, event.ContainerID, reason.Error()); err != nil {
Expand Down
17 changes: 6 additions & 11 deletions pkg/provision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,18 +989,13 @@ func (e *NativeEngine) DecommissionCached(id string, reason string) error {
return nil
}

//to bad we have to repeat this here
ctx := context.WithValue(context.Background(), engineKey{}, e)
ctx = withDeployment(ctx, twin, dlID)

ctx, cancel := context.WithTimeout(ctx, 3*time.Minute)
defer cancel()

err = e.uninstallWorkload(ctx, &gridtypes.WorkloadWithID{Workload: &wl, ID: globalID},
fmt.Sprintf("workload decommissioned by system, reason: %s", reason),
)
result := gridtypes.Result{
State: gridtypes.StateError,
Error: reason,
Created: gridtypes.Timestamp(time.Now().Unix()),
}

return err
return e.storage.Transaction(twin, dlID, wl.WithResults(result))
}

func (n *NativeEngine) CreateOrUpdate(twin uint32, deployment gridtypes.Deployment, update bool) error {
Expand Down
5 changes: 2 additions & 3 deletions pkg/vm/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,11 @@ func (m *Module) monitorID(ctx context.Context, running map[string]Process, id s
reason = m.withLogs(m.logsPath(id), err)
}
} else {
reason = fmt.Errorf("deleting vm due to so many crashes")
reason = fmt.Errorf("resulting error for vm due to so many crashes")
}

if reason != nil {
log.Debug().Err(reason).Msg("deleting vm due to restart error")
m.removeConfig(id)
log.Debug().Err(reason).Msg("resulting error for vm due to restart error")

if err := stub.DecommissionCached(ctx, id, reason.Error()); err != nil {
return errors.Wrapf(err, "failed to decommission reservation '%s'", id)
Expand Down
Loading