Skip to content

Commit

Permalink
GA versioning refactor plus fetch new rsm properties. (#2974)
Browse files Browse the repository at this point in the history
* GA versioning refactor

* added comment

* added abstract decorator

* undo abstract change

* update names

* addressed comments

* pylint

* agent family

* state name

* address comments

* conf change
  • Loading branch information
nagworld9 committed Dec 14, 2023
1 parent 5a41542 commit 56543ed
Show file tree
Hide file tree
Showing 25 changed files with 1,423 additions and 521 deletions.
14 changes: 7 additions & 7 deletions azurelinuxagent/common/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,28 +622,28 @@ def get_etp_collection_period(conf=__conf__):
return conf.get_int("Debug.EtpCollectionPeriod", 300)


def get_hotfix_upgrade_frequency(conf=__conf__):
def get_self_update_hotfix_frequency(conf=__conf__):
"""
Determines the frequency to check for Hotfix upgrades (<Patch>.<Build> version changed in new upgrades).
Determines the frequency to check for Hotfix upgrades (<Build> version changed in new upgrades).
NOTE: This option is experimental and may be removed in later versions of the Agent.
"""
return conf.get_int("Debug.AutoUpdateHotfixFrequency", 4 * 60 * 60)
return conf.get_int("Debug.SelfUpdateHotfixFrequency", 4 * 60 * 60)


def get_normal_upgrade_frequency(conf=__conf__):
def get_self_update_regular_frequency(conf=__conf__):
"""
Determines the frequency to check for Normal upgrades (<Major>.<Minor> version changed in new upgrades).
Determines the frequency to check for regular upgrades (<Major>.<Minor>.<patch> version changed in new upgrades).
NOTE: This option is experimental and may be removed in later versions of the Agent.
"""
return conf.get_int("Debug.AutoUpdateNormalFrequency", 24 * 60 * 60)
return conf.get_int("Debug.SelfUpdateRegularFrequency", 24 * 60 * 60)


def get_enable_ga_versioning(conf=__conf__):
"""
If True, the agent looks for rsm updates(checking requested version in GS) otherwise it will fall back to self-update and finds the highest version from PIR.
NOTE: This option is experimental and may be removed in later versions of the Agent.
"""
return conf.get_switch("Debug.EnableGAVersioning", False)
return conf.get_switch("Debug.EnableGAVersioning", True)


def get_firewall_rules_log_period(conf=__conf__):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ def _parse_extensions_config(self, xml_text, wire_client):
for ga_family in ga_families:
name = findtext(ga_family, "Name")
version = findtext(ga_family, "Version")
is_version_from_rsm = findtext(ga_family, "IsVersionFromRSM")
is_vm_enabled_for_rsm_upgrades = findtext(ga_family, "IsVMEnabledForRSMUpgrades")
uris_list = find(ga_family, "Uris")
uris = findall(uris_list, "Uri")
family = VMAgentFamily(name, version)
family = VMAgentFamily(name)
family.version = version
if is_version_from_rsm is not None: # checking None because converting string to lowercase
family.is_version_from_rsm = is_version_from_rsm.lower() == "true"
if is_vm_enabled_for_rsm_upgrades is not None: # checking None because converting string to lowercase
family.is_vm_enabled_for_rsm_upgrades = is_vm_enabled_for_rsm_upgrades.lower() == "true"
for uri in uris:
family.uris.append(gettext(uri))
self._agent_families.append(family)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def _parse_agent_manifests(self, vm_settings):
# {
# "name": "Prod",
# "version": "9.9.9.9",
# "isVersionFromRSM": true,
# "isVMEnabledForRSMUpgrades": true,
# "uris": [
# "https://zrdfepirv2cdm03prdstr01a.blob.core.windows.net/7d89d439b79f4452950452399add2c90/Microsoft.OSTCLinuxAgent_Prod_uscentraleuap_manifest.xml",
# "https://ardfepirv2cdm03prdstr01a.blob.core.windows.net/7d89d439b79f4452950452399add2c90/Microsoft.OSTCLinuxAgent_Prod_uscentraleuap_manifest.xml"
Expand All @@ -267,10 +269,15 @@ def _parse_agent_manifests(self, vm_settings):
for family in families:
name = family["name"]
version = family.get("version")
is_version_from_rsm = family.get("isVersionFromRSM")
is_vm_enabled_for_rsm_upgrades = family.get("isVMEnabledForRSMUpgrades")
uris = family.get("uris")
if uris is None:
uris = []
agent_family = VMAgentFamily(name, version)
agent_family = VMAgentFamily(name)
agent_family.version = version
agent_family.is_version_from_rsm = is_version_from_rsm
agent_family.is_vm_enabled_for_rsm_upgrades = is_vm_enabled_for_rsm_upgrades
for u in uris:
agent_family.uris.append(u)
self._agent_families.append(agent_family)
Expand Down
24 changes: 8 additions & 16 deletions azurelinuxagent/common/protocol/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from azurelinuxagent.common.datacontract import DataContract, DataContractList
from azurelinuxagent.common.future import ustr
from azurelinuxagent.common.utils.flexible_version import FlexibleVersion
from azurelinuxagent.common.utils.textutil import getattrib
from azurelinuxagent.common.version import DISTRO_VERSION, DISTRO_NAME, CURRENT_VERSION

Expand Down Expand Up @@ -69,23 +68,16 @@ def __init__(self):


class VMAgentFamily(object):
def __init__(self, name, version=None):
def __init__(self, name):
self.name = name
# This is the Requested version as specified by the Goal State, it defaults to 0.0.0.0 if not specified in GS
self.requested_version_string = VERSION_0 if version is None else version
self.uris = []

@property
def requested_version(self):
return FlexibleVersion(self.requested_version_string)
# Two-state: None, string. Set to None if version not specified in the GS
self.version = None
# Tri-state: None, True, False. Set to None if this property not specified in the GS.
self.is_version_from_rsm = None
# Tri-state: None, True, False. Set to None if this property not specified in the GS.
self.is_vm_enabled_for_rsm_upgrades = None

@property
def is_requested_version_specified(self):
"""
If we don't get any requested_version from the GS, we default it to 0.0.0.0.
This property identifies if a requested Version was passed in the GS or not.
"""
return self.requested_version > FlexibleVersion(VERSION_0)
self.uris = []

def __repr__(self):
return self.__str__()
Expand Down
Loading

0 comments on commit 56543ed

Please sign in to comment.