Skip to content

Commit

Permalink
update logging; update goal state when out of date (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
hglkrijger authored Jan 23, 2017
1 parent 2f8c906 commit bb07960
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion azurelinuxagent/common/protocol/hostplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def put_vm_status(self, status_blob, sas_url, config_blob_type=None):
'content': status}, sort_keys=True)
response = restutil.http_put(url, data=data, headers=headers)
if response.status != httpclient.OK:
logger.error("PUT failed [{0}]", response.status)
logger.warn("PUT {0} [{1}: {2}]",
url,
response.status,
response.reason)
else:
logger.verbose("Successfully uploaded status to host plugin")
except Exception as e:
Expand Down
17 changes: 11 additions & 6 deletions azurelinuxagent/common/protocol/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,10 @@ def fetch_manifest(self, version_uris):
uri, headers = host.get_artifact_request(version.uri)
response = self.fetch(uri, headers)
if not response:
host = self.get_host_plugin(force_update=True)
logger.info("Retry fetch in {0} seconds",
LONG_WAITING_INTERVAL)
time.sleep(LONG_WAITING_INTERVAL)
SHORT_WAITING_INTERVAL)
time.sleep(SHORT_WAITING_INTERVAL)
else:
host.manifest_uri = version.uri
logger.verbose("Manifest downloaded successfully from host plugin")
Expand All @@ -659,9 +660,10 @@ def fetch(self, uri, headers=None):
if resp.status == httpclient.OK:
return_value = self.decode_config(resp.read())
else:
logger.warn("Could not fetch {0} [{1}]",
logger.warn("Could not fetch {0} [{1}: {2}]",
uri,
resp.status)
resp.status,
resp.reason)
except (HttpError, ProtocolError) as e:
logger.verbose("Fetch failed from [{0}]", uri)
return return_value
Expand Down Expand Up @@ -982,8 +984,11 @@ def get_header_for_cert(self):
"x-ms-guest-agent-public-x509-cert": cert
}

def get_host_plugin(self):
if self.host_plugin is None:
def get_host_plugin(self, force_update=False):
if self.host_plugin is None or force_update:
if force_update:
logger.warn("Forcing update of goal state")
self.goal_state = None
goal_state = self.get_goal_state()
self.host_plugin = HostPluginProtocol(self.endpoint,
goal_state.container_id,
Expand Down
8 changes: 4 additions & 4 deletions azurelinuxagent/ga/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def _download(self):
break
else:
if self.host is not None:
logger.info("Download unsuccessful, falling back to host plugin")
logger.warn("Download unsuccessful, falling back to host plugin")
uri, headers = self.host.get_artifact_request(uri.uri, self.host.manifest_uri)
if self._fetch(uri, headers=headers):
break
Expand Down Expand Up @@ -730,9 +730,9 @@ def _fetch(self, uri, headers=None):
logger.info(u"Agent {0} downloaded from {1}", self.name, uri)
except restutil.HttpError as http_error:
logger.verbose(u"Agent {0} download from {1} failed [{2}]",
self.name,
uri,
http_error)
self.name,
uri,
http_error)
return package is not None

def _load_error(self):
Expand Down

0 comments on commit bb07960

Please sign in to comment.