| 1 | package activator |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "os/exec" |
| 6 | |
| 7 | "github.com/carlosframework/platform/internal/cgroup" |
| 8 | "github.com/carlosframework/platform/internal/hostwrite" |
| 9 | ) |
| 10 | |
| 11 | func spawnClaimed(ctx context.Context, enabled bool, manager *cgroup.Manager, host string, limit cgroup.Limit, selected hostwrite.Work, identity hostwrite.Identity, build func() *exec.Cmd) (*exec.Cmd, *cgroup.Prepared, error) { |
| 12 | return spawnClaimedBefore(ctx, enabled, manager, host, limit, selected, identity, build, nil) |
| 13 | } |
| 14 | |
| 15 | func spawnClaimedBefore(ctx context.Context, enabled bool, manager *cgroup.Manager, host string, limit cgroup.Limit, selected hostwrite.Work, identity hostwrite.Identity, build func() *exec.Cmd, before func() error) (*exec.Cmd, *cgroup.Prepared, error) { |
| 16 | if !enabled { |
| 17 | cmd, err := manager.Start(host, limit, build) |
| 18 | return cmd, nil, err |
| 19 | } |
| 20 | // Main's isolated root launcher does not yet consume claim reservations. |
| 21 | // Keep this old helper closed even if a future caller reintroduces it. |
| 22 | return nil, nil, ErrClaimIsolationUnavailable |
| 23 | } |
| 24 | |
| 25 | // spawnClaimedGen is the claims-on spawn of a generation child under the |
| 26 | // entry's parent (zero-downtime spec section 7.3), and it is closed: it |
| 27 | // pins nothing, reserves nothing, never builds the command and never |
| 28 | // enters the host write. Invalid arguments answer hostwrite.ErrUnavailable; |
| 29 | // every other call answers ErrClaimIsolationUnavailable, like |
| 30 | // spawnClaimedBefore. Main's RoleLaunch.Start is closed too, so routing a |
| 31 | // claimed generation spawn there would not open it either. A later plan |
| 32 | // needs an isolated root launch protocol that carries the claim |
| 33 | // reservations and the final authority check, rather than a re-route or |
| 34 | // an in-process path. |
| 35 | func spawnClaimedGen(ctx context.Context, parent *cgroup.Prepared, n uint64, tier cgroup.Limit, selected hostwrite.Work, identity hostwrite.Identity, build func() *exec.Cmd, before func() error) (*exec.Cmd, *cgroup.Prepared, error) { |
| 36 | if parent == nil || selected == nil || build == nil || n == 0 { |
| 37 | return nil, nil, hostwrite.ErrUnavailable |
| 38 | } |
| 39 | return nil, nil, ErrClaimIsolationUnavailable |
| 40 | } |
| 41 | |