Download this file
| 1 | package host |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "github.com/carlosframework/platform/internal/hostclaim" |
| 6 | "github.com/carlosframework/platform/internal/provision" |
| 7 | ) |
| 8 | |
| 9 | var errRootMigrationBusy = errors.New("root migration requires an idle, complete census") |
| 10 | |
| 11 | // Call only on fresh authoritative records while admission is excluded. |
| 12 | // The caller also checks root journals and kernel reservations before writing. |
| 13 | func rootMigrationPreflight(complete bool, records []provision.Record, claims []hostclaim.Claim) error { |
| 14 | if !complete { |
| 15 | return errRootMigrationBusy |
| 16 | } |
| 17 | for _, rec := range records { |
| 18 | // Committed still owns cleanup; MoveComplete clears Move when settled. |
| 19 | if rec.Move != nil { |
| 20 | return errRootMigrationBusy |
| 21 | } |
| 22 | } |
| 23 | for _, claim := range claims { |
| 24 | // Refuse every active operation, including unknown future kinds. |
| 25 | if claim.Op.ID != "" || (claim.Op.Kind != "" && claim.Op.Kind != hostclaim.KindServing) || claim.Op.Phase != "" { |
| 26 | return errRootMigrationBusy |
| 27 | } |
| 28 | } |
| 29 | return nil |
| 30 | } |
| 31 | |