Skip to content

Commit cf2257d

Browse files
authored
{Packaging} Add warning message for Azure Linux 2.0 (#31545)
1 parent 6b05a20 commit cf2257d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 12 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,14 @@
2223

2324
logger = get_logger(__name__)
2425

26+
AZURELINUX2_WARNING_MESSAGE = (
27+
"Azure CLI 2.74.0 is the final version available on Azure Linux (Mariner) 2.0 and will not receive further "
28+
"updates. "
29+
"We recommend migrating to Azure Linux 3.0 to access newer versions of Azure CLI and continue receiving updates. "
30+
"For more information: https://go.microsoft.com/fwlink/?linkid=2322402. "
31+
"To disable this warning message, set AZURE_CLI_DISABLE_AZURELINUX2_WARNING environment variable to any value. "
32+
)
33+
2534

2635
def cli_main(cli, args):
2736
return cli.invoke(args)
@@ -96,7 +105,6 @@ def cli_main(cli, args):
96105
else:
97106
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows')
98107
else:
99-
import os
100108
devnull = open(os.devnull, 'w')
101109
cmd.append('-y')
102110
upgrade_exit_code = subprocess.call(cmd, shell=platform.system() == 'Windows', stdout=devnull)
@@ -115,6 +123,9 @@ def cli_main(cli, args):
115123
except Exception as ex: # pylint: disable=broad-except
116124
logger.debug("Intercept survey prompt failed. %s", str(ex))
117125

126+
if 'AZURE_CLI_DISABLE_AZURELINUX2_WARNING' not in os.environ:
127+
logger.warning(AZURELINUX2_WARNING_MESSAGE)
128+
118129
telemetry.set_init_time_elapsed("{:.6f}".format(init_finish_time - start_time))
119130
telemetry.set_invoke_time_elapsed("{:.6f}".format(invoke_finish_time - init_finish_time))
120131
telemetry.conclude()

0 commit comments

Comments
 (0)