diff --git a/azurelinuxagent/common/conf.py b/azurelinuxagent/common/conf.py index 6554ab308..cb929e433 100644 --- a/azurelinuxagent/common/conf.py +++ b/azurelinuxagent/common/conf.py @@ -129,6 +129,7 @@ def load_conf_from_file(conf_file_path, conf=__conf__): "ResourceDisk.EnableSwapEncryption": False, "AutoUpdate.Enabled": True, "EnableOverProvisioning": True, + "GAUpdates.Enabled": True, # # "Debug" options are experimental and may be removed in later # versions of the Agent. @@ -502,6 +503,14 @@ def get_monitor_network_configuration_changes(conf=__conf__): return conf.get_switch("Monitor.NetworkConfigurationChanges", False) +def get_ga_updates_enabled(conf=__conf__): + """ + If True, the agent go through update logic to look for new agents otherwise it will stop agent updates. + NOTE: This option is needed in e2e tests to control agent updates. + """ + return conf.get_switch("GAUpdates.Enabled", True) + + def get_cgroup_check_period(conf=__conf__): """ How often to perform checks on cgroups (are the processes in the cgroups as expected, diff --git a/azurelinuxagent/ga/agent_update.py b/azurelinuxagent/ga/agent_update.py index ba9861324..206a628ea 100644 --- a/azurelinuxagent/ga/agent_update.py +++ b/azurelinuxagent/ga/agent_update.py @@ -182,8 +182,8 @@ def __log_event(level, msg_, success_=True): def run(self, goal_state): try: - # Ignore new agents if update is disabled - if not self._autoupdate_enabled: + # Ignore new agents if update is disabled. The latter flag only used in e2e tests. + if not self._autoupdate_enabled or not conf.get_ga_updates_enabled(): return self._gs_id = goal_state.extensions_goal_state.id diff --git a/tests/ga/test_agent_update.py b/tests/ga/test_agent_update.py index 5386bdaf6..f484a1dae 100644 --- a/tests/ga/test_agent_update.py +++ b/tests/ga/test_agent_update.py @@ -117,7 +117,7 @@ def test_it_should_not_agent_update_if_last_attempted_update_time_not_elapsed(se with self.__get_agent_update_handler(test_data=data_file, autoupdate_frequency=10) as (agent_update_handler, mock_telemetry): agent_update_handler._protocol.mock_wire_data.set_extension_config_requested_version(version) agent_update_handler._protocol.mock_wire_data.set_incarnation(2) - agent_update_handler._protocol.update_goal_state() + agent_update_handler._protocol.client.update_goal_state() agent_update_handler.run(agent_update_handler._protocol.get_goal_state()) self.__assert_agent_requested_version_in_goal_state(mock_telemetry, inc=2, version=version) @@ -151,7 +151,7 @@ def test_it_should_not_agent_update_if_requested_version_is_same_as_current_vers agent_update_handler._protocol.mock_wire_data.set_extension_config_requested_version( str(CURRENT_VERSION)) agent_update_handler._protocol.mock_wire_data.set_incarnation(2) - agent_update_handler._protocol.update_goal_state() + agent_update_handler._protocol.client.update_goal_state() agent_update_handler.run(agent_update_handler._protocol.get_goal_state()) self.assertEqual(0, len([kwarg['message'] for _, kwarg in mock_telemetry.call_args_list if "requesting a new agent version" in kwarg['message'] and kwarg[ @@ -187,7 +187,7 @@ def test_it_should_downgrade_agent_if_requested_version_is_available_less_than_c with self.__get_agent_update_handler(test_data=data_file) as (agent_update_handler, mock_telemetry): agent_update_handler._protocol.mock_wire_data.set_extension_config_requested_version(downgraded_version) agent_update_handler._protocol.mock_wire_data.set_incarnation(2) - agent_update_handler._protocol.update_goal_state() + agent_update_handler._protocol.client.update_goal_state() with self.assertRaises(AgentUpgradeExitException) as context: agent_update_handler.run(agent_update_handler._protocol.get_goal_state()) self.__assert_agent_requested_version_in_goal_state(mock_telemetry, inc=2, version=downgraded_version) @@ -208,7 +208,7 @@ def test_handles_if_requested_version_not_found_in_pkgs_to_download(self): with self.__get_agent_update_handler(test_data=data_file) as (agent_update_handler, mock_telemetry): agent_update_handler._protocol.mock_wire_data.set_extension_config_requested_version(version) agent_update_handler._protocol.mock_wire_data.set_incarnation(2) - agent_update_handler._protocol.update_goal_state() + agent_update_handler._protocol.client.update_goal_state() agent_update_handler.run(agent_update_handler._protocol.get_goal_state()) self.__assert_agent_requested_version_in_goal_state(mock_telemetry, inc=2, version=version) @@ -245,7 +245,7 @@ def test_it_should_report_update_status_with_success(self): agent_update_handler._protocol.mock_wire_data.set_extension_config_requested_version( str(CURRENT_VERSION)) agent_update_handler._protocol.mock_wire_data.set_incarnation(2) - agent_update_handler._protocol.update_goal_state() + agent_update_handler._protocol.client.update_goal_state() agent_update_handler.run(agent_update_handler._protocol.get_goal_state()) vm_agent_update_status = agent_update_handler.get_vmagent_update_status() self.assertEqual(VMAgentUpdateStatuses.Success, vm_agent_update_status.status) diff --git a/tests/test_agent.py b/tests/test_agent.py index 2f80d695e..5ec1c9cdd 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -51,6 +51,7 @@ Extensions.Enabled = True Extensions.GoalStatePeriod = 6 Extensions.InitialGoalStatePeriod = 6 +GAUpdates.Enabled = True HttpProxy.Host = None HttpProxy.Port = None Lib.Dir = /var/lib/waagent