Skip to content

Commit 048f978

Browse files
committed
azurelinux2-warning
1 parent 6b05a20 commit 048f978

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/azure-cli/azure/cli/__main__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
start_time = timeit.default_timer()
1010

1111
import sys
12+
import os
1213

1314
from azure.cli.core import telemetry
1415
from azure.cli.core import get_default_cli
@@ -22,6 +23,12 @@
2223

2324
logger = get_logger(__name__)
2425

26+
AZURELINUX2_WARNING_MESSAGE = (
27+
"Azure CLI 2.74.0 is the last version available on Azure Linux (Mariner) 2.0 and will not receive updates. "
28+
"Consider migrating to Azure Linux 3.0 to use newer versions of Azure CLI. "
29+
"To disable this warning message, set AZURE_CLI_DISABLE_AZURELINUX2_WARNING environment variable to any value."
30+
)
31+
2532

2633
def cli_main(cli, args):
2734
return cli.invoke(args)
@@ -96,7 +103,6 @@ def cli_main(cli, args):
96103
else:
97104
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows')
98105
else:
99-
import os
100106
devnull = open(os.devnull, 'w')
101107
cmd.append('-y')
102108
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows', stdout=devnull)
@@ -115,6 +121,9 @@ def cli_main(cli, args):
115121
except Exception as ex: # pylint: disable=broad-except
116122
logger.debug("Intercept survey prompt failed. %s", str(ex))
117123

124+
if 'AZURE_CLI_DISABLE_AZURELINUX2_WARNING' not in os.environ:
125+
logger.warning(AZURELINUX2_WARNING_MESSAGE)
126+
118127
telemetry.set_init_time_elapsed("{:.6f}".format(init_finish_time - start_time))
119128
telemetry.set_invoke_time_elapsed("{:.6f}".format(invoke_finish_time - init_finish_time))
120129
telemetry.conclude()

0 commit comments

Comments
 (0)