You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于AKS的Azure DevOps Ubuntu构建代理执行任务时Dynatrace报错

AKS中Azure DevOps构建代理Dynatrace语法错误排查请求

我们在AKS中部署了基于Ubuntu的Azure DevOps构建代理,已成功加入代理池并可执行流水线,但执行所有任务时均出现Dynatrace相关异常错误。以下是使用的配置文件及报错信息:

DockerFile

FROM ubuntu:18.04

# To make it easier for build and release pipelines to run apt-get,
# configure apt to not require confirmation (assume the -y argument by default)
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    jq \
    git \
  && rm -rf /var/lib/apt/lists/*

RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \
  && rm -rf /var/lib/apt/lists/*

# Can be 'linux-x64', 'linux-arm64', 'linux-arm', 'rhel.6-x64'.
ENV TARGETARCH=linux-x64

WORKDIR /azp

COPY ./start.sh .
RUN chmod +x start.sh

ENTRYPOINT ["./start.sh"]

AKS Deployment File

apiVersion: apps/v1
kind: Deployment
metadata:
  name: azdevops-deployment
  labels:
    app: azdevops-agent
spec:
  replicas: 1 #here is the configuration for the actual agent always running
  selector:
    matchLabels:
      app: azdevops-agent
  template:
    metadata:
      labels:
        app: azdevops-agent
    spec:
      containers:
      - name: kubepodcreation
        image: customised and built docker image
        env:
          - name: AZP_URL
            valueFrom:
              secretKeyRef:
                name: azdevops
                key: AZP_URL
          - name: AZP_TOKEN
            valueFrom:
              secretKeyRef:
                name: azdevops
                key: AZP_TOKEN
          - name: AZP_POOL
            valueFrom:
              secretKeyRef:
                name: azdevops
                key: AZP_POOL
        volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-volume
      volumes:
      - name: docker-volume
        hostPath:
          path: /var/run/docker.sock

报错信息

/opt/dynatrace/oneagent/agent/bin/1.251.xxxxxxxxxx/any/nodejs/nodejsagent.js:2611
  const e = Buffer.allocUnsafe(8), d = 2 ** 32;
                                          ^

SyntaxError: Unexpected token *
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at module.js:676:12
    at Array.forEach (native)
##[error]Exit code 1 returned from process: file name '/azp/externals/node/bin/node', arguments '"/azp/_work/_tasks/PublishBuildArtifacts_2ff763a7-ce83-4e1f-bc89-0ae63477cebe/1.158.3/publishbuildartifacts.js"'.

问题原因及解决方法

原因分析

报错中的2 ** 32是ES2016引入的幂运算符,而当前Azure DevOps代理使用的Node.js版本(从报错文件vm.js/module.js判断为Node.js 6.x或更早)不支持该语法。

核心矛盾:Dynatrace OneAgent注入的监控代码使用了高版本Node.js语法,但代理环境内的Node.js版本过低,导致语法解析失败。另外,代理容器挂载了宿主的/var/run/docker.sock,流水线任务容器会共享宿主的OneAgent,进而被注入不兼容代码。

解决方法

方法1:升级代理容器内的Node.js版本

在Dockerfile中主动安装支持幂运算符的高版本Node.js(如14.x及以上):

# 在Dockerfile中添加以下内容,安装Node.js 16.x
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs

方法2:排除代理进程被Dynatrace监控

修改Dynatrace OneAgent配置,将Azure DevOps代理相关进程/路径排除:

  • 登录Dynatrace控制台,进入Settings > Processes and containers > Process group detection
  • 添加排除规则,将/azp/externals/node/bin/node或代理容器进程路径加入排除列表
  • 重启OneAgent生效

方法3:移除宿主Docker sock挂载(若业务允许)

如果流水线任务无需直接操作宿主Docker,删除Deployment中的以下配置块:

volumeMounts:
- mountPath: /var/run/docker.sock
  name: docker-volume
volumes:
- name: docker-volume
  hostPath:
    path: /var/run/docker.sock

方法4:升级Dynatrace OneAgent版本

部分旧版本OneAgent对低版本Node.js兼容性处理不足,升级至最新稳定版可修复此类语法兼容问题。

内容的提问来源于stack exchange,提问作者Vowneee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 16:10:32