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

Skip downgrade if requested version below daemon version #2850

Merged
merged 9 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azurelinuxagent/ga/agent_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def run(self, goal_state):
# as historically we don't support downgrades below daemon versions. So daemon will not pickup that requested version rather start with
# installed latest version again. When that happens agent go into loop of downloading the requested version, exiting and start again with same version.
#
raise Exception("Can't process the update as the requested version: {0} is < current daemon version: {1}".format(
raise Exception("as the requested version: {0} is < current daemon version: {1}".format(
Copy link
Member

Choose a reason for hiding this comment

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

Missing "Unable to update Agent:"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we append this msg when we catch the exception.

Copy link
Member

Choose a reason for hiding this comment

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

That is confusing. Myabe instead define an AgentUpdateError exception with a "reason" property and initialize the reason to "Requested version... is < ...."? The format the message where you handle the exception.

Copy link
Member

Choose a reason for hiding this comment

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

Or actually, you don't need the "reason" property. The type of the exception would be AgentUpdateError and the message "Requested version... is < ...."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

requested_version, daemon_version))

msg = "Goal state {0} is requesting a new agent version {1}, will update the agent before processing the goal state.".format(
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 @@ -248,7 +248,7 @@ def test_it_should_not_downgrade_below_daemon_version(self):
self.assertFalse(os.path.exists(self.agent_dir(downgraded_version)),
"New agent directory should not be found")
self.assertEqual(1, len([kwarg['message'] for _, kwarg in mock_telemetry.call_args_list if
"Can't process the update as the requested version" in kwarg[
"Unable to update Agent: as the requested version" in kwarg[
'message'] and kwarg[
'op'] == WALAEventOperation.AgentUpgrade]), "We should allow downgrade above daemon version")

Expand Down
Loading