Skip to content

Commit 5602fac

Browse files
authored
Merge pull request #3421 from Azure/release-2.14.0.0
Release 2.14.0.1 (branch release-2.14.0.0) to master
2 parents 2aa5926 + 1cee9e8 commit 5602fac

File tree

169 files changed

+5039
-1492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+5039
-1492
lines changed

.github/workflows/ci_pr.yml

Lines changed: 88 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -8,132 +8,118 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
test-python-2_6-and-3_4-versions:
12-
11+
execute-tests:
12+
name: "Python ${{ matrix.python-version }} Unit Tests"
13+
runs-on: ubuntu-24.04
1314
strategy:
1415
fail-fast: false
1516
matrix:
1617
include:
18+
#
19+
# Some of the Python versions we test are not supported by the setup-python Github Action. For those versions, we use a
20+
# pre-built virtual environment.
21+
#
1722
- python-version: "2.6"
23+
use_virtual_environment: true
24+
- python-version: "2.7"
25+
use_virtual_environment: true
1826
- python-version: "3.4"
19-
20-
name: "Python ${{ matrix.python-version }} Unit Tests"
21-
runs-on: ubuntu-20.04
22-
container:
23-
image: ubuntu:24.04
24-
volumes:
25-
- /home/waagent:/home/waagent
26-
defaults:
27-
run:
28-
shell: bash -l {0}
29-
30-
env:
31-
NOSEOPTS: "--verbose"
32-
33-
steps:
34-
- uses: actions/checkout@v3
35-
36-
- name: Install Python ${{ matrix.python-version }} Virtual Environment
37-
run: |
38-
apt-get update
39-
apt-get install -y curl bzip2 sudo
40-
curl -sSf --retry 5 -o /tmp/python-${{ matrix.python-version }}.tar.bz2 https://dcrdata.blob.core.windows.net/python/python-${{ matrix.python-version }}.tar.bz2
41-
sudo tar xjf /tmp/python-${{ matrix.python-version }}.tar.bz2 --directory /
42-
#
43-
# TODO: Some unit tests create helper scripts that use 'python3' as shebang; we should probably port them to Bash, but installing Python 3 as a workaround for now.
44-
#
45-
if [[ "${{ matrix.python-version }}" == "2.6" ]]; then
46-
apt-get -y install python3
47-
fi
48-
#
49-
# The virtual environments for 2.6 and 3.4 have dependencies on OpenSSL 1.0, which is not available beyond Ubuntu 16. We use this script to patch the environments.
50-
#
51-
if [[ "${{ matrix.python-version }}" =~ ^2\.6|3\.4$ ]]; then
52-
./tests/python_eol/patch_python_venv.sh "${{ matrix.python-version }}"
53-
fi
54-
55-
- name: Execute Tests
56-
run: |
57-
source /home/waagent/virtualenv/python${{ matrix.python-version }}/bin/activate
58-
./ci/nosetests.sh
59-
exit $?
60-
61-
test-python-2_7:
62-
63-
strategy:
64-
fail-fast: false
65-
66-
name: "Python 2.7 Unit Tests"
67-
runs-on: ubuntu-20.04
68-
defaults:
69-
run:
70-
shell: bash -l {0}
71-
72-
env:
73-
NOSEOPTS: "--verbose"
74-
75-
steps:
76-
- uses: actions/checkout@v3
77-
78-
- name: Install Python 2.7
79-
run: |
80-
apt-get update
81-
apt-get install -y curl bzip2 sudo
82-
curl https://dcrdata.blob.core.windows.net/python/python-2.7.tar.bz2 -o python-2.7.tar.bz2
83-
sudo tar xjvf python-2.7.tar.bz2 --directory /
84-
85-
- name: Test with nosetests
86-
run: |
87-
source /home/waagent/virtualenv/python2.7.16/bin/activate
88-
./ci/nosetests.sh
89-
exit $?
90-
91-
test-current-python-versions:
92-
93-
strategy:
94-
fail-fast: false
95-
matrix:
96-
include:
27+
use_virtual_environment: true
9728
- python-version: "3.5"
98-
# workaround found in https://github.com/actions/setup-python/issues/866
99-
# for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5
100-
pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org"
29+
use_virtual_environment: true
10130
- python-version: "3.6"
31+
use_virtual_environment: true
10232
- python-version: "3.7"
33+
use_virtual_environment: true
10334
- python-version: "3.8"
10435
- python-version: "3.9"
10536
additional-nose-opts: "--with-coverage --cover-erase --cover-inclusive --cover-branches --cover-package=azurelinuxagent"
10637
- python-version: "3.10"
10738
- python-version: "3.11"
108-
109-
name: "Python ${{ matrix.python-version }} Unit Tests"
110-
runs-on: ubuntu-20.04
111-
112-
env:
113-
NOSEOPTS: "--with-timer ${{ matrix.additional-nose-opts }}"
39+
- python-version: "3.12"
11440

