Skip to content

Commit

Permalink
reset channel if host plugin put status fails (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
hglkrijger authored Apr 11, 2017
1 parent aaba3bf commit c990b47
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions azurelinuxagent/common/protocol/hostplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def put_vm_status(self, status_blob, sas_url, config_blob_type=None):
report_event(op=WALAEventOperation.ReportStatus,
is_success=False,
message=message)
logger.warn("HostGAPlugin: resetting default channel")
HostPluginProtocol.set_default_channel(False)

def _put_block_blob_status(self, sas_url, status_blob):
url = URI_FORMAT_PUT_VM_STATUS.format(self.endpoint, HOST_PLUGIN_PORT)
Expand Down
26 changes: 26 additions & 0 deletions tests/protocol/test_hostplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ def test_fallback(self):
self.assertTrue(wire.HostPluginProtocol.is_default_channel())
wire.HostPluginProtocol.set_default_channel(False)

def test_fallback_failure(self):
"""
Validate that when host plugin fails, the default channel is reset
"""
test_goal_state = wire.GoalState(WireProtocolData(DATA_FILE).goal_state)
status = restapi.VMStatus(status="Ready",
message="Guest Agent is running")
with patch.object(wire.HostPluginProtocol,
"ensure_initialized",
return_value=True):
with patch.object(wire.StatusBlob,
"upload",
return_value=False):
with patch.object(wire.HostPluginProtocol,
"_put_page_blob_status",
side_effect=wire.HttpError("put failure")) as patch_put:
client = wire.WireProtocol(wireserver_url).client
client.get_goal_state = Mock(return_value=test_goal_state)
client.ext_conf = wire.ExtensionsConfig(None)
client.ext_conf.status_upload_blob = sas_url
client.status_blob.set_vm_status(status)
client.upload_status_blob()
self.assertTrue(patch_put.call_count == 1,
"Fallback was not engaged")
self.assertFalse(wire.HostPluginProtocol.is_default_channel())

def test_put_status_error_reporting(self):
"""
Validate the telemetry when uploading status fails
Expand Down

0 comments on commit c990b47

Please sign in to comment.