Skip to content

server: Introduce Unknown Status to be used in AbstractInvestigatorImpl - #222

Closed
yadvr wants to merge 2 commits into
4.5from
HA-abstractinvestigatorimpl-nullstate
Closed

yadvr wants to merge 2 commits into
4.5from
HA-abstractinvestigatorimpl-nullstate

Conversation

@yadvr

@yadvr yadvr commented May 1, 2015

Copy link
Copy Markdown
Member

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

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>
@yadvr

yadvr commented May 1, 2015

Copy link
Copy Markdown
Member Author

@dahn @snuf @remibergsma @koushik-das @abhinandanprateek can anyone of you help review this patch? It simply replaces the null semantics with the Status.Unknown state. I checked #211 and I think there is no functional changes that would introduce any bugs, though it adds better return values and debug messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this check should not be needed (neither null or UNKNOWN)

@DaanHoogland

Copy link
Copy Markdown
Contributor

@bhaisaab Remi told me he will test. LGTM except that the null check is redundant. We could remove it

…sage

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@asfbot

asfbot commented May 1, 2015

Copy link
Copy Markdown

cloudstack-pull-requests #87 SUCCESS
This pull request looks good

@yadvr

yadvr commented May 1, 2015

Copy link
Copy Markdown
Member Author

@DaanHoogland thanks, I've fixed the issues now. Removed dead code where null check is not required as the method only return Unknown/Up/Down.

@asfbot

asfbot commented May 1, 2015

Copy link
Copy Markdown

cloudstack-pull-requests #88 SUCCESS
This pull request looks good

@koushik-das

Copy link
Copy Markdown
Contributor

@bhaisaab The 'null' semantics of all investigators needs to change to 'Unknown'. Just look at all classes that implements Investigator interface. (XS, KVM, Simulator, CheckOnAgent etc.) Also check the noredist ones.

@koushik-das

Copy link
Copy Markdown
Contributor

Also callers for investigate()/isAgentAlive() methods needs to be fixed to handle Unknown instead of null.

@remibergsma

Copy link
Copy Markdown
Contributor

@bhaisaab I'm preparing my lab to test your branch. Will do that in the weekend and let you know!

@DaanHoogland

Copy link
Copy Markdown
Contributor

@koushik-das You sure this is needed for this PR to work? it seems to me this can be future work. Nothing will be broken more then it is now.

@yadvr

yadvr commented May 2, 2015

Copy link
Copy Markdown
Member Author

@remibergsma thanks man! I'm too working this weekend in order to test ACS and cut a 4.5.1 RC candidate on monday.

@koushik-das I've not touched any other code, other than testIpAddress and its consumers. #211 and this PR only try to introduce changes for better debugging. If we want to change the consumers of investigate() or isAlive it could be done separately and if you look at the code they are not returning Unknown at all, their return types remain same.

@koushik-das

Copy link
Copy Markdown
Contributor

I thought the intent of introducing 'Unkonwn' host status was to replace the entire null semantics that was thought to be confusing in the investigators. By doing it partially aren't we introducing more confusion - now there is 'null' as well as 'Unknown' semantics.

Also specific to the change I see the below code removed
if (vmState == null) {continue;}

Shouldn't it be
if (vmState == Status.Unknown) {continue;}

@DaanHoogland

Copy link
Copy Markdown
Contributor

@koushik-das not needed. The null check is needed to prevent npe. The
unknown status will fall through.

On Sat, 2 May 2015 17:45 koushik-das notifications@github.com wrote:

I thought the intent of introducing 'Unkonwn' host status was to replace
the entire null semantics that was thought to be confusing in the
investigators. By doing it partially aren't we introducing more confusion -
now there is 'null' as well as 'Unknown' semantics.

Also specific to the change I see the below code removed
if (vmState == null) {continue;}

Shouldn't it be
if (vmState == Status.Unknown) {continue;}

—
Reply to this email directly or view it on GitHub
#222 (comment).

@koushik-das

Copy link
Copy Markdown
Contributor

@DaanHoogland It is not only to prevent NPE but also to go to the next item in the list when the status cannot be determined. Think of it like this - status cannot be determined using the current host, so move to the next one in the list immediately without any further processing.

@yadvr

yadvr commented May 2, 2015

Copy link
Copy Markdown
Member Author

@koushik-das the new fix ensures that testIpAddress does not return null; and there is no need to check for null and then continue

@abhinandanprateek

Copy link
Copy Markdown
Contributor

The issue has got entangled, let me try to summarise what each of us has been trying to do:

The initial fix itself takes a step into right direction. Use of a proper state instead of null is a good idea. Right now that change is localised in only one of the investigator method. On the whole there is no change to code flow and the change makes it even more readable.

If you look at the HA code holistically then this breaks a pattern for the good, but then the whole code should be made consistent, which means when any investigator i.e. a host investigator or a vm investigator does not know the state of the resource for sure it passes 'UNKNOWN' and not 'null'. I think that will be bit disruptive for a maintenance release, but if can be done that is fine too.