11541
steps:
116-
117-
- name: Checkout WALinuxAgent repo
42+
- name: Checkout WALinuxAgent
11843
uses: actions/checkout@v3
119-
44+
#
45+
# We either install Python and the test dependencies, or download a pre-built virtual environment, depending on the
46+
# use_virtual_environment flag.
47+
#
12048
- name: Setup Python ${{ matrix.python-version }}
49+
if: (!matrix.use_virtual_environment)
12150
uses: actions/setup-python@v4
12251
with:
12352
python-version: ${{ matrix.python-version }}
124-
env:
125-
PIP_TRUSTED_HOST: ${{ matrix.pip_trusted_host }}
12653

12754
- name: Install dependencies
55+
if: (!matrix.use_virtual_environment)
12856
id: install-dependencies
12957
run: |
13058
sudo env "PATH=$PATH" python -m pip install --upgrade pip
13159
sudo env "PATH=$PATH" pip install -r requirements.txt
13260
sudo env "PATH=$PATH" pip install -r test-requirements.txt
13361
sudo env "PATH=$PATH" pip install --upgrade pylint
13462
63+
- name: Setup Python ${{ matrix.python-version }} Virtual Environment
64+
if: matrix.use_virtual_environment
65+
id: install-venv
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y curl bzip2 sudo
69+
curl -sSf --retry 5 -o /tmp/python-${{ matrix.python-version }}.tar.bz2 https://dcrdata.blob.core.windows.net/python/python-${{ matrix.python-version }}.tar.bz2
70+
sudo tar xjf /tmp/python-${{ matrix.python-version }}.tar.bz2 --directory /
71+
#
72+
# The virtual environments have dependencies on old versions of OpenSSL (e.g 1.0/1.1) which are not available on Ubuntu 24. We use this script to patch the environments.
73+
#
74+
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then
75+
sudo ./tests/python_eol/patch_python_venv.sh "${{ matrix.python-version }}"
76+
fi
77+
78+
#
79+
# Execute the tests
80+
#
81+
- name: Execute Unit Tests
82+
run: |
83+
if [[ "${{ matrix.python-version }}" =~ ^3\.[1-9][0-9]+$ ]]; then
84+
#
85+
# Use pytest
86+
#
87+
./ci/pytest.sh
88+
else
89+
#
90+
# Use nosetests
91+
#
92+
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then # the pytest version on the venvs does not support the --with-timer option
93+
export NOSEOPTS="--verbose ${{ matrix.additional-nose-opts }}"
94+
else
95+
export NOSEOPTS="--verbose --with-timer ${{ matrix.additional-nose-opts }}"
96+
fi
97+
98+
#
99+
# If using a venv, activate it.
100+
#
101+
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then
102+
source /home/waagent/virtualenv/python${{ matrix.python-version }}/bin/activate
103+
fi
104+
105+
./ci/nosetests.sh
106+
fi
107+
108+
#
109+
# Execute pylint even when the tests fail (but only if the dependencies were installed successfully)
110+
#
111+
# The virtual environments for 2.6, 2.7, and 3.4 do not include pylint, so we skip those Python versions.
112+
#
135113
- name: Run pylint
114+
if: (!contains(fromJSON('["2.6", "2.7", "3.4"]'), matrix.python-version) && (success() || (failure() && steps.install-dependencies.outcome == 'success')))
136115
run: |
116+
#
117+
# If using a venv, activate it.
118+
#
119+
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then
120+
source /home/waagent/virtualenv/python${{ matrix.python-version }}/bin/activate
121+
fi
122+
137123
#
138124
# List of files/directories to be checked by pylint.
139125
# The end-to-end tests run only on Python 3.9 and we lint them only on that version.
@@ -153,15 +139,15 @@ jobs:
153139
# * 'no-self-use' ("R0201: Method could be a function") was moved to an optional extension on 3.8 and is no longer used by default. It needs
154140
# to be suppressed for previous versions (3.0-3.7), though.
155141
# * 'contextmanager-generator-missing-cleanup' are false positives if yield is used inside an if-else block for contextmanager generator functions.
156-
# (https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/contextmanager-generator-missing-cleanup.html).
142+
# (https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/contextmanager-generator-missing-cleanup.html).
157143
# This is not implemented on versions (3.0-3.7) Bad option value 'contextmanager-generator-missing-cleanup' (bad-option-value)
158-
# * 3.9-3.11 will produce "too-many-positional-arguments" for several methods that are having more than 5 args, so we suppress that warning.
144+
# * >= 3.9 will produce "too-many-positional-arguments" for several methods that are having more than 5 args, so we suppress that warning.
159145
# (R0917: Too many positional arguments (8/5) (too-many-positional-arguments))
160146
PYLINT_OPTIONS="--rcfile=ci/pylintrc --jobs=0"
161147
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then
162148
PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-member,too-many-positional-arguments --ignore=main.py"
163149
fi
164-
if [[ "${{ matrix.python-version }}" =~ ^3\.(10|11)$ ]]; then
150+
if [[ "${{ matrix.python-version }}" =~ ^3\.(10|11|12)$ ]]; then
165151
PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=too-many-positional-arguments"
166152
fi
167153
if [[ "${{ matrix.python-version }}" =~ ^3\.[0-7]$ ]]; then
@@ -173,16 +159,10 @@ jobs:
173159
174160
pylint $PYLINT_OPTIONS $PYLINT_FILES
175161
176-
- name: Execute Unit Tests
177-
if: success() || (failure() && steps.install-dependencies.outcome == 'success')
178-
run: |
179-
if [[ "${{ matrix.python-version }}" =~ ^3\.[1-9][0-9]+$ ]]; then
180-
./ci/pytest.sh
181-
else
182-
./ci/nosetests.sh
183-
fi
184-
185-
- name: Compile Coverage
162+
#
163+
# Lastly, compile code coverage
164+
#
165+
- name: Compile Code Coverage
186166
if: matrix.python-version == '3.9'
187167
run: |
188168
echo looking for coverage files :
@@ -191,7 +171,7 @@ jobs:
191171
sudo env "PATH=$PATH" coverage xml
192172
sudo env "PATH=$PATH" coverage report
193173
194-
- name: Upload Coverage
174+
- name: Upload Code Coverage
195175
if: matrix.python-version == '3.9'
196176
uses: codecov/codecov-action@v3
197177
with:

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
## Linux distributions support
55

6-
Our daily automation tests most of the [Linux distributions supported by Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/endorsed-distros); the Agent can be
7-
used on other distributions as well, but development, testing and support for those are done by the open source community.
6+
The list of distros we officially support is maintained at: [Linux distributions supported by Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/endorsed-distros). Our daily automation tests most of these distributions. The Agent can be
7+
used on other distributions as well, but development, testing and support for those are done by the open source community. This repo contains community-driven support for some distributions which are not officially supported by Azure.
88

99
Testing is done using the develop branch, which can be unstable. For a stable build please use the master branch instead.
1010

@@ -653,6 +653,15 @@ _Default: customscript,runcommand_
653653

654654
The list of extensions which will be excluded from cgroups limits. This should be comma separated.
655655

656+
#### __Protocol.EndpointDiscovery__
657+
658+
_Type: String_
659+
_Default: dhcp_
660+
661+
Determines how the agent will discover the [WireServer endpoint](https://learn.microsoft.com/en-us/azure/virtual-network/what-is-ip-address-168-63-129-16).
662+
Agent will use DHCP by default to discover the WireServer endpoint, but if this setting is 'static' the agent will use the known WireServer address (168.63.129.16).
663+
Possible options are "dhcp" (default) or "static".
664+
656665
### Telemetry
657666

658667
WALinuxAgent collects usage data and sends it to Microsoft to help improve our products and services. The data collected is used to track service health and

azurelinuxagent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def collect_logs(self, is_full_mode):
247247
for controller in tracked_controllers:
248248
if isinstance(controller, _CpuController):
249249
controller.initialize_cpu_usage()
250+
controller.track_throttle_time(True)
250251
break
251252
log_collector_monitor = get_log_collector_monitor_handler(tracked_controllers)
252253
log_collector_monitor.run()

azurelinuxagent/common/conf.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def load_conf_from_file(conf_file_path, conf=__conf__):
171171
"ResourceDisk.MountOptions": None,
172172
"ResourceDisk.Filesystem": "ext3",
173173
"AutoUpdate.GAFamily": "Prod",
174-
"Policy.PolicyFilePath": "/etc/waagent_policy.json"
174+
"Policy.PolicyFilePath": "/etc/waagent_policy.json",
175+
"Protocol.EndpointDiscovery": "dhcp"
175176
}
176177

177178

@@ -547,6 +548,19 @@ def get_auto_update_to_latest_version(conf=__conf__):
547548
return conf.get_switch("AutoUpdate.UpdateToLatestVersion", default)
548549

549550

551+
def get_protocol_endpoint_discovery(conf=__conf__):
552+
return conf.get("Protocol.EndpointDiscovery", "dhcp")
553+
554+
555+
def get_dhcp_discovery_enabled(conf=__conf__):
556+
"""
557+
Determines how the agent will discover the wireserver endpoint.
558+
If set to 'dhcp', the agent will use DHCP to get the wireserver endpoint.
559+
Otherwise, the agent will use the known wireserver endpoint (168.63.129.16).
560+
"""
561+
return get_protocol_endpoint_discovery(conf) == "dhcp"
562+
563+
550564
def get_cgroup_check_period(conf=__conf__):
551565
"""
552566
How often to perform checks on cgroups (are the processes in the cgroups as expected,
@@ -619,6 +633,7 @@ def get_enable_agent_memory_usage_check(conf=__conf__):
619633
"""
620634
return conf.get_switch("Debug.EnableAgentMemoryUsageCheck", False)
621635

636+
622637
def get_enable_fast_track(conf=__conf__):
623638
"""
624639
If True, the agent use FastTrack when retrieving goal states
@@ -692,3 +707,11 @@ def get_log_collector_initial_delay(conf=__conf__):
692707
NOTE: This option is experimental and may be removed in later versions of the Agent.
693708
"""
694709
return conf.get_int("Debug.LogCollectorInitialDelay", 5 * 60)
710+
711+
def get_enable_rsm_downgrade(conf=__conf__):
712+
"""
713+
If False, the agent will not downgrade to a lower version when a lower version is requested in the goal state.
714+
715+
Todo: Flag will be removed once we have a fix for rsm downgrade scenario.
716+
"""
717+
return conf.get_switch("Debug.EnableRsmDowngrade", False)

azurelinuxagent/common/dhcp.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import time
2121

2222
import azurelinuxagent.common.logger as logger
23+
from azurelinuxagent.common import conf
2324
from azurelinuxagent.common.exception import DhcpError
2425
from azurelinuxagent.common.osutil import get_osutil
2526
from azurelinuxagent.common.utils.restutil import KNOWN_WIRESERVER_IP
@@ -151,9 +152,15 @@ def send_dhcp_req(self):
151152
"""
152153
Check if DHCP is available
153154
"""
154-
dhcp_available = self.osutil.is_dhcp_available()
155-
if not dhcp_available:
156-
logger.info("send_dhcp_req: DHCP not available")
155+
dhcp_available = self.osutil.is_dhcp_available()
156+
# If user has DHCP disabled for their VM then the dhcp request will fail. The user can configure the agent to
157+
# use the known wire server ip instead.
158+
use_dhcp = conf.get_dhcp_discovery_enabled()
159+
if not dhcp_available or not use_dhcp:
160+
if not use_dhcp:
161+
logger.info("send_dhcp_req: DHCP usage for endpoint discovery is disabled (Protocol.EndpointDiscovery={0}). Will use known wireserver endpoint.".format(conf.get_protocol_endpoint_discovery()))
162+
elif not dhcp_available:
163+
logger.info("send_dhcp_req: DHCP not available")
157164
self.endpoint = KNOWN_WIRESERVER_IP
158165
return
159166

0 commit comments

Comments
 (0)