Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade/Downgrade agent if Requested Version available #2479

Merged
merged 13 commits into from Jan 28, 2022

Conversation

larohra
Copy link
Contributor

@larohra larohra commented Jan 20, 2022

Description

This PR contains the next set of changes for GA Versioning. Certain key points of this PR -

  • The agent wont accept downgrades for requested versions < current daemon version
  • Blacklist the Agent on downgrade
  • AutoUpdate as soon as a requested version is available rather than waiting for the wait times (4 hrs/24 hrs)
  • Remove dead code that is not relevant anymore
  • A bit of a re-write of the auto-update logic (with emphasis on making sure the current scenario is not broken)

Issue #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made

Quality of Code and Contribution Guidelines

@@ -298,6 +298,3 @@ def set_goal_state_agent():

GOAL_STATE_AGENT_VERSION = set_goal_state_agent()


def is_current_agent_installed():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code logic was not being used anymore, so removed it

@@ -815,17 +853,6 @@ def _is_orphaned(self):

return fileutil.read_file(conf.get_agent_pid_file_path()) != ustr(parent_pid)

def _is_version_eligible(self, version):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was only being used in 1 place (during auto-update) and due to the condition below, it was always True (if version == CURRENT_VERSION and is_current_agent_installed(): return True). Since it was not adding much value to the code, removed it

@codecov
Copy link

codecov bot commented Jan 20, 2022

Codecov Report

Merging #2479 (80c3575) into develop (2b6dc40) will increase coverage by 0.05%.
The diff coverage is 92.10%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2479      +/-   ##
===========================================
+ Coverage    71.96%   72.01%   +0.05%     
===========================================
  Files          101      101              
  Lines        15064    15100      +36     
  Branches      2394     2399       +5     
===========================================
+ Hits         10841    10875      +34     
  Misses        3737     3737              
- Partials       486      488       +2     
Impacted Files Coverage Δ
azurelinuxagent/common/version.py 70.23% <ø> (-0.36%) ⬇️
azurelinuxagent/ga/update.py 89.03% <92.10%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b6dc40...80c3575. Read the comment docs.

@@ -1100,34 +1101,6 @@ def test_is_orphaned_returns_true_if_parent_does_not_exist(self):
with patch('os.getppid', return_value=42):
self.assertTrue(self.update_handler._is_orphaned)

def test_is_version_available(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the test cases for the functionality that was removed

Copy link
Member

@narrieta narrieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitting a few comments for now... still reviewing the code

azurelinuxagent/ga/update.py Show resolved Hide resolved
# (unless the CURRENT_VERSION == daemon version, but since we don't support downgrading
# below daemon version, we will never reach this code path if that's the scenario)
current_agent = next(agent for agent in self.agents if agent.version == CURRENT_VERSION)
current_agent.mark_failure(is_fatal=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a log statement explaining why this is being blacklisted? (and not mentioning "blacklisting", which an implementation thing, but rather that that specific version will not be executed because blah blah)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (though I did mention the word blacklisting because I feel its pretty self explanatory (and makes it easier to explain) even to folks outside our dev group who read the logs for debugging.

current_agent = next(agent for agent in self.agents if agent.version == CURRENT_VERSION)
current_agent.mark_failure(is_fatal=True)
except StopIteration:
logger.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this warning? this is the current version not finding itself, right? i think that would happen only if the current version is running as the daemon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that would happen only if the current version is running as the daemon

This scenario is already handled separately. If that is the case, we would not hit this code path. That is the primary reason for this warning, as that situation should not happen ever

azurelinuxagent/ga/update.py Show resolved Hide resolved
azurelinuxagent/ga/update.py Outdated Show resolved Hide resolved
@@ -923,59 +967,78 @@ def _check_and_download_agent_if_upgrade_available(self, protocol, base_version=
if not conf.get_autoupdate_enabled():
return False

def report_error(msg_, version=CURRENT_VERSION):
def report_error(msg_, version_=CURRENT_VERSION, op=WALAEventOperation.Download):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not default this WALAEventOperation.Download, but make it an explicit parameter. There are some usages where the default is being used to report issues not related do download

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which usage exactly did you see where we're reporting it as a download failure but its not one? This helper function is mainly to log those errors inside the _download_agent_if_upgrade_available function and instead of one call to it, all other calls for this function are Download errors, that's why I defaulted to that operation to make the code cleaner

@larohra larohra merged commit b27e475 into Azure:develop Jan 28, 2022
@larohra larohra deleted the requested-ver-upgrade branch January 28, 2022 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants