Skip to content

Commit

Permalink
Fix cache-incarnation sync (#587)
Browse files Browse the repository at this point in the history
* when hostname record is missing, assume current

* version update to 2.2.4.1

* minor cleanup; reduce duplicate http logging

* update the incarnarnation file after all caches

* remove http proxy logging unless proxy set

* force goalstate update when host plugin call fails

* update version to 2.2.5
  • Loading branch information
hglkrijger committed Feb 9, 2017
1 parent 2010d76 commit f561aee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
15 changes: 11 additions & 4 deletions azurelinuxagent/common/osutil/default.py
Expand Up @@ -749,9 +749,16 @@ def set_hostname_record(self, hostname):
fileutil.write_file(conf.get_published_hostname(), contents=hostname)

def get_hostname_record(self):
record = None
if os.path.exists(conf.get_published_hostname()):
record = fileutil.read_file(conf.get_published_hostname())
hostname_record = conf.get_published_hostname()
if not os.path.exists(hostname_record):
# this file is created at provisioning time with agents >= 2.2.3
hostname = socket.gethostname()
logger.warn('Hostname record does not exist, '
'creating [{0}] with hostname [{1}]',
hostname_record,
hostname)
self.set_hostname_record(hostname)
record = fileutil.read_file(hostname_record)
return record

def del_account(self, username):
Expand All @@ -765,7 +772,7 @@ def decode_customdata(self, data):
return base64.b64decode(data).decode('utf-8')

def get_total_mem(self):
# Get total memory in bytes and divide by 1024**2 to get the valu in MB.
# Get total memory in bytes and divide by 1024**2 to get the value in MB.
return os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024**2)

def get_processor_cores(self):
Expand Down
5 changes: 3 additions & 2 deletions azurelinuxagent/common/protocol/wire.py
Expand Up @@ -721,7 +721,7 @@ def update_goal_state(self, forced=False, max_retry=3):

if not forced:
last_incarnation = None
if (os.path.isfile(incarnation_file)):
if os.path.isfile(incarnation_file):
last_incarnation = fileutil.read_file(incarnation_file)
new_incarnation = goal_state.incarnation
if last_incarnation is not None and \
Expand All @@ -736,11 +736,11 @@ def update_goal_state(self, forced=False, max_retry=3):
file_name = GOAL_STATE_FILE_NAME.format(goal_state.incarnation)
goal_state_file = os.path.join(conf.get_lib_dir(), file_name)
self.save_cache(goal_state_file, xml_text)
self.save_cache(incarnation_file, goal_state.incarnation)
self.update_hosting_env(goal_state)
self.update_shared_conf(goal_state)
self.update_certs(goal_state)
self.update_ext_conf(goal_state)
self.save_cache(incarnation_file, goal_state.incarnation)
if self.host_plugin is not None:
self.host_plugin.container_id = goal_state.container_id
self.host_plugin.role_config_name = goal_state.role_config_name
Expand Down Expand Up @@ -992,6 +992,7 @@ def get_host_plugin(self, force_update=False):
if force_update:
logger.warn("Forcing update of goal state")
self.goal_state = None
self.update_goal_state(forced=True)
goal_state = self.get_goal_state()
self.host_plugin = HostPluginProtocol(self.endpoint,
goal_state.container_id,
Expand Down
12 changes: 3 additions & 9 deletions azurelinuxagent/common/utils/restutil.py
Expand Up @@ -86,7 +86,7 @@ def _http_request(method, host, rel_uri, port=None, data=None, secure=False,
timeout=10)
url = rel_uri

logger.verbose("HTTPConnection [{0}] [{1}] [{2}] [{3}]",
logger.verbose("HTTP connection [{0}] [{1}] [{2}] [{3}]",
method,
url,
data,
Expand Down Expand Up @@ -128,14 +128,8 @@ def http_request(method, url, data, headers=None, max_retry=3,
"(new in python 2.7)")
secure_warning = False

logger.verbose("HTTP method: [{0}]", method)
logger.verbose("HTTP host: [{0}]", host)
logger.verbose("HTTP uri: [{0}]", rel_uri)
logger.verbose("HTTP port: [{0}]", port)
logger.verbose("HTTP data: [{0}]", data)
logger.verbose("HTTP secure: [{0}]", secure)
logger.verbose("HTTP headers: [{0}]", headers)
logger.verbose("HTTP proxy: [{0}:{1}]", proxy_host, proxy_port)
if proxy_host or proxy_port:
logger.verbose("HTTP proxy: [{0}:{1}]", proxy_host, proxy_port)

retry_msg = ''
log_msg = "HTTP {0}".format(method)
Expand Down
2 changes: 1 addition & 1 deletion azurelinuxagent/common/version.py
Expand Up @@ -88,7 +88,7 @@ def get_distro():

AGENT_NAME = "WALinuxAgent"
AGENT_LONG_NAME = "Azure Linux Agent"
AGENT_VERSION = '2.2.4'
AGENT_VERSION = '2.2.5'
AGENT_LONG_VERSION = "{0}-{1}".format(AGENT_NAME, AGENT_VERSION)
AGENT_DESCRIPTION = """\
The Azure Linux Agent supports the provisioning and running of Linux
Expand Down

0 comments on commit f561aee

Please sign in to comment.