forked from Azure/WALinuxAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- correct scvmm references - add unit tests for scvmm detection - ensure all matching devices are mounted and examined for scvmm configuration - exit once vmm startup script is found and executed - fixes Azure#185
- Loading branch information
1 parent
922c569
commit ab2e3c3
Showing
4 changed files
with
148 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Copyright 2014 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Requires Python 2.4+ and Openssl 1.0+ | ||
# | ||
# Implements parts of RFC 2131, 1541, 1497 and | ||
# http://msdn.microsoft.com/en-us/library/cc227282%28PROT.10%29.aspx | ||
# http://msdn.microsoft.com/en-us/library/cc227259%28PROT.13%29.aspx | ||
|
||
import azurelinuxagent.distro.default.scvmm as scvmm | ||
import azurelinuxagent.distro.default.osutil as osutil | ||
import mock | ||
from tests.tools import * | ||
from azurelinuxagent.distro.loader import get_distro | ||
from azurelinuxagent.distro.default.protocolUtil import * | ||
|
||
|
||
class TestSCVMM(AgentTestCase): | ||
def test_scvmm_detection_with_file(self): | ||
# setup | ||
conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir) | ||
conf.get_detect_scvmm_env = Mock(return_value=True) | ||
scvmm_file = os.path.join(self.tmp_dir, scvmm.VMM_CONF_FILE_NAME) | ||
fileutil.write_file(scvmm_file, "") | ||
|
||
patch = mock.patch.object(scvmm.ScvmmHandler, 'start_scvmm_agent').start() | ||
|
||
# execute | ||
get_distro().daemon_handler.daemon() | ||
|
||
# assert | ||
patch.assert_called() | ||
|
||
# cleanup | ||
os.remove(scvmm_file) | ||
|
||
|
||
def test_scvmm_detection_with_multiple_cdroms(self): | ||
# setup | ||
conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir) | ||
conf.get_detect_scvmm_env = Mock(return_value=True) | ||
|
||
patch_mount = mock.patch.object(osutil.DefaultOSUtil, 'mount_dvd').start() | ||
|
||
# execute | ||
with patch('os.listdir', return_value=["sr0", "sr1", "sr2"]): | ||
scvmm.ScvmmHandler(get_distro()).detect_scvmm_env() | ||
|
||
# assert | ||
assert patch_mount.call_count == 3 | ||
assert patch_mount.call_args_list[0][1]['dvd'] == '/dev/sr0' | ||
assert patch_mount.call_args_list[1][1]['dvd'] == '/dev/sr1' | ||
assert patch_mount.call_args_list[2][1]['dvd'] == '/dev/sr2' | ||
|
||
|
||
def test_scvmm_detection_without_file(self): | ||
# setup | ||
conf.get_dvd_mount_point = Mock(return_value=self.tmp_dir) | ||
conf.get_detect_scvmm_env = Mock(return_value=True) | ||
scvmm_file = os.path.join(self.tmp_dir, scvmm.VMM_CONF_FILE_NAME) | ||
if os.path.exists(scvmm_file): | ||
os.remove(scvmm_file) | ||
|
||
patch_start = mock.patch.object(scvmm.ScvmmHandler, 'start_scvmm_agent').start() | ||
|
||
# execute | ||
scvmm.ScvmmHandler(get_distro()).detect_scvmm_env() | ||
|
||
# assert | ||
patch_start.assert_not_called() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not able to apply it cleanly against 2.1.3.
I'll try to "rebase" your patch and see if I can apply it.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, here's what I did:
I used the diff against 2.1.3 that I obtained via this URL:
Azure/WALinuxAgent@b05e389...hglkrijger:bugfix/github-185
I applied this to the code of 2.1.3 shipped with ubuntu cloud image and started the provisioning.
Now it looks better yet still the provisioning loops:
http://screencast.com/t/qCDKXe9ub
and the syslog:
http://screencast.com/t/Vo9YxFPI
I see the scvmm agent is in fact installed in /opt/microsoft so the only missing thing is the restart which never happens. It might be due to systemd behaving differently than upstart or init.
p.s. i rebooted manually yet for whatever reason the scvmm agent is not doing its job. rather than that the waagent is looping again.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @emsi - could you please provide the scvmm.log from this failure case? (/var/log/microsoft/scvmmguestagent, iirc)
My understanding is that cloud-init does not support VMM provisioning, so that should probably be disabled.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure:
http://screencast.com/t/EKRr1NmtQ
Now everything is crystal clear :) The path is missing trailing slash na glues to
/mnt/cdrom/securelinuxosconfiguration.xml
rather than/mnt/cdrom/secure/linuxosconfiguration.xml
I mean this: http://screencast.com/t/PiD9hUjvU
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To not loose more time I added the missing slash to verify if that ultimately does the trick:
This time machine got provisioned to a degree. It rebooted immediately and the hostname, timezone, password, ssh keys etc. are setup now. Unfortunately there should be another reboot concluding the provisioning that never occurred. The waagentl.log is clear and says:
Over and over again...
while scvmmlog looks kile below:
Then it repeats all over again the set of messages witch each set ending with:
Command:/opt/microsoft/scvmmguestagent/bin/cfgpost
and the mesage grows in size incrementalyI mean it loops with
Writing following to file:<OSConfigurationStatus SchemaVersion="1.1"><SpecializationStarted Schem....
andReading file:/opt/microsoft/scvmmguestagent/status/statusmessage.xml
thenFile read:<OSConfigurationStatus SchemaVersion="1.1"><SpecializationStarted SchemaVersion="1.1">SpecializationStarted</SpecializationStarted><PreConfiguratorStatus SchemaVersion="1.1">Successful</PreConfiguratorStatus><SpecializationStarted SchemaVersion="1.1">SpecializationStarted</SpecializationStarted><SpecializationStarted SchemaVersion="1.1">SpecializationStarted</SpecializationStarted><SpecializationStarted SchemaVersion="1.1">SpecializationStarted</SpecializationStarted><SpecializationStarted SchemaVersion="1.1">SpecializationStarted</SpecializationStarted><SpecializationStarted SchemaVersion="1.1">...
and it gets longer and longer again.So there's another loop. I guess it's probably due to waalinuxagent not turning itself off after the first reboot when the scvmmagent already took its job.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hglkrijger: I think that azure agent should step back once it installed scvmmagent. Do you have any clue?
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emsi, the current version of scvmm install does not support systemd, so waagent is not stopped correctly and goes into this loop. I have put an updated version of this script with a systemd fix here. If you are able to verify this works as expected, that would be very helpful.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hglkrijger: Still the same - loops as before. The installer does the reboot yet after that it still loops.
I patched the installer on my vmm server with following patch and I checked that it ended in the Linux machine being provisioned:
I checked if the waagent.service is started and systemd says it's not:
However what I found is that there is no such service. What is installed is walinuxagent:
BTW: does your patch address the missing slash I mentioned in my previous comment?
script_commands = ["/bin/bash", startup_script, "-p " + mount_point + "/"]
p.s. manually shutting down the machine concluded the process but I had to stop and disable walinuxagent prior to that. vmm says it's provisioned now.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @emsi, I will update the service name.
yes, the missing slash is included.
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hglkrijger: Thank you very much.
Unfortunately it looks like scvmmagent also needs update for systemd. I had to manually reboot the machine to finalize the provisioning process. Do you know if such update is possible?
ab2e3c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emsi, please file an issue here: https://github.com/Microsoft/SCVMMLinuxGuestAgent