Skip to content

Commit

Permalink
Merge branch 'develop' into publish_hostname_cloud_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
maddieford authored Jan 2, 2024
2 parents 8f39c58 + 0c03cb1 commit e956f92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions azurelinuxagent/ga/self_update_version_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _is_new_agent_allowed_update(self):
"""
This method ensure that update is allowed only once per (hotfix/Regular) upgrade frequency
"""
now = datetime.datetime.now()
now = datetime.datetime.utcnow()
upgrade_type = self._get_agent_upgrade_type(self._version)
if upgrade_type == SelfUpdateType.Hotfix:
next_update_time = self._get_next_process_time(self._last_attempted_self_update_time,
Expand All @@ -80,6 +80,12 @@ def _is_new_agent_allowed_update(self):
next_update_time = self._get_next_process_time(self._last_attempted_self_update_time,
conf.get_self_update_regular_frequency(), now)

if self._version > CURRENT_VERSION:
message = "Self-update discovered new {0} upgrade WALinuxAgent-{1}; Will upgrade on or after {2}".format(
upgrade_type, str(self._version), next_update_time.strftime(logger.Logger.LogTimeFormatInUTC))
logger.info(message)
add_event(op=WALAEventOperation.AgentUpgrade, message=message, log_event=False)

if next_update_time <= now:
# Update the last upgrade check time even if no new agent is available for upgrade
self._last_attempted_self_update_time = now
Expand All @@ -92,7 +98,7 @@ def _should_agent_attempt_manifest_download(self):
the agent has not attempted to download the manifest in the last 1 hour
If we allow update, we update the last attempted manifest download time
"""
now = datetime.datetime.now()
now = datetime.datetime.utcnow()

if self._last_attempted_manifest_download_time != datetime.datetime.min:
next_attempt_time = self._last_attempted_manifest_download_time + datetime.timedelta(
Expand Down Expand Up @@ -161,7 +167,7 @@ def log_new_agent_update_message(self):
"""
This function logs the update message after we check version allowed to update.
"""
msg = "Self-update discovered new agent version:{0} in agent manifest for goal state {1}, will update the agent before processing the goal state.".format(
msg = "Self-update is ready to upgrade the new agent: {0} now before processing the goal state: {1}".format(
str(self._version), self._gs_id)
logger.info(msg)
add_event(op=WALAEventOperation.AgentUpgrade, message=msg, log_event=False)
Expand Down
2 changes: 1 addition & 1 deletion tests/ga/test_agent_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _assert_agent_rsm_version_in_goal_state(self, mock_telemetry, inc=1, version

def _assert_update_discovered_from_agent_manifest(self, mock_telemetry, inc=1, version="9.9.9.10"):
upgrade_event_msgs = [kwarg['message'] for _, kwarg in mock_telemetry.call_args_list if
'Self-update discovered new agent version:{0} in agent manifest for goal state incarnation_{1}'.format(version, inc) in kwarg['message'] and kwarg[
'Self-update is ready to upgrade the new agent: {0} now before processing the goal state: incarnation_{1}'.format(version, inc) in kwarg['message'] and kwarg[
'op'] == WALAEventOperation.AgentUpgrade]
self.assertEqual(1, len(upgrade_event_msgs),
"Did not find the event indicating that the new version found. Got: {0}".format(
Expand Down

0 comments on commit e956f92

Please sign in to comment.