| 1 | package control |
| 2 | |
| 3 | // ValidateModelApplicationIdentity fences recovery actions without requiring |
| 4 | // permission to send using the old credentials. Stopping work remains possible |
| 5 | // after provider access has been revoked. |
| 6 | func (c *Controller) ValidateModelApplicationIdentity(choice ModelApplicationChoice) error { |
| 7 | applied, desired, err := c.ModelSettingsState() |
| 8 | if err != nil { |
| 9 | return err |
| 10 | } |
| 11 | if choice.ExpectedRuntimeIdentity != c.ModelRuntimeIdentity() || choice.ExpectedAppliedRevision != applied || choice.ExpectedDesiredRevision != desired { |
| 12 | return ErrModelChoiceStale |
| 13 | } |
| 14 | return nil |
| 15 | } |
| 16 | |
| 17 | // CancelModelApplicationBlockers never cancels independent session processes. |
| 18 | // The caller holds the host's session admission lock through validation/cancel. |
| 19 | func (c *Controller) CancelModelApplicationBlockers(ids []string) { |
| 20 | allowed := map[string]bool{} |
| 21 | for _, job := range c.ModelReplacementJobs() { |
| 22 | allowed[job.ID] = true |
| 23 | } |
| 24 | for _, id := range ids { |
| 25 | if allowed[id] { |
| 26 | c.CancelJob(id) |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 |