Skip to content

Commit

Permalink
Ignore dependencies when the extension does not have any settings (#2957
Browse files Browse the repository at this point in the history
)

* Ignore dependencies when the extension does not have any settings

* Remove message

---------

Co-authored-by: narrieta <narrieta>
  • Loading branch information
narrieta authored Oct 26, 2023
1 parent 4a479c7 commit 79bc12c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions azurelinuxagent/common/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class WALAEventOperation:
OpenSsl = "OpenSsl"
Partition = "Partition"
PersistFirewallRules = "PersistFirewallRules"
ProvisionAfterExtensions = "ProvisionAfterExtensions"
PluginSettingsVersionMismatch = "PluginSettingsVersionMismatch"
InvalidExtensionConfig = "InvalidExtensionConfig"
Provision = "Provision"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from azurelinuxagent.common import logger
from azurelinuxagent.common.AgentGlobals import AgentGlobals
from azurelinuxagent.common.event import WALAEventOperation, add_event
from azurelinuxagent.common.future import ustr
from azurelinuxagent.common.protocol.extensions_goal_state import ExtensionsGoalState, GoalStateChannel, VmSettingsParseError
from azurelinuxagent.common.protocol.restapi import VMAgentFamily, Extension, ExtensionRequestedState, ExtensionSettings
Expand Down Expand Up @@ -492,11 +493,28 @@ def _parse_dependency_level(depends_on, extension):
length = len(depends_on)
if length > 1:
raise Exception('dependsOn should be an array with exactly one item for single-config extensions ({0}) (got {1})'.format(extension.name, depends_on))
elif length == 0:
if length == 0:
logger.warn('dependsOn is an empty array for extension {0}; setting the dependency level to 0'.format(extension.name))
extension.settings[0].dependencyLevel = 0
dependency_level = 0
else:
extension.settings[0].dependencyLevel = depends_on[0]['dependencyLevel']
dependency_level = depends_on[0]['dependencyLevel']
depends_on_extension = depends_on[0].get('dependsOnExtension')
if depends_on_extension is None:
# TODO: Consider removing this check and its telemetry after a few releases if we do not receive any telemetry indicating
# that dependsOnExtension is actually missing from the vmSettings
message = 'Missing dependsOnExtension on extension {0}'.format(extension.name)
logger.warn(message)
add_event(WALAEventOperation.ProvisionAfterExtensions, message=message, is_success=False, log_event=False)
else:
message = '{0} depends on {1}'.format(extension.name, depends_on_extension)
logger.info(message)
add_event(WALAEventOperation.ProvisionAfterExtensions, message=message, is_success=True, log_event=False)
if len(extension.settings) == 0:
message = 'Extension {0} does not have any settings. Will ignore dependency (dependency level: {1})'.format(extension.name, dependency_level)
logger.warn(message)
add_event(WALAEventOperation.ProvisionAfterExtensions, message=message, is_success=False, log_event=False)
else:
extension.settings[0].dependencyLevel = dependency_level
else:
# multi-config
settings_by_name = {}
Expand Down
3 changes: 0 additions & 3 deletions azurelinuxagent/ga/agent_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ def __check_if_downgrade_is_requested_and_allowed(self, requested_version):
"""
if not self._is_requested_version_update:
if requested_version < CURRENT_VERSION:
msg = "Downgrade requested in the GoalState, but downgrades are not supported for self-update version:{0}, " \
"skipping agent update".format(requested_version)
self.__log_event(LogLevel.INFO, msg)
return False
return True

Expand Down

0 comments on commit 79bc12c

Please sign in to comment.