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

Implementation of new conf flag AutoUpdate.UpdateToLatestVersion support #3027

Merged
merged 11 commits into from
Feb 6, 2024
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
4 changes: 2 additions & 2 deletions azurelinuxagent/common/agent_supported_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def __init__(self):

class _GAVersioningGovernanceFeature(AgentSupportedFeature):
"""
CRP would drive the RSM upgrade version if agent reports that it does support RSM upgrades with this flag otherwise CRP fallback to largest version.
CRP would drive the RSM update if agent reports that it does support RSM upgrades with this flag otherwise CRP fallback to largest version.
Agent doesn't report supported feature flag if auto update is disabled or old version of agent running that doesn't understand GA versioning.

Note: Especially Windows need this flag to report to CRP that GA doesn't support the updates. So linux adopted same flag to have a common solution.
"""

__NAME = SupportedFeatureNames.GAVersioningGovernance
__VERSION = "1.0"
__SUPPORTED = conf.get_autoupdate_enabled()
__SUPPORTED = conf.get_autoupdate_enabled() and conf.get_agent_update_to_latest_version()

def __init__(self):
super(_GAVersioningGovernanceFeature, self).__init__(name=self.__NAME,
Expand Down
15 changes: 7 additions & 8 deletions azurelinuxagent/common/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def load_conf_from_file(conf_file_path, conf=__conf__):
"ResourceDisk.EnableSwap": False,
"ResourceDisk.EnableSwapEncryption": False,
"AutoUpdate.Enabled": True,
"AutoUpdate.UpdateToLatestVersion": True,
"EnableOverProvisioning": True,
#
# "Debug" options are experimental and may be removed in later
Expand All @@ -136,7 +137,6 @@ def load_conf_from_file(conf_file_path, conf=__conf__):
"Debug.CgroupLogMetrics": False,
"Debug.CgroupDisableOnProcessCheckFailure": True,
"Debug.CgroupDisableOnQuotaCheckFailure": True,
"Debug.DownloadNewAgents": True,
"Debug.EnableAgentMemoryUsageCheck": False,
"Debug.EnableFastTrack": True,
"Debug.EnableGAVersioning": True
Expand Down Expand Up @@ -503,15 +503,14 @@ def get_monitor_network_configuration_changes(conf=__conf__):
return conf.get_switch("Monitor.NetworkConfigurationChanges", False)


def get_download_new_agents(conf=__conf__):
def get_agent_update_to_latest_version(conf=__conf__):
"""
If True, the agent go through update logic to look for new agents to download otherwise it will stop agent updates.
NOTE: AutoUpdate.Enabled controls whether the Agent downloads new update and also whether any downloaded updates are started or not, while DownloadNewAgents controls only the former.
AutoUpdate.Enabled == false -> Agent preinstalled on the image will process extensions and will not update (regardless of DownloadNewAgents flag)
AutoUpdate.Enabled == true and DownloadNewAgents == true, any update already downloaded will be started, and agent look for future updates
AutoUpdate.Enabled == true and DownloadNewAgents == false, any update already downloaded will be started, but the agent will not look for future updates
If set to True, agent will update to the latest version
Copy link
Member

Choose a reason for hiding this comment

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

we should add unit tests that codify these rules: use all combinations of y/n/absent for both flags and check the return value of UpdateToLatestVersion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

NOTE:
when turned on, both AutoEnabled.Enabled and UpdateToLatestVersion same meaning: update to latest version
Copy link
Contributor

@maddieford maddieford Jan 24, 2024

Choose a reason for hiding this comment

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

Suggested change
when turned on, both AutoEnabled.Enabled and UpdateToLatestVersion same meaning: update to latest version
when both turned on, both AutoUpdate.Enabled and AutoUpdate.UpdateToLatestVersion same meaning: update to latest version

when turned off, AutoEnabled.Enabled: reverts to pre-installed agent, UpdateToLatestVersion: uses latest version installed on the vm
Copy link
Contributor

@maddieford maddieford Jan 24, 2024

Choose a reason for hiding this comment

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

Suggested change
when turned off, AutoEnabled.Enabled: reverts to pre-installed agent, UpdateToLatestVersion: uses latest version installed on the vm
when turned off, AutoUpdate.Enabled: reverts to pre-installed agent, AutoUpdate.UpdateToLatestVersion: uses latest version already installed on the vm and does not download new agents

"""
return conf.get_switch("Debug.DownloadNewAgents", True)
return conf.get_switch("AutoUpdate.UpdateToLatestVersion", True)


def get_cgroup_check_period(conf=__conf__):
Expand Down
4 changes: 2 additions & 2 deletions azurelinuxagent/ga/agent_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def _get_agent_family_manifest(self, goal_state):
def run(self, goal_state, ext_gs_updated):

try:
# Ignore new agents if update is disabled. The latter flag only used in e2e tests.
if not conf.get_autoupdate_enabled() or not conf.get_download_new_agents():
# Ignore new agents if update is disabled.
if not conf.get_autoupdate_enabled() or not conf.get_agent_update_to_latest_version():
return

# Update the state only on new goal state
Expand Down
1 change: 1 addition & 0 deletions azurelinuxagent/ga/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ def log_if_agent_versioning_feature_disabled():
log_if_op_disabled("OS.EnableFirewall", conf.enable_firewall())
log_if_op_disabled("Extensions.Enabled", conf.get_extensions_enabled())
log_if_op_disabled("AutoUpdate.Enabled", conf.get_autoupdate_enabled())
log_if_op_disabled("AutoUpdate.UpdateToLatestVersion", conf.get_agent_update_to_latest_version())

if conf.enable_firewall():
log_if_int_changed_from_default("OS.EnableFirewallPeriod", conf.get_enable_firewall_period())
Expand Down
7 changes: 7 additions & 0 deletions config/alpine/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ OS.OpensslPath=None
OS.SshDir=/etc/ssh

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we know release #, i think it may be helpful to add which release added support for AutoUpdate.UpdateToLatestVersion.

Also maybe we can mention why we encourage users to transition to this new option (for example, if you revert to pre-installed agent you lose many bug fixes, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, adding wiki link. That has all other details.

# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/arch/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,15 @@ OS.SshDir=/etc/ssh
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/bigip/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ OS.SshdConfigPath=/config/ssh/sshd_config
OS.EnableRDMA=n

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
10 changes: 9 additions & 1 deletion config/clearlinux/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ OS.OpensslPath=None
# Set the path to SSH keys and configuration files
OS.SshDir=/etc/ssh

# Enable or disable self-update, default is enabled
# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

AutoUpdate.GAFamily=Prod

# Determine if the overprovisioning feature is enabled. If yes, hold extension
Expand Down
7 changes: 7 additions & 0 deletions config/coreos/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ OS.OpensslPath=None
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/debian/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,15 @@ OS.SshDir=/etc/ssh
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/devuan/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ OS.SshDir=/etc/ssh
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/freebsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ OS.SudoersDir=/usr/local/etc/sudoers.d
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/gaia/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ OS.SshDir=/etc/ssh
OS.EnableRDMA=n

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=n

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/iosxe/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,15 @@ OS.SshDir=/etc/ssh
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
8 changes: 8 additions & 0 deletions config/mariner/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ OS.OpensslPath=None
OS.SshDir=/etc/ssh

# Enable or disable self-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

AutoUpdate.GAFamily=Prod

# Determine if the overprovisioning feature is enabled. If yes, hold extension
Expand Down
7 changes: 7 additions & 0 deletions config/nsbsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,15 @@ Extension.LogDir=/log/azure
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=n

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/openbsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ OS.PasswordPath=/etc/master.passwd
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
8 changes: 8 additions & 0 deletions config/photonos/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ OS.OpensslPath=None
OS.SshDir=/etc/ssh

# Enable or disable self-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

AutoUpdate.GAFamily=Prod

# Determine if the overprovisioning feature is enabled. If yes, hold extension
Expand Down
7 changes: 7 additions & 0 deletions config/suse/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ OS.SshDir=/etc/ssh
# OS.CheckRdmaDriver=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/ubuntu/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ OS.SshDir=/etc/ssh
# OS.CheckRdmaDriver=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
7 changes: 7 additions & 0 deletions config/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@ OS.SshDir=/etc/ssh
# OS.CheckRdmaDriver=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it reverts to the pre-installed agent that comes with image
# Added new option AutoUpdate.UpdateToLatestVersion, and encourage users to transition to this new option
# However, this flag is retained for legacy reasons
# AutoUpdate.Enabled=y

# Enable or disable goal state processing auto-update, default is enabled
# When turned off, it remains on latest version installed on the vm
# AutoUpdate.UpdateToLatestVersion=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

Expand Down
11 changes: 11 additions & 0 deletions tests/ga/test_agent_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,14 @@ def test_it_should_save_rsm_state_of_the_most_recent_goal_state(self):
agent_update_handler.run(agent_update_handler._protocol.get_goal_state(), True)

self.assertFalse(os.path.exists(state_file), "The rsm file should be removed (file: {0})".format(state_file))

def test_it_should_not_update_to_latest_if_flag_is_disabled(self):
self.prepare_agents(count=1)

data_file = DATA_FILE.copy()
data_file['ext_conf'] = "wire/ext_conf.xml"
with self._get_agent_update_handler(test_data=data_file) as (agent_update_handler, _):
with patch("azurelinuxagent.common.conf.get_agent_update_to_latest_version", return_value=False):
agent_update_handler.run(agent_update_handler._protocol.get_goal_state(), True)

self._assert_agent_directories_exist_and_others_dont_exist(versions=[str(CURRENT_VERSION)])
2 changes: 1 addition & 1 deletion tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
EXPECTED_CONFIGURATION = \
"""AutoUpdate.Enabled = True
AutoUpdate.GAFamily = Prod
AutoUpdate.UpdateToLatestVersion = True
Autoupdate.Frequency = 3600
DVD.MountPoint = /mnt/cdrom/secure
Debug.AgentCpuQuota = 50
Expand All @@ -41,7 +42,6 @@
Debug.CgroupLogMetrics = False
Debug.CgroupMonitorExpiryTime = 2022-03-31
Debug.CgroupMonitorExtensionName = Microsoft.Azure.Monitor.AzureMonitorLinuxAgent
Debug.DownloadNewAgents = True
Debug.EnableAgentMemoryUsageCheck = False
Debug.EnableFastTrack = True
Debug.EnableGAVersioning = True
Expand Down
5 changes: 4 additions & 1 deletion tests_e2e/orchestrator/scripts/collect-logs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ logs_file_name="/tmp/waagent-logs.tgz"

echo "Collecting logs to $logs_file_name ..."

PYTHON=$(get-agent-python)
waagent_conf=$($PYTHON -c 'from azurelinuxagent.common.osutil import get_osutil; print(get_osutil().agent_conf_file_path)')

tar --exclude='journal/*' --exclude='omsbundle' --exclude='omsagent' --exclude='mdsd' --exclude='scx*' \
--exclude='*.so' --exclude='*__LinuxDiagnostic__*' --exclude='*.zip' --exclude='*.deb' --exclude='*.rpm' \
--warning=no-file-changed \
-czf "$logs_file_name" \
/var/log \
/var/lib/waagent/ \
/etc/waagent.conf
$waagent_conf

set -euxo pipefail

Expand Down
Loading
Loading