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

Add telemetry for azure slice and custom agent unit files #2150

Merged
merged 8 commits into from
Jan 27, 2021

Conversation

narrieta
Copy link
Member

Send telemetry if there are units named "azure*" and if there are unit files that override the default agent settings

@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #2150 (2a30aca) into develop (29d430f) will decrease coverage by 0.15%.
The diff coverage is 37.68%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2150      +/-   ##
===========================================
- Coverage    70.66%   70.50%   -0.16%     
===========================================
  Files           95       95              
  Lines        12993    13062      +69     
  Branches      1850     1859       +9     
===========================================
+ Hits          9181     9209      +28     
- Misses        3401     3437      +36     
- Partials       411      416       +5     
Impacted Files Coverage Δ
azurelinuxagent/common/cgroupconfigurator.py 69.70% <37.68%> (-10.78%) ⬇️
azurelinuxagent/common/cgroupapi.py 83.62% <0.00%> (+0.88%) ⬆️

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 29d430f...2a30aca. Read the comment docs.

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

match = re.match(r'\s?(azure[^\s]*)\s?', line, re.IGNORECASE)
if match is not None:
azure_unit_name = match.group(1)
azure_unit_description = line
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you break once you find your first match? Or maybe capture all the possible options (and make azure_unit_name an array instead?)

Copy link
Member Author

Choose a reason for hiding this comment

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

good point; i'll make it handle multiple instances (if any)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

azurelinuxagent/common/cgroupconfigurator.py Show resolved Hide resolved
for unit_file in agent_unit_files:
try:
with open(unit_file, "r") as file_object:
message = "Found a custom unit file for the agent: {0}\n{1}".format(unit_file, file_object.read())
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very cool and much needed! This would give us a very good idea on how many VMs/Customers are modifying us without us knowing!

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, it should be helpful. sample logging:

2021-01-27T00:51:34.078443Z INFO ExtHandler ExtHandler Found an Azure unit under -.slice: azure.slice loaded active active Slice for Azure VM Agent and Extensions
2021-01-27T00:51:34.091817Z INFO ExtHandler ExtHandler Found a custom unit file for the agent: /etc/systemd/system/walinuxagent.service
#
# NOTE:
#   This file hosted on WALinuxAgent repository only for reference purposes.
#   Please refer to a recent image to find out the up-to-date systemd unit file.
#

[Unit]
Description=Azure Linux Agent

After=network-online.target cloud-init.service
Wants=network-online.target sshd.service sshd-keygen.service

ConditionFileIsExecutable=/usr/sbin/waagent
ConditionPathExists=/etc/waagent.conf

[Service]
Type=simple
ExecStart=/usr/bin/python3 -u /usr/sbin/waagent -daemon
Restart=always

[Install]
WantedBy=multi-user.target


2021-01-27T00:51:34.092579Z INFO ExtHandler ExtHandler Found a custom unit file for the agent: /etc/systemd/system/walinuxagent.service.d/10-azure-walinuxagent.system.conf
[Service]
Slice=azure.slice
CPUAccounting=yes

2021-01-27T00:51:34.093055Z INFO ExtHandler ExtHandler Found a custom unit file for the agent: /etc/systemd/system/walinuxagent.service.d/20-azure-walinuxagent.system.conf
[Service]
Slice=azure.slice
MemoryAccounting=yes

kevinclark19a
kevinclark19a previously approved these changes Jan 27, 2021
larohra
larohra previously approved these changes Jan 27, 2021
@narrieta narrieta dismissed stale reviews from larohra and kevinclark19a via 93303fe January 27, 2021 19:39
@narrieta narrieta merged commit 3eb9a0c into Azure:develop Jan 27, 2021
@narrieta narrieta deleted the telemetry branch January 27, 2021 20:02
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