So if majority agrees that they will continue to work on making this code consistent eventually then that is best way forward . As of now it does not change code flow but only effects the semantic consistency.

@DaanHoogland

Copy link
Copy Markdown
Contributor

thanks for summarizing Abhi,

+1 from me

On Sun, May 3, 2015 at 4:40 AM, Abhinandan Prateek <notifications@github.com

wrote:

The issue has got entangled, let me try to summarise what each of us has
been trying to do:

The initial fix itself takes a step into right direction. Use of a proper
state instead of null is a good idea. Right now that change is localised in
only one of the investigator method. On the whole there is no change to
code flow and the change makes it even more readable.

If you look at the HA code holistically then this breaks a pattern for the
good, but then the whole code should be made consistent, which means when
any investigator i.e. a host investigator or a vm investigator does not
know the state of the resource for sure it passes 'UNKNOWN' and not 'null'.
I think that will be bit disruptive for a maintenance release, but if can
be done that is fine too.

So if majority agrees that they will continue to work on making this code
consistent eventually then that is best way forward . As of now it does not
change code flow but only effects the semantic consistency.

—
Reply to this email directly or view it on GitHub
#222 (comment).

Daan

@remibergsma

Copy link
Copy Markdown
Contributor

@abhinandanprateek Nice write up! +1

@yadvr

yadvr commented May 3, 2015

Copy link
Copy Markdown
Member Author

@abhinandanprateek thanks abhi, you're right on the spot. Merging the change soon (though as you said it does not change anything functionally, but only semantically).

@remibergsma

Copy link
Copy Markdown
Contributor

@bhaisaab I've built 4.5.1 from your branch HA-abstractinvestigatorimpl-nullstate, built everything from scratch. When I shut down all nodes in a cluster, they enter Alert state in ~4min time in my setup (as it did initially). I'm OK with this, although I had expected to see something else than Alert since you set it to Unknown state. From an user perspective, the behaviour in 4.5 and HA-abstractinvestigatorimpl-nullstate seems the same. Am I doing something wrong or is this what we expect? I'll have some more time to work on this tonight.

@yadvr

yadvr commented May 3, 2015

Copy link
Copy Markdown
Member Author

@remibergsma Hi Remi, thanks for testing. Yes, we should expect the same states - as Abhi shared no change should be seen from the users' side. The changes I did are mostly semantic changes and don't change any input/outputs for the outside world (outside of the black box). For master/4.6; we should change the states to reflect Unknown etc. I guess no testing is required since you've done the regression testing already.

@yadvr yadvr closed this May 3, 2015
asfgit pushed a commit that referenced this pull request May 3, 2015
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>
asfgit pushed a commit that referenced this pull request May 3, 2015
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>
@remibergsma

Copy link
Copy Markdown
Contributor

Cool, thanks!

Sent from my iPhone

On 03 May 2015, at 15:14, Rohit Yadav notifications@github.com wrote:

@remibergsma Hi Remi, thanks for testing. Yes, we should expect the same states - as Abhi shared no change should be seen from the users' side. The changes I did are mostly semantic changes and don't change any input/outputs for the outside world (outside of the black box). For master/4.6; we should change the states to reflect Unknown etc. I guess no testing is required since you've done the regression testing already.

—
Reply to this email directly or view it on GitHub.

@koushik-das

Copy link
Copy Markdown
Contributor

I think there is agreement that this is a partial fix (with the right intent). And that this PR doesn't add any value from the end-users perspective.
Personally, I would have liked this to be done in a separate branch with all the changes needed to replace null with Unknown in all the investigators. But since it is already committed, would wait for the next PR which will handle this.

@DaanHoogland

Copy link
Copy Markdown
Contributor

This does add value to us. It is used to page engineers on duty.

Op ma 4 mei 2015 om 07:06 schreef koushik-das notifications@github.com:

I think there is agreement that this is a partial fix (with the right
intent). And that this PR doesn't add any value from the end-users
perspective.
Personally, I would have liked this to be done in a separate branch with
all the changes needed to replace null with Unknown in all the
investigators. But since it is already committed, would wait for the next
PR which will handle this.

—
Reply to this email directly or view it on GitHub
#222 (comment).

yadvr added a commit that referenced this pull request Jan 20, 2021
Fixes #222

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
shwstppr pushed a commit to shapeblue/cloudstack that referenced this pull request Mar 13, 2023
* Create table to store available console sessions

* Handle the new table in Java (VO and DAO)

* Manage console sessions via database

* Fix cherry-pick: verify in database if the session exist

* Address reviews: rename table to console_session and rename java objects according to the table name

* Redesign console_session to store more data

* Remove unnecessary constructor

* Use create table syntax previous to mariadb 10.5

* Add console session cleanup task

* Address review

* Add missing config keys

* Fix sonar cloud reports

* In progress fix console load report

* Fix remove console when session ends

* Improve setting description

---------

Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants