RecoverRunOnBoot applies one daemon-owned recovery decision to a non-terminal run discovered during startup reconciliation.
( ctx context.Context, runID string, recovery RunBootRecovery, actor ActorContext, )
| 2204 | // RecoverRunOnBoot applies one daemon-owned recovery decision to a non-terminal |
| 2205 | // run discovered during startup reconciliation. |
| 2206 | func (m *Service) RecoverRunOnBoot( |
| 2207 | ctx context.Context, |
| 2208 | runID string, |
| 2209 | recovery RunBootRecovery, |
| 2210 | actor ActorContext, |
| 2211 | ) (*Run, error) { |
| 2212 | if err := requireWriteAuthority(actor); err != nil { |
| 2213 | return nil, err |
| 2214 | } |
| 2215 | |
| 2216 | normalizedRecovery, err := normalizeRunBootRecovery(recovery) |
| 2217 | if err != nil { |
| 2218 | return nil, err |
| 2219 | } |
| 2220 | |
| 2221 | run, taskRecord, err := m.loadRunWithTask(ctx, runID) |
| 2222 | if err != nil { |
| 2223 | return nil, err |
| 2224 | } |
| 2225 | |
| 2226 | previousStatus := run.Status.Normalize() |
| 2227 | previousSessionID := strings.TrimSpace(run.SessionID) |
| 2228 | switch normalizedRecovery.Action.Normalize() { |
| 2229 | case RunBootRecoveryRequeue: |
| 2230 | return m.recoverRunByRequeue( |
| 2231 | ctx, |
| 2232 | taskRecord, |
| 2233 | run, |
| 2234 | normalizedRecovery, |
| 2235 | actor, |
| 2236 | previousStatus, |
| 2237 | previousSessionID, |
| 2238 | ) |
| 2239 | case RunBootRecoveryMarkRunning: |
| 2240 | return m.recoverRunByMarkRunning( |
| 2241 | ctx, |
| 2242 | taskRecord, |
| 2243 | run, |
| 2244 | normalizedRecovery, |
| 2245 | actor, |
| 2246 | previousStatus, |
| 2247 | previousSessionID, |
| 2248 | ) |
| 2249 | case RunBootRecoveryFail: |
| 2250 | return m.recoverRunByFailure( |
| 2251 | ctx, |
| 2252 | taskRecord, |
| 2253 | run, |
| 2254 | normalizedRecovery, |
| 2255 | actor, |
| 2256 | previousStatus, |
| 2257 | previousSessionID, |
| 2258 | ) |
| 2259 | default: |
| 2260 | return nil, fmt.Errorf( |
| 2261 | "%w: run boot recovery action %q is not supported", |
| 2262 | ErrValidation, |
| 2263 | normalizedRecovery.Action, |