Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facade/state work for action abort #11214

Merged
merged 1 commit into from Feb 20, 2020
Merged

Conversation

hpidcock
Copy link
Member

Checklist

  • Checked if it requires a pylibjuju change?
  • Added integration tests for the PR?
  • Added or updated doc.go related to packages changed?
  • Do comments answer the question of why design decisions were made?

Facade/state work for action abort

This PR encapsulates state and facade changes to deal with juju cancel-action aborting running actions.

Actions can enter an Aborting state when juju cancel-action, this will refire the action notifications watcher, allowing the uniter to handle the abort. The uniter will need to fetch the current action status hence the introduction of the ActionStatus facade call.

Second PR will follow to handle aborting action status.
Third PR will follow to handle aborting machine actions.

QA steps

Create an action that sleeps for a few minutes.

juju run-action myapp/0 mysleepyaction
juju show-action-status action-1

Action should be running.

juju cancel-action action-1

Action should enter the aborting state, but not do anything.
Action should complete successfully after sleep has elapsed.

Documentation changes

N/A

Bug reference

N/A

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts...

apiserver/common/action.go Outdated Show resolved Hide resolved
state/action.go Outdated Show resolved Hide resolved
state/action.go Outdated Show resolved Hide resolved
state/interface.go Outdated Show resolved Hide resolved
worker/uniter/remotestate/watcher.go Outdated Show resolved Hide resolved
worker/uniter/remotestate/snapshot.go Outdated Show resolved Hide resolved
state/watcher.go Outdated Show resolved Hide resolved
state/watcher.go Outdated Show resolved Hide resolved
@hpidcock hpidcock force-pushed the action-cancel-facade branch 6 times, most recently from 4c22f7d to 5547e6c Compare February 18, 2020 07:14
Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, not quite done reviewing yet.
A few small niggles.
Can we improve the state watcher implementation by using a common watcher parameterised with a filter of the status values to fire on?

apiserver/common/action.go Outdated Show resolved Hide resolved
apiserver/common/action.go Outdated Show resolved Hide resolved
state/action.go Show resolved Hide resolved
worker/uniter/operation/executor.go Show resolved Hide resolved
worker/uniter/resolver/loop_test.go Outdated Show resolved Hide resolved
worker/uniter/resolver/loop.go Show resolved Hide resolved
@hpidcock hpidcock force-pushed the action-cancel-facade branch 2 times, most recently from 2e0c14d to 4c3e198 Compare February 19, 2020 02:46
@hpidcock
Copy link
Member Author

!!build!! weird network issue

state/watcher.go Outdated Show resolved Hide resolved
var doc actionNotificationDoc
coll, closer := w.db.GetCollection(actionNotificationsC)
defer closer()
iter := coll.Find(nil).Iter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could get really messy if there's a large number of unpruned completed actions.
can we filter on pending or running...?
(with a test)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to preserve backwards compatibility, we need to fire for pending and running, at least once. If the uniter crashes it should get the running actions it had started so it can error them.
number of pending/running actions is unbounded, but I believe this being for a legacy facades only we can accept that risk.

A) We could fire all initial events, then subsequently only fire when the notify document is missing a change field, but that requires a read for each notification. This also changes the semantics of the fire once for each action.

B) A way around this is two collections, one for legacy watchers (fires only on pending) and one the new facade. This seems just as heavy as the current solution.

I'll implement option A and change all the semantics of fireOnce to notifyNewPending. But this solution isn't as robust as the current map or option B, future changes to the notify collection will need to keep in mind legacy behaviour.

This would have been substantially easier if the mongo collection watchers send the new doc state in the Change value (or a way to read the document in the past with revno)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending and running yes. I was suggesting that'd we'd filter out anything else - completed, failed, aborted etc. I would not expect the number of pending/running to be too bad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no notification doc for completed states AFAIK.

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few things now. Main issue is preventing the actions watcher from blowing up when there's large numbers of unpruned completed actions

state/watcher.go Outdated Show resolved Hide resolved
@hpidcock
Copy link
Member Author

$$merge$$

1 similar comment
@hpidcock
Copy link
Member Author

$$merge$$

- Added Cancel to Action state for handling running/pending actions.
- Added facade call on uniter facade to get ActionStatus.
- Extended ActionNotifications to support changes not just new actions.
- Added support for running operations to receive updates to remote
state.
@hpidcock
Copy link
Member Author

$$merge$$ removed test logging

@jujubot jujubot merged commit 1a98304 into juju:develop Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants