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

Parse and compare agent manifests #2416

Merged
merged 7 commits into from
Nov 19, 2021
Merged

Conversation

narrieta
Copy link
Member

Parse the agent manifests in vmSettings and compare them against extensionsConfig.

In the process, I removed VMAgentManifestUri, VMAgentManifestList, ExtHandlerVersionUri, and ExtHandlerPackageUri and replaced them with simple types (strings and lists)

from azurelinuxagent.common.utils.textutil import parse_doc, parse_json, findall, find, findtext, getattrib, gettext, format_exception, \
is_str_none_or_whitespace, is_str_empty


class ExtensionsGoalStateFromExtensionsConfig(ExtensionsGoalState):
def __init__(self, incarnation, xml_text, wire_client=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

The default values (None) for wire_client was a left over of a test I was doing during my previous PR.

@codecov
Copy link

codecov bot commented Nov 18, 2021

Codecov Report

Merging #2416 (8e6a46a) into develop (eff8187) will increase coverage by 0.00%.
The diff coverage is 85.86%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2416   +/-   ##
========================================
  Coverage    71.64%   71.65%           
========================================
  Files          100      100           
  Lines        14631    14672   +41     
  Branches      2092     2097    +5     
========================================
+ Hits         10483    10513   +30     
- Misses        3684     3692    +8     
- Partials       464      467    +3     
Impacted Files Coverage Δ
...protocol/extensions_goal_state_from_vm_settings.py 84.09% <75.00%> (-2.03%) ⬇️
azurelinuxagent/common/protocol/wire.py 80.53% <77.77%> (-0.05%) ⬇️
...inuxagent/common/protocol/extensions_goal_state.py 87.50% <88.23%> (-0.36%) ⬇️
azurelinuxagent/common/protocol/restapi.py 97.70% <92.85%> (-0.62%) ⬇️
...ol/extensions_goal_state_from_extensions_config.py 92.19% <100.00%> (+0.05%) ⬆️
azurelinuxagent/ga/exthandlers.py 85.74% <100.00%> (ø)
azurelinuxagent/ga/update.py 89.45% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eff8187...8e6a46a. Read the comment docs.

}
}
]
<Extensions version="1.0.0.0" goalStateIncarnation="10"><GuestAgentExtension xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the test data from an actual DCR run to get the latest changes in HostGAPlugin

]
}
]
}</RuntimeSettings>
Copy link
Member Author

Choose a reason for hiding this comment

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

I added the extensions with protected settings to this data file and removed the -protected-settings. files. This way I do not need to update 2 sets of data files when I want to take an update of the HostGAPlugin schema.

larohra
larohra previously approved these changes Nov 18, 2021
Copy link
Contributor

@larohra larohra left a comment

Choose a reason for hiding this comment

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

some minor comments, else LGTM

@@ -115,6 +119,7 @@ def compare_attribute(attribute):
compare_attribute("status_upload_blob_type")
compare_attribute("required_features")
compare_attribute("on_hold")
compare_attribute("agent_manifests")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the comparison of ext-handlers going to be done in a separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, all this refactoring is affecting a lot of code and those changes need to be done gradually

class VMAgentManifestUri(DataContract):
def __init__(self, uri=None):
self.uri = uri
class VMAgentManifest(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the refactoring!

"extensionGoalStatesSource": "Fabric",
"StatusUploadBlob": {
"statusUploadBlob": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we handle this on our end, but is the casing not guaranteed from HostGA? I remember Rohit mentioning something about fixing this, is that not in yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

we need to keep doing this until all the nodes in the fleet are updated with the newest HostGAPlugin (which will take a loong time, unfortunately)

Copy link
Contributor

Choose a reason for hiding this comment

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

totally understand that, was just curious to know if this was being handled by HostGA or not. Like if its supposed to be handled properly by HostGA and still we're seeing discrepancy we should probably let Rohit know about it too as it might be a regression there

Copy link
Member Author

@narrieta narrieta Nov 18, 2021

Choose a reason for hiding this comment

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

At some point we should be ready to declare "version W.X.Y.Z of the HostGAPlugin is ready and all the fleet is updated"... at that point we'll add a single check for that version and remove all those workarounds/checks (case-insensitive dictionary, check for > 112, comparison of goal states, etc). Discrepancies would pop up then. Right now it is not worth checking the case of properties (I haven't seen any during my manual tests, BTW).

from azurelinuxagent.common.protocol.restapi import Extension, ExtHandler, ExtHandlerVersionUri, VMAgentManifest, \
VMAgentManifestUri, ExtensionState, ExtHandlerList, VMAgentManifestList, InVMGoalStateMetaData
from azurelinuxagent.common.protocol.restapi import Extension, ExtHandler, VMAgentManifest, \
ExtensionState, ExtHandlerList, InVMGoalStateMetaData
from azurelinuxagent.common.utils.textutil import parse_doc, parse_json, findall, find, findtext, getattrib, gettext, format_exception, \
is_str_none_or_whitespace, is_str_empty


class ExtensionsGoalStateFromExtensionsConfig(ExtensionsGoalState):
Copy link
Contributor

Choose a reason for hiding this comment

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

can we test for agent_manifest from extension_config like we have for vm_settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure i get your comment @nagworld9 ... the extension config stuff is existing code and has existing tests. is that what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, the existing tests not covering agent manifests checks. I don't mind leaving it now but may be when you touch the test file again it's worthwhile to consider testing.
https://github.com/Azure/WALinuxAgent/blob/develop/tests/protocol/test_extensions_goal_state_from_extensions_config.py#L8

Copy link
Member Author

@narrieta narrieta Nov 19, 2021

Choose a reason for hiding this comment

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

yes, the existing code lacks some tests. retrofitting tests to that code would be costly. do feel free to add tests where you consider it worth the effort

nagworld9
nagworld9 previously approved these changes Nov 19, 2021
Copy link
Contributor

@nagworld9 nagworld9 left a comment

Choose a reason for hiding this comment

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

LGTM

@narrieta narrieta dismissed stale reviews from nagworld9 and larohra via 8e6a46a November 19, 2021 15:34
@narrieta narrieta merged commit a73462e into Azure:develop Nov 19, 2021
@narrieta narrieta deleted the agent-manifest branch November 19, 2021 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants