...
| Scenarios | Current behavior | How to deal with it |
|---|
- Scenario 1: Connection failures between the agent and the management server
| Agent cannot send Answer to management server, therefore timed out on management server | Agent: (for reconcile command only) - Save command info as JSON file
- Update command state in JSON when start/process/complete the command
- STARTED
- PROCESSING
- COMPLETE/FAILED
- Save Answer in the JSON file
- Every minute
- Load command/answer from JSON files
- Send with with PingCommand
- Receive the PingAnswer from management server
- Remove the JSON file if state is COMPLETE/FAILED
Management server: (for reconcile command only) - When create the reconcile command, insert a record with state CREATED into reconcile_commands table
- When receive the PingCommand, Update command state and answer in reconcile_commands table
- When wait for the answer of command (reconcile command only)
- Every 10 seconds, check answer of the reconcile_commands table
- If answer is found, parse the answer
- Returna and continue with the answer
- No need to wait until timeout, if there are connection failures.
- if timed out, update command state to TIMED_OUT in reconcile_commands table
|
- Scenario 2: Agent crash (or force killing the agent process)
| Agent interrupt the process or processing in backend | Management server - When Host Status is determined as Down
- Update reconcile commands (to the agent) in reconcile_command table
- to INTERRUPTED state
- Reconcile the command
- see "3.6 Reconcile the command"
|
- Scenario 3: Agent restart
| Agent interrupt the process or processing in backend | Agent (when restart) When stop the agent, updates state of processesPROCESSING to INTERRUPTEDPROCESSING_IN_BACKEND to DANGLED_IN_BACKEND
- When start the agent, updates state of processes
- PROCESSING to INTERRUPTED
- PROCESSING_IN_BACKEND to DANGLED_IN_BACKEND
- Agent send CommandInfo to management server via PingCommand every minute
- with new state
- Management server reconcile commands every minute (from reconcile_commands table) , for commands in state
|
- Scenario 4: Agent has completed but timed out
| timed out on management server | Management server - Update state_by_management to TIMED_OUT
- Update state_by_agent to COMPLETED (from PROCESSING)
- Reconcile the command
- see "3.6 Reconcile the command"
- TODO: what should be the correct resource state ?4
|
- Scenario 5: Management restart
| Agent process the command - has completed and send Answer to management server, but no action on management server
- has not completed, and is processing command
| Management server - Update state_by_management to INTERRUPTED when mgmt server is stopped.
- When another management server is detected DOWN
- update reconcile_command to INTERRUPTED state by management server
|
...
-> RECONCILED (all good) / RECONCILE_FAILED (failed, will retry) / RECONCILED_RETRY (success, but need more information, will retry)
3.7 Summary
| Action | scenario 1 Connection failures between the agent and the management server | scenario 2 Agent crash (or force killing the agent process) | scenario 3 Agent is restarted manually | how to reconcile |
|---|
| Migrate VM | - iptables -I OUTPUT -p tcp -m tcp --dport 8250 -j DROP
- iptables -D OUTPUT -p tcp -m tcp --dport 8250 -j DROP
- intermittent failure
- agent updates answer when connection is back to normal
- mgmt server gets the answer from DB
|
and process - every 10 seconds
- mgmt server processes the answer if found
|
Long agent is started again by systemctl- Migration thread of VM [i-2-1198-VM] finished.
- management
- Resource [Host:1] is unreachable: Host 1: Operation timed out on migrating VM instance
- Behavior:
- (new) check via destination host (if dest is Up)
- if vm is Running on destination, consider the vm migration is successful.
- Active migration command so scheduling a restart
- vm is Stopped on destination and Running on source (actually it is not)
| - kill -9 $(ps -ef |grep cloudstack-agent |grep -v grep |awk '{print $2}')
- agent
- agent is started again by systemctl
management server
|
management server
Resource [Host:However- In edge case, if the vm is migrated before agent is restarted (10 seconds) , the vm is Stopped (by ACS on destination host)
| - systemctl restart cloudstack-agent
- agent
- abort the migration job by disconnect hook
- written by Marcus
- management server
- Resource [Host:1] is unreachable: Host 1: Operation timed out on migrating VM instance
- VM is Running on source host
- Note:
- In edge case, the vm is migrated before aborting the job, the vm is Stopped (by ACS on destination host)
| If VM is Migrating (mgmt server is restarted) - check via source host (if source is Up)
- check via destination host (if dest is Up)
- determine the state and update
|
| Migrate VM with volumes |
|
|
|
|
|
|
|
|
|
Migrate VM with volumes (If VM is Migrating)
...