Increase attempts on assigning agent instead of setting state

The previous code would increase attempts every time state was set to
"running". This turned out to be a bad idea: The running state is set by
the agent, not the master, and there are a lot of possible failures
where the task never gets set to running in the first place. This would
lead to the task being retried over and over again, because it would
never reach its retry limit.

This code increases attempts on assignment of an agent, which avoids the
endless retry, but has the disadvantage of increasing attempts in the
case where a task gets assigned to an agent that is offline. (Which can
happen if the master has not yet realized that this agent is offline.)