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

Notify listeners when a host has been added to a cluster, is about to… #816

Merged
merged 1 commit into from
May 12, 2016

Conversation

mike-tutkowski
Copy link
Member

… be removed from a cluster, or has been removed from a cluster

This PR addresses the following JIRA ticket:

https://issues.apache.org/jira/browse/CLOUDSTACK-8813

The problem is that there needs to be notifications sent when a host is added to, about to be removed from, and removed from a cluster.

Such notifications can be used for many purposes. For example, it can allow storage plug-ins to update ACLs on their storage systems. Also, it can allow us to clean up IQNs from ESXi hosts that are no longer needed.

@mike-tutkowski
Copy link
Member Author

Just an FYI that I have tested this with the two SolidFire storage plug-ins (where applicable) making use of the following hypervisor types and versions:

XenServer 6.1, 6.2, and 6.5
ESXi 5.1
KVM on Ubuntu 14.04
KVM on Ubuntu 12.04

@@ -3327,7 +3330,7 @@ private Answer execute(MigrateVolumeCommand cmd) {
// Consolidate VM disks.
// In case of a linked clone VM, if VM's disks are not consolidated,
// further volume operations on the ROOT volume such as volume snapshot etc. will result in DB inconsistencies.
String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
// String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the commented out code?

Copy link
Member Author

Choose a reason for hiding this comment

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

While making changes in this file, I noticed that Eclipse was pointing out that the variable apiVersion was not in use. Instead of removing the entire line, I just commented it out in case someone later wanted to easily resume making use of this variable.

@miguelaferreira
Copy link
Contributor

Hi @mike-tutkowski

I've skimmed through the code in this PR and I saw quite a lot of nice modifications. Things like proper formatting, stricter object encapsulation, breaking code down in small methods, just to name a few.

However, I found it quite strange that in a PR where you've changed 58 files (adding 1,410 and removing 214 lines), you did not touch a single test class. (Although you touched 1 class that is used for integration testing - DirectAgentManagerSimpleImpl.)
That seems to fall short from any reasonable amount of automated test coverage for your PR.

@@ -124,6 +132,22 @@
private final String _clusterAdminPassword;

public SolidFireConnection(String managementVip, int managementPort, String clusterAdminUsername, String clusterAdminPassword) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't a IP be passed as a InetAddress inside the code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, Wido. How's about I put that on my todo list (and open a PR after this one)? It would end up changing a lot of lines of code in this PR that might distract from the main intention of this work.

@mike-tutkowski
Copy link
Member Author

Hi Miguel,

Fortunately this PR is such that there is essentially no existing test code that needed to be modified. At a high level, this code simply generates a few new events.

What I am doing is writing integration tests that I plan to run regularly on this (basically performing a lot of the test actions that I did manually in an automated fashion). However, this is part of a larger effort I have underway (where I expect to be automating a lot more than just this code).

Thanks for taking time to review the code!
Mike

@miguelaferreira
Copy link
Contributor

Hi again Mike,

Thanks for addressing my questions.

Regarding the commented-out code, I see from your answers that the reason for leaving commented-out code was to make it easy to revert it back in the future.
I also see that you did not follow the same reasoning for other code changes you made in this same PR. And I argue that those changes are also very easy to revert. For that we need only to leverage the version control system. It is easy to track the changes of a given file, and recover it's previous states.
May I recommend that you remove the commented out code, since we still keep the possibility to easily revert those changes in the future?

Regarding the automated testing, I'm very happy to hear that you are working on integration test. I assume from your answer that those integration tests are not committed in the git repository, and that is something I would expect to see happen. Please do correct me if my assumption is wrong.

I trust you when you say that "there is essentially no existing test code" covering the code you changed. I wouldn't go as far as to call that fortunate. I actually think it is a very sad truth.
I think we should unit-test as much as we can, and especially targeting code that has no coverage at all.
I'm sure that given the amount of changes made in this PR there is ample room for covering at least some of it with unit-tests.

Fact is, that if we continue to add code without the complementary unit-tests, our test coverage drops. Is that something we want?

@asfbot
Copy link

asfbot commented Sep 14, 2015

cloudstack-pull-rats #591 ABORTED

@mike-tutkowski
Copy link
Member Author

Hi Miguel,

I can remove those commented-out lines. No problem. Some companies like such lines left in, but others - as you point out - like them removed and point to version control as sufficient documentation.

As you noted, there were some places where I simply didn't see any value in being able to easily reference that info anyways, so I removed those lines. I can just do the same for all of them.

I'm happy to add until tests, but it was not clear to me how to do so for this particular group of logic. Do you have any suggestions as to what specifically (and perhaps how) you'd like unit tested?

Initially I had mainly planned on doing end-to-end integration testing on this code (along with many other pieces of code).

Thanks!
Mike

@miguelaferreira
Copy link
Contributor

Hi @mike-tutkowski

Thanks for being open about removing the commented-out code. IMHO (and not just mine btw) commented-out code poses a serious risk for maintainability. I'll be happy to dive in deeper on the topic if you would like to. Over beers would be the best setting :)

Regarding the unit tests, I cannot make any time this week since I'm already behind schedule for completing my sprint. But I will for sure reserve time next sprint (starting on Monday), to write some unit tests for the code changes in this PR. We can then discuss how to make the test suite more complete.

@mike-tutkowski
Copy link
Member Author

Sure, I'd be happy to get your input on how you see us unit testing this code. In the past, I've mainly restricted my CloudStack testing (automated and manual) to integration tests (in large part because I like to see the code in CloudStack make calls into my storage plug-ins and monitor the behavior it executes on our SAN).

In the meanwhile, I can remove the commented-out code and work on other activities.

Thanks!

@asfbot
Copy link

asfbot commented Sep 14, 2015

cloudstack-pull-analysis #527 ABORTED

@mike-tutkowski
Copy link
Member Author

Just an FYI that I went ahead and updated the code to remove the commented-out lines.

@asfbot
Copy link

asfbot commented Sep 15, 2015

cloudstack-pull-analysis #540 ABORTED

@asfbot
Copy link

asfbot commented Sep 15, 2015

cloudstack-pull-rats #605 ABORTED

@asfbot
Copy link

asfbot commented Sep 15, 2015

cloudstack-pull-rats #614 SUCCESS
This pull request looks good

@asfbot
Copy link

asfbot commented Sep 15, 2015

cloudstack-pull-analysis #552 ABORTED

@mike-tutkowski mike-tutkowski force-pushed the addremovehosts2 branch 2 times, most recently from 5b42bdc to b879605 Compare May 10, 2016 02:19
@swill
Copy link
Contributor

swill commented May 10, 2016

CI RESULTS

Tests Run: 85
  Skipped: 0
   Failed: 1
   Errors: 0
 Duration: 9h 15m 46s

Summary of the problem(s):

FAIL: Test redundant router internals
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/git/cs1/cloudstack/test/integration/smoke/test_routers_network_ops.py", line 483, in test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false
    "Attempt to retrieve google.com index page should be successful once rule is added!"
AssertionError: Attempt to retrieve google.com index page should be successful once rule is added!
----------------------------------------------------------------------
Additional details in: /tmp/MarvinLogs/test_network_5B8X28/results.txt

Associated Uploads

/tmp/MarvinLogs/DeployDataCenter__May_10_2016_06_46_02_Z1YVGT:

/tmp/MarvinLogs/test_network_5B8X28:

/tmp/MarvinLogs/test_vpc_routers_01VL92:

Uploads will be available until 2016-07-10 02:00:00 +0200 CEST

Comment created by upr comment.

@swill
Copy link
Contributor

swill commented May 10, 2016

The one issue showing in the CI run is an issue with my environment. I think this one is ready to merge...

@swill
Copy link
Contributor

swill commented May 11, 2016

Can you re-push to try to get Jenkins green. Thx...

@mike-tutkowski
Copy link
Member Author

@swill Done. Hopefully it will work for Jenkins this time.

@swill
Copy link
Contributor

swill commented May 11, 2016

@mike-tutkowski unfortunately it failed again. :(

@mike-tutkowski
Copy link
Member Author

@swill Is this claiming there's a license problem?

I can rebase and push again.

[INFO] Rat check: Summary of files. Unapproved: 1 unknown: 1 generated: 0 approved: 7204 licence.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.258 s
[INFO] Finished at: 2016-05-11T06:53:07+00:00
[INFO] Final Memory: 47M/366M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.10:check (default-cli) on project cloudstack: Too many files with unapproved license: 1 See RAT report in: /home/jenkins/jenkins-slave/workspace/cloudstack-pr-analysis/target/rat.txt -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http:https://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@swill
Copy link
Contributor

swill commented May 11, 2016

I have seen this happen periodically and it does not seem to be consistently telling us the truth. This happens sometimes when only a single line of code changes, so I am not sure what the deal is here. Just re-push and lets see what happens.

…ster, is about to be removed from a cluster, or has been removed from a cluster
@DaanHoogland
Copy link
Contributor

That is the rat test. it is usually right. I didn't see a new file without license though. May one of the to with a license starting with an empty comment line were the problem. Otherwise the job may be the problem in the sense of not cleaning the workspace properly.

@swill
Copy link
Contributor

swill commented May 11, 2016

I think we are definitely having issues with it not cleaning correctly. I have seen a couple cases where we get the "unable to update index" when it tries to do a git checkout because of problems with cleanup, so that is possible.

@mike-tutkowski
Copy link
Member Author

@swill OK, looks like are OK here.

@asfgit asfgit merged commit dad9e5d into apache:master May 12, 2016
asfgit pushed a commit that referenced this pull request May 12, 2016
Notify listeners when a host has been added to a cluster, is about to be removed from a cluster, or has been removed from a cluster

This PR addresses the following JIRA ticket:

https://issues.apache.org/jira/browse/CLOUDSTACK-8813

The problem is that there needs to be notifications sent when a host is added to, about to be removed from, and removed from a cluster.

Such notifications can be used for many purposes. For example, it can allow storage plug-ins to update ACLs on their storage systems. Also, it can allow us to clean up IQNs from ESXi hosts that are no longer needed.

* pr/816:
  CLOUDSTACK-8813: Notify listeners when a host has been added to a cluster, is about to be removed from a cluster, or has been removed from a cluster

Signed-off-by: Will Stevens <[email protected]>
@mike-tutkowski mike-tutkowski deleted the addremovehosts2 branch May 12, 2016 18:35
@anshul1886
Copy link

anshul1886 commented May 18, 2016

@koushik-das @swill @mike-tutkowski This has broken Hyper-V support. And this is happening because of variable renaming in command.

Should we even allow renaming of variable in the first place? Specifically which are used by other components.

@mike-tutkowski
Copy link
Member Author

Hi @anshul1886 Can you be more specific about the class that is given you problems and the variables? Thanks!

@anshul1886
Copy link

@mike-tutkowski First one which I hit is in ModifyStoragePoolCommand.java. But I am sure there will be more. Hyper-V uses json to communicate between management server and Hyper-V agent. So if we are changing variable names it no longer will be able to parse that info.

@mike-tutkowski
Copy link
Member Author

I see.

Shouldn't the system be using annotations to make this less brittle.

At present, there's no obvious way to see that changing these variable names will break anything.

At the least, we should have unit tests that look for certain variable names in certain classes and fail if expected ones no longer exist.

On May 18, 2016, at 11:05 PM, Anshul Gangwar <[email protected]mailto:[email protected]> wrote:

@mike-tutkowskihttps://github.com/mike-tutkowski First one which I hit is in ModifyStoragePoolCommand.java. But I am sure there will be more. Hyper-V uses json to communicate between management server and Hyper-V agent. So if we are changing variable names it no longer will be able to parse that info.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//pull/816#issuecomment-220228493

@anshul1886
Copy link

@mike-tutkowski I believe class name ending in Command signifies that they are meant for agent and should be treated like API params.

@mike-tutkowski
Copy link
Member Author

I wonder how many people are actually aware of that. :-)

Sent from my iPhone

On May 19, 2016, at 9:04 PM, Anshul Gangwar <[email protected]mailto:[email protected]> wrote:

@mike-tutkowskihttps://github.com/mike-tutkowski I believe class name ending in Command signifies that they are meant for agent and should be treated like API params.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//pull/816#issuecomment-220512436

@anshul1886
Copy link

@mike-tutkowski then we can raise this in dev list.

@mike-tutkowski
Copy link
Member Author

Yes, I can send an e-mail out in a bit.

In the short term (at least for 4.9), I can just revert the changed names in those Command classes.

Do you have a ticket I can open the PR against?

Thanks!


From: Anshul Gangwar [email protected]
Sent: Thursday, May 19, 2016 10:30 PM
To: apache/cloudstack
Cc: Tutkowski, Mike; Mention
Subject: Re: [apache/cloudstack] Notify listeners when a host has been added to a cluster, is about to… (#816)

@mike-tutkowskihttps://github.com/mike-tutkowski then we can raise this in dev list.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//pull/816#issuecomment-220514841

@asfbot
Copy link

asfbot commented May 20, 2016

"Tutkowski, Mike" on [email protected] replies:
I see that you just sent an e-mail to @dev about this - thanks!=0A=
________________________________________=0A=
From: mike-tutkowski [email protected]=0A=
Sent: Thursday, May 19, 2016 10:46 PM=0A=
To: [email protected]=0A=
Subject: [GitHub] cloudstack pull request: Notify listeners when a host has=
been add...=0A=
=0A=
Github user mike-tutkowski commented on the pull request:=0A=
=0A=
#816 (comment)
=0A=
Yes, I can send an e-mail out in a bit.=0A=
=0A=
=0A=
In the short term (at least for 4.9), I can just revert the changed nam=
es in those Command classes.=0A=
=0A=
=0A=
Do you have a ticket I can open the PR against?=0A=
=0A=
=0A=
Thanks!=0A=
=0A=
=0A=
________________________________=0A=
From: Anshul Gangwar [email protected]=0A=
Sent: Thursday, May 19, 2016 10:30 PM=0A=
To: apache/cloudstack=0A=
Cc: Tutkowski, Mike; Mention=0A=
Subject: Re: [apache/cloudstack] Notify listeners when a host has been =
added to a cluster, is about to=85 (#816)=0A=
=0A=
=0A=
@mike-tutkowskihttps://github.com/mike-tutkowski then we can raise th=
is in dev list.=0A=
=0A=
=97=0A=
You are receiving this because you were mentioned.=0A=
Reply to this email directly or view it on GitHub<https://github.com/ap=
ache/cloudstack/pull/816#issuecomment-220514841>=0A=
=0A=
=0A=
=0A=
---=0A=
If your project is set up for it, you can reply to this email and have your=
=0A=
reply appear on GitHub as well. If your project does not have this feature=
=0A=
enabled and wishes so, or if the feature is enabled but not working, please=
=0A=
contact infrastructure at [email protected] or file a JIRA ticket=
=0A=
with INFRA.=0A=
---=0A=

@anshul1886
Copy link

@mike-tutkowski No, I have not created ticket. You can create one.

@mike-tutkowski
Copy link
Member Author

?OK, I can create one and open a PR up against it reverting those variable names.


From: Anshul Gangwar [email protected]
Sent: Thursday, May 19, 2016 10:50 PM
To: apache/cloudstack
Cc: Tutkowski, Mike; Mention
Subject: Re: [apache/cloudstack] Notify listeners when a host has been added to a cluster, is about to… (#816)

@mike-tutkowskihttps://github.com/mike-tutkowski No, I have not created ticket. You can create one.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//pull/816#issuecomment-220516738

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.

None yet

10 participants