Skip to content
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
12 changes: 8 additions & 4 deletions packages/api/internal/orchestrator/delete_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ func (o *Orchestrator) removeSandboxFromNode(ctx context.Context, sbx sandbox.Sa
return fmt.Errorf("node '%s' not found", sbx.NodeID)
}

// Remove the sandbox resources after the sandbox is deleted
err := o.routingCatalog.DeleteSandbox(ctx, sbx.SandboxID, sbx.ExecutionID)
if err != nil {
logger.L().Error(ctx, "error removing routing record from catalog", zap.Error(err), logger.WithSandboxID(sbx.SandboxID))
// Only remove from routing table if the node is managed by Nomad
// For remote cluster nodes we are using gPRC metadata for routing registration instead
if node.IsNomadManaged() {
// Remove the sandbox resources after the sandbox is deleted
err := o.routingCatalog.DeleteSandbox(ctx, sbx.SandboxID, sbx.ExecutionID)
if err != nil {
logger.L().Error(ctx, "error removing routing record from catalog", zap.Error(err), logger.WithSandboxID(sbx.SandboxID))
}
}

sbxlogger.I(sbx).Debug(ctx, "Removing sandbox",
Expand Down
38 changes: 23 additions & 15 deletions packages/api/internal/orchestrator/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@ func (o *Orchestrator) addSandboxToRoutingTable(ctx context.Context, sandbox san
node := o.GetNode(sandbox.ClusterID, sandbox.NodeID)
if node == nil {
logger.L().Error(ctx, "failed to get node", logger.WithNodeID(sandbox.NodeID))
} else {
info := e2bcatalog.SandboxInfo{
OrchestratorID: node.Metadata().ServiceInstanceID,
OrchestratorIP: node.IPAddress,

ExecutionID: sandbox.ExecutionID,
StartedAt: sandbox.StartTime,
MaxLengthInHours: int64(sandbox.MaxInstanceLength / time.Hour),
}

lifetime := time.Duration(info.MaxLengthInHours) * time.Hour
err := o.routingCatalog.StoreSandbox(ctx, sandbox.SandboxID, &info, lifetime)
if err != nil {
logger.L().Error(ctx, "error adding routing record to catalog", zap.Error(err), logger.WithSandboxID(sandbox.SandboxID))
}

return
}

// Only add to routing table if the node is managed by Nomad
// For remote cluster nodes we are using gPRC metadata for routing registration instead
if !node.IsNomadManaged() {
Comment thread
sitole marked this conversation as resolved.
return
Comment thread
sitole marked this conversation as resolved.
}

info := e2bcatalog.SandboxInfo{
OrchestratorID: node.Metadata().ServiceInstanceID,
OrchestratorIP: node.IPAddress,

ExecutionID: sandbox.ExecutionID,
StartedAt: sandbox.StartTime,
MaxLengthInHours: int64(sandbox.MaxInstanceLength / time.Hour),
}

lifetime := time.Duration(info.MaxLengthInHours) * time.Hour
err := o.routingCatalog.StoreSandbox(ctx, sandbox.SandboxID, &info, lifetime)
if err != nil {
logger.L().Error(ctx, "error adding routing record to catalog", zap.Error(err), logger.WithSandboxID(sandbox.SandboxID))
}
}