Repository navigation
return a state instead of null in AbstractInvestigatorImpl - #211
Conversation
When a full cluster is down or unreachable, CloudStack currently reports everything the same as the last known state, which is usually Up. When it cannot reach a host and cannot reach another host in the same cluster either, it returns null and says "I don't know". This prevents it from reporting the problem. Now, we return an Alert or Disconnected state so proper action can be taken. Also logging was added, so we know what part of the code put it to Alert or Disconnected.
|
LGTM |
|
cloudstack-pull-requests #68 SUCCESS |
|
Reading the code, if testIpAddress() returns anything other than Up, Down or null then returned status is ignored. |
|
@koushik-das what is your point? I think I miss context for your remark. |
|
@DaanHoogland If you look at the code from where testIpAddress() is called (for e.g. UserVmDomRInvestigator.isAgentAlive()), it only deals with return of Up, Down and null. So I am not able to follow the use of this fix. |
|
@koushik-das To reproduce the issue:
Before this fix, CloudStack would not notice the hypervisors were down and keep them Up. After this fix, it puts the hypervisors to Alert state and notifies admin. If you mean something else, please let me know. All tests pass so I'm not aware of anything failing. |
|
I haven't researched this fix extensively. However, I just want to make sure that the alert state is not accompanied by any undesirable behavior. Moving the hypervisors to alert state to warn the admin is fine, but we don't want to assume that anything actually went down. In the scenario given, it is probably more likely that there was a break in the network between the hypervisors and mgmt server, and VMs are running fine, so as long as we are accounting for that scenario during recovery from alert state and not assuming the VMs are down we should be good. |
|
I guess for KVM at least, the behavior should be similar to stopping/starting the Agent. It makes the hypervisor go into disconnected, but leaves the VM states as-is, and is reconciled when the Agent is restarted. |
|
@remibergsma My comments are based on the latest master code. Based on my reading of the code, the changes you made shouldn't have any impact on the outcome of the test. I see that HighAvailabilityManagerImpl.investigate() method returns status as Alert if none of the investigators are able to determine the status. Is it possible that the test is passing due to this? |
|
Also about the scenario that is being addressed - all hosts in a XS cluster are shutdown by pulling the plug. Instead of immediately putting the hosts in Alert state, it may be better to wait for some configurable amount of time and after that if it is not possible to determine status of hosts in the cluster then put them in Alert. |
|
@mlsorensen Agree, no state of VMs should change since we cannot tell because the hypervisors are unreachable. This does not change the state of the VMs, only the hypervisors. @koushik-das It already takes a few minutes before it determines it cannot reach the hypersvisor (after a few retries). I didn't change anything on this. It is not configurable right now as far as I know. I will have a look at the test you mentioned to see what you mean. |
|
The way HA is implemented, “null” is a valid return value from an investigator. The valid values are Up, Down or null. |
|
I agree with Koushik here. The purpose of an HA investigator is to either say that host is UP or Down or it does not know for sure. A host that has not returned some pings is in an indeterministic state, HA recognises it as "null" and not as Alert. |
|
Abhinandan, I think that is a design flow and we should revisit. I doubt The page you mention has been last edited Sep 13, 2013. By capable people Op vr 1 mei 2015 om 11:55 schreef Abhinandan Prateek <
|
|
Daan, |
|
I looked at the code and saw that if investigate() is not able to determine the state of host then by default Alert is returned, earlier it was null. This may not have the desired effect all the time. Recently I came across a scenario where if XS pool master is shutdown and it takes more than "ping timeout" for the new master to get elected then the host always stays in Alert state. Earlier Cloudstack was able to determine the state as Down. |
|
One possible solution I can think of the original problem for this PR is to wait for sometime (say based on the config parameter alert.wait) and if even after that the status of host cannot be determined then put it to Alert rather than putting it to Alert immediately. |
|
@koushik-das Since CloudStack 4.4 XenHA is the one to elect the new pool master. Before, CloudStack would force an election. Personally I do not like this new behaviour, but that's another story. I can imagine this is why it does not align with ping.timeout anymore? Was your test done with XenHA enabled? If you share your test details I will try to replay it and see what happens. |
|
Koushik, I'd rather have the state machine never return null and create a Op vr 1 mei 2015 om 13:03 schreef koushik-das notifications@github.com: One possible solution I can think of the original problem for this PR is to
|
|
@remibergsma Yes XS (6.5) pool HA was enabled. @DaanHoogland Agree on the new state UNKNOWN |
|
Guys - do we have any consensus on this issue? I'm planning to cut a 4.5.1 RC on Monday, if we are not very clear I would like to revert this on 4.5 to avoid any regressions in the release. I'm not personally sure of any side effects since the method only returned Up, Down or null, looks like whatever you return which is no Up or Down, the "for loop" would simply continue (so same behaviour as in null). |
|
Please don't revert. It is on the 4.4 branch as well. It passes all tests and we have yet to create a test that show this hypothetical regression. If we have I'll fix forward. |
|
Daan Hoogland on dev@cloudstack.apache.org replies: Status testIpAddress(Long hostId, String testHostIp), is called twice and effectively the result (and objective) of the commit is only the clearer Hope this convinces you all. Op vr 1 mei 2015 om 14:53 schreef DaanHoogland git@git.apache.org: |
The PR #211 introduced changes where the abstract investigator testIpAddress() would return other Status, which previously only returned null, Up or Down. In this patch we introduce a new Status "Unknown" that replaces null's semantics. The important changes #211 introduced was the debugging statements as semantically the changes would work same as the consumers of testIpAddress() method only used if returned values were Up or Down and in other cases (null, Alert etc) it would simply continue to loop through the resources being investigated. Keeping the debug logs, this commit only replaces the previously returned null values with Status.Unknown and fixed the debug statements to reflect the same. In case of trapped exceptions too, we return Unknown status but log the exception we trapped. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
@dahn you're right, I looked at the code and made some semantic changes around debugging/logging and return value type. I guess there are some parts in the source code that are so tribal or fragile (that must be fixed), changes in them may terrify people. |
|
Another thing to note is that while changing some of this legacy understanding, it is not just the code that needs improvement/change, it is all the existing documentation around it that also needs to be revamped. |
The PR #211 introduced changes where the abstract investigator testIpAddress() would return other Status, which previously only returned null, Up or Down. In this patch we introduce a new Status "Unknown" that replaces null's semantics. The important changes #211 introduced was the debugging statements as semantically the changes would work same as the consumers of testIpAddress() method only used if returned values were Up or Down and in other cases (null, Alert etc) it would simply continue to loop through the resources being investigated. Keeping the debug logs, this commit only replaces the previously returned null values with Status.Unknown and fixed the debug statements to reflect the same. In case of trapped exceptions too, we return Unknown status but log the exception we trapped. server: add null assertions and remove dead code with testIpAddress usage This closes #222 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
The PR #211 introduced changes where the abstract investigator testIpAddress() would return other Status, which previously only returned null, Up or Down. In this patch we introduce a new Status "Unknown" that replaces null's semantics. The important changes #211 introduced was the debugging statements as semantically the changes would work same as the consumers of testIpAddress() method only used if returned values were Up or Down and in other cases (null, Alert etc) it would simply continue to loop through the resources being investigated. Keeping the debug logs, this commit only replaces the previously returned null values with Status.Unknown and fixed the debug statements to reflect the same. In case of trapped exceptions too, we return Unknown status but log the exception we trapped. server: add null assertions and remove dead code with testIpAddress usage This closes #222 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit 7a1cb28) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
…pache#4966) (apache#211) * Improve logs * Remove unnecessary comments * Use diamond inference * Fix some logs * Remove unnecessary unboxing * Create method to handle job result * Remove unused vars and fix some logics * Extract code to method and few adjusts * Use CollectionUtils * Extract pending work job validation to method * Create new constructors * Extract work job and info creation to a method * Extract submit async job to a method * Extract find vm by id to a method * Change log level from trace to debug * Remove unnused methods and add logs * Undo code remotion * Remove asserts and fix conditionals * Address @GabrielBrascher reviews * Remove double quotes from keys in manual json * Undo code remotion * Add object to log * Remove statement from try/catch * Implement toString with ReflectionToStringBuilderUtils * Fix errors related to merge main Co-authored-by: Daniel Augusto Veronezi Salvador <daniel@scclouds.com.br> Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Co-authored-by: Daniel Augusto Veronezi Salvador <daniel@scclouds.com.br>
When a full cluster is down or unreachable,
CloudStack currently reports everything the
same as the last known state, which is usually
Up. When it cannot reach a host and cannot
reach another host in the same cluster either,
it returns null and says "I don't know". This
prevents it from reporting the problem. Now,
we return an Alert or Disconnected state so
proper action can be taken.
Also logging was added, so we know what part
of the code put it to Alert or Disconnected.
When the host is available again, it goes
from Alert state back to Up and CloudStack
starts HA work to recover the VMs. I tested
it on 4.6/master and it works fine now.
As this is a nasty bug, we might want to fix
this also in 4.5 and 4.4.
Thanks to @dahn and @snuf for their
help solving this issue.