|
19 | 19 | using Microsoft.VisualStudio.Services.Agent.Util;
|
20 | 20 | using Microsoft.VisualStudio.Services.Agent.Worker.Container;
|
21 | 21 | using Microsoft.VisualStudio.Services.Agent.Worker.Handlers;
|
| 22 | +using Microsoft.VisualStudio.Services.Agent.Worker.Telemetry; |
22 | 23 | using Microsoft.VisualStudio.Services.Common;
|
23 | 24 | using Microsoft.Win32;
|
24 | 25 | using Newtonsoft.Json;
|
@@ -767,49 +768,37 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta
|
767 | 768 | }
|
768 | 769 | }
|
769 | 770 |
|
770 |
| - bool useNode20InUnsupportedSystem = AgentKnobs.UseNode20InUnsupportedSystem.GetValue(executionContext).AsBoolean(); |
771 |
| - |
772 |
| - if(!useNode20InUnsupportedSystem) |
| 771 | + if (PlatformUtil.RunningOnLinux) |
773 | 772 | {
|
774 |
| - var node20 = container.TranslateToContainerPath(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeHandler.Node20_1Folder, "bin", $"node{IOUtil.ExeExtension}")); |
| 773 | + bool useNode20InUnsupportedSystem = AgentKnobs.UseNode20InUnsupportedSystem.GetValue(executionContext).AsBoolean(); |
775 | 774 |
|
776 |
| - string node20TestCmd = $"bash -c \"{node20} -v\""; |
777 |
| - List<string> nodeInfo = await DockerExec(executionContext, container.ContainerId, node20TestCmd, noExceptionOnError: true); |
778 |
| - if (nodeInfo.Count > 0) |
| 775 | + if (!useNode20InUnsupportedSystem) |
779 | 776 | {
|
780 |
| - foreach(var nodeInfoLine in nodeInfo) |
| 777 | + var node20 = container.TranslateToContainerPath(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeHandler.Node20_1Folder, "bin", $"node{IOUtil.ExeExtension}")); |
| 778 | + |
| 779 | + string node20TestCmd = $"bash -c \"{node20} -v\""; |
| 780 | + List<string> nodeVersionOutput = await DockerExec(executionContext, container.ContainerId, node20TestCmd, noExceptionOnError: true); |
| 781 | + |
| 782 | + container.NeedsNode16Redirect = WorkerUtilities.IsCommandResultGlibcError(executionContext, nodeVersionOutput, out string nodeInfoLine); |
| 783 | + |
| 784 | + if (container.NeedsNode16Redirect) |
781 | 785 | {
|
782 |
| - // detect example error from node 20 attempting to run on Ubuntu18: |
783 |
| - // /__a/externals/node20/bin/node: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /__a/externals/node20/bin/node) |
784 |
| - // /__a/externals/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__a/externals/node20/bin/node) |
785 |
| - // /__a/externals/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /__a/externals/node20/bin/node) |
786 |
| - if(nodeInfoLine.Contains("version `GLIBC_2.28' not found") |
787 |
| - || nodeInfoLine.Contains("version `GLIBC_2.25' not found") |
788 |
| - || nodeInfoLine.Contains("version `GLIBC_2.27' not found")) |
789 |
| - { |
790 |
| - executionContext.Debug($"GLIBC error found executing node -v; setting NeedsNode16Redirect: {nodeInfoLine}"); |
791 |
| - executionContext.Warning($"The container operating system doesn't support Node20. Using Node16 instead. " + |
792 |
| - "Please upgrade the operating system of the container to ensure compatibility with Node20 tasks: " + |
793 |
| - "https://github.com/nodesource/distributions"); |
794 |
| - |
795 |
| - container.NeedsNode16Redirect = true; |
796 |
| - } |
| 786 | + PublishTelemetry( |
| 787 | + executionContext, |
| 788 | + new Dictionary<string, string> |
| 789 | + { |
| 790 | + { "ContainerNode20to16Fallback", container.NeedsNode16Redirect.ToString() } |
| 791 | + } |
| 792 | + ); |
797 | 793 | }
|
798 | 794 | }
|
| 795 | + |
799 | 796 | }
|
800 | 797 |
|
801 | 798 | if (!string.IsNullOrEmpty(containerUserName))
|
802 | 799 | {
|
803 | 800 | container.CurrentUserName = containerUserName;
|
804 | 801 | }
|
805 |
| - |
806 |
| - if(!useNode20InUnsupportedSystem) |
807 |
| - { |
808 |
| - if(container.NeedsNode16Redirect) |
809 |
| - { |
810 |
| - container.CustomNodePath = container.TranslateToContainerPath(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeHandler.Node16Folder, "bin", $"node{IOUtil.ExeExtension}")); |
811 |
| - } |
812 |
| - } |
813 | 802 | }
|
814 | 803 | }
|
815 | 804 | }
|
@@ -1039,5 +1028,23 @@ private static void ThrowIfWrongWindowsVersion(IExecutionContext executionContex
|
1039 | 1028 | throw new ArgumentOutOfRangeException(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId");
|
1040 | 1029 | }
|
1041 | 1030 | }
|
| 1031 | + |
| 1032 | + private void PublishTelemetry( |
| 1033 | + IExecutionContext executionContext, |
| 1034 | + object telemetryData, |
| 1035 | + string feature = nameof(ContainerOperationProvider) |
| 1036 | +) |
| 1037 | + { |
| 1038 | + var cmd = new Command("telemetry", "publish") |
| 1039 | + { |
| 1040 | + Data = JsonConvert.SerializeObject(telemetryData, Formatting.None) |
| 1041 | + }; |
| 1042 | + cmd.Properties.Add("area", "PipelinesTasks"); |
| 1043 | + cmd.Properties.Add("feature", feature); |
| 1044 | + |
| 1045 | + var publishTelemetryCmd = new TelemetryCommandExtension(); |
| 1046 | + publishTelemetryCmd.Initialize(HostContext); |
| 1047 | + publishTelemetryCmd.ProcessCommand(executionContext, cmd); |
| 1048 | + } |
1042 | 1049 | }
|
1043 | 1050 | }
|
0 commit comments