简体   繁体   English

在 Service Fabric 中运行 Azure DevOps 自托管构建代理时“无法解析远程名称”

[英]“The remote name could not be resolved” when running an Azure DevOps self-hosted build agent in Service Fabric

I can successfully start a self-hosted agent on my Windows 10 machine following this article:按照这篇文章,我可以在我的 Windows 10 机器上成功启动自托管代理:

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#windows https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#windows

However when I try to start the very same Docker image in Service Fabric with Windows Server 20H2 nodes, I get these container log entries:但是,当我尝试使用 Windows Server 20H2 节点在Service Fabric中启动完全相同的 Docker 映像时,我得到了以下容器日志条目:

1. Determining matching Azure Pipelines agent...
Invoke-RestMethod : The remote name could not be resolved: 'dev.azure.com'
At C:\azp\start.ps1:34 char:12
+ $package = Invoke-RestMethod -Headers @{Authorization=("Basic $base64 ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:Htt
   pWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
   ll.Commands.InvokeRestMethodCommand

Dockerfile Dockerfile

FROM mcr.microsoft.com/windows/servercore:20H2

WORKDIR /azp

COPY start.ps1 .

CMD powershell .\start.ps1

ApplicationManifest.xml应用程序清单.xml

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="build-agent-20H2" ApplicationTypeVersion="20201228.5"
  xmlns="http://schemas.microsoft.com/2011/01/fabric"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Package" ServiceManifestVersion="20201228.5" />
    <EnvironmentOverrides CodePackageRef="buildagent.Code">
      <EnvironmentVariable Name="AZP_URL" Value="https://dev.azure.com/myaccount" />
      <EnvironmentVariable Name="AZP_TOKEN" Value="mypat" />
      <EnvironmentVariable Name="AZP_AGENT_NAME" Value="myagentname" />
      <EnvironmentVariable Name="AZP_POOL" Value="mypoolname" />
    </EnvironmentOverrides>
    <Policies>
      <ServicePackageResourceGovernancePolicy CpuCores="1"/>
      <ResourceGovernancePolicy CodePackageRef="buildagent.Code" MemoryInMB="1024" />
      <ContainerHostPolicies CodePackageRef="buildagent.Code" UseTokenAuthenticationCredentials="true">
        <HealthConfig IncludeDockerHealthStatusInSystemHealthReport="true" RestartContainerOnUnhealthyDockerHealthStatus="false" TreatContainerUnhealthyStatusAsError="false" />
      </ContainerHostPolicies>
    </Policies>
  </ServiceManifestImport>
  <DefaultServices>
    <Service Name="buildagent">
      <StatelessService ServiceTypeName="buildagentType" InstanceCount="1">
        <SingletonPartition />
      </StatelessService>
    </Service>
  </DefaultServices>
</ApplicationManifest>

ServiceManifest.xml服务清单.xml

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Package" Version="20201228.5"
  xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <ServiceTypes>
    <StatelessServiceType ServiceTypeName="buildagentType" UseImplicitHost="true">
    </StatelessServiceType>
  </ServiceTypes>
  <CodePackage Name="buildagent.Code" Version="20201228.5">
    <EntryPoint>
      <ContainerHost>
        <ImageName>myacr.azurecr.io/build-agent-20h2:20201228.5</ImageName>
        <Commands>
        </Commands>
      </ContainerHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="AZP_URL" Value="" />
      <EnvironmentVariable Name="AZP_TOKEN" Value="" />
      <EnvironmentVariable Name="AZP_AGENT_NAME" Value="" />
      <EnvironmentVariable Name="AZP_POOL" Value="" />
    </EnvironmentVariables>
  </CodePackage>
</ServiceManifest>

I also tried without these specs:我也试过没有这些规格:

  • ServicePackageResourceGovernancePolicy服务包资源治理策略
  • ResourceGovernancePolicy资源治理政策
  • HealthConfig健康配置

and I wonder whether I can bring up a container in Service Fabric without having a HTTP or TCP endpoint.我想知道是否可以在没有 HTTP 或 TCP 端点的情况下在Service Fabric中启动容器。

EDIT:编辑:

another observation: When I SSH/remote onto one of the nodes where I deployed the image to and docker run -it the image directly, the remote name can be resolved and the installation procedure works (?).另一个观察结果:当我通过 SSH/远程连接到我将映像部署到的其中一个节点上并docker run -it映像时,可以解析远程名称并且安装过程有效(?)。 So it seams SF starts the container differently.所以它接缝SF以不同的方式启动容器。

EDIT 2:编辑2:

Tried with a simplified start.ps1尝试使用简化的start.ps1

Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.2.402/dotnet-sdk-2.2.402-win-x64.zip
Read-Host

brings same error.带来同样的错误。 Comparing docker inspect on SF controlled container and directly started container I see a deviation which maybe relevant:比较docker inspect SF 控制的容器和直接启动的容器,我发现可能相关的偏差:

SF (not working)顺丰(不工作)

        "Dns": [],
        "DnsOptions": [],
        "DnsSearch": [],
...
        "Networks": {
            "nat": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": null,
                "NetworkID": "b52a59a54d97f56f8fc866c0f742588023333ff1cb10b2c536be21d6745d609d",
                "EndpointID": "bc20ebb2124467f5135aefeefd7e3d38c14338479f7a5dbd04fd274dd0fa3ddf",
                "Gateway": "192.168.80.1",
                "IPAddress": "192.168.81.196",
                "IPPrefixLen": 24,

direct (working)直接(工作)

        "Dns": [
            "10.1.0.211"
        ],
        "DnsOptions": [
            "ndots:1"
        ],
        "DnsSearch": [
            "build-agent-20H2"
        ],
...
        "Networks": {
            "nat": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": null,
                "NetworkID": "b52a59a54d97f56f8fc866c0f742588023333ff1cb10b2c536be21d6745d609d",
                "EndpointID": "",
                "Gateway": "",
                "IPAddress": "",
                "IPPrefixLen": 0,

When deploying the same image with compose deployment network resolution was working fine and build agent installed & started successfully.当使用compose 部署网络分辨率部署相同的图像时工作正常并且构建代理安装并成功启动。

Comparing manifests I added endpoints and it was working:比较清单我添加了端点并且它正在工作:

ApplicationManifest.xml应用程序清单.xml

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="build-agent-20H2" ApplicationTypeVersion="20201228.5"
  xmlns="http://schemas.microsoft.com/2011/01/fabric"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Package" ServiceManifestVersion="20201228.5" />
    <EnvironmentOverrides CodePackageRef="buildagent.Code">
      <EnvironmentVariable Name="AZP_URL" Value="https://dev.azure.com/myaccount" />
      <EnvironmentVariable Name="AZP_TOKEN" Value="mypat" />
      <EnvironmentVariable Name="AZP_AGENT_NAME" Value="myagentname" />
      <EnvironmentVariable Name="AZP_POOL" Value="mypoolname" />
    </EnvironmentOverrides>
    <Policies>
      <ServicePackageResourceGovernancePolicy CpuCores="1"/>
      <ResourceGovernancePolicy CodePackageRef="buildagent.Code" MemoryInMB="1024" />
      <ContainerHostPolicies CodePackageRef="buildagent.Code" UseTokenAuthenticationCredentials="true">
        <PortBinding ContainerPort="80" EndpointRef="agentEndpoint" />
        <PortBinding ContainerPort="443" EndpointRef="agentEndpoint1" />
      </ContainerHostPolicies>
    </Policies>
  </ServiceManifestImport>
  <DefaultServices>
    <Service Name="buildagent">
      <StatelessService ServiceTypeName="buildagentType" InstanceCount="1">
        <SingletonPartition />
      </StatelessService>
    </Service>
  </DefaultServices>
</ApplicationManifest>

ServiceManifest.xml服务清单.xml

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Package" Version="20201228.5"
  xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <ServiceTypes>
    <StatelessServiceType ServiceTypeName="buildagentType" UseImplicitHost="true">
    </StatelessServiceType>
  </ServiceTypes>
  <CodePackage Name="buildagent.Code" Version="20201228.5">
    <EntryPoint>
      <ContainerHost>
        <ImageName>myacr.azurecr.io/build-agent-20h2:20201228.5</ImageName>
        <Commands>
        </Commands>
      </ContainerHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="AZP_URL" Value="" />
      <EnvironmentVariable Name="AZP_TOKEN" Value="" />
      <EnvironmentVariable Name="AZP_AGENT_NAME" Value="" />
      <EnvironmentVariable Name="AZP_POOL" Value="" />
    </EnvironmentVariables>
  </CodePackage>
  <Resources>
    <Endpoints>
      <Endpoint Name="agentEndpoint" UriScheme="http" />
      <Endpoint Name="agentEndpoint1" UriScheme="https" />
    </Endpoints>
  </Resources>
</ServiceManifest>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法解析远程名称:在 Docker 中设置自托管 devops 代理时出现“dev.azure.com” - The remote name could not be resolved: 'dev.azure.com' when setting up self-hosted devops agent in Docker Azure DevOps 自托管构建代理 - Kaniko - Azure DevOps self-hosted build agent - Kaniko 自托管构建代理无法连接到 Azure DevOps Services,无法建立 SSL 连接 - Self-hosted build agent cannot connect to Azure DevOps Services, SSL connection could not be established 将自托管建筑代理重定向到 Azure Devops 服务 - Redirect Self-Hosted Building Agent to Azure Devops Service 如何通过 bash 检查 Linux 上自托管 Azure DevOps 代理上正在运行的作业 - How to check running job on self-hosted Azure DevOps Agent on Linux via bash 在自托管的 Azure DevOps Agent 上安装 ChromeDriver - Installing ChromeDriver on self-hosted Azure DevOps Agent Azure DevOps 自托管容器实例中的代理-.network 规则 - Azure DevOps self-hosted agent in Container instance - network rules 在自托管代理上运行容器作业时 Azure DevOps YAML 构建失败 - Azure DevOps YAML build fail when running container jobs on self hosted agent 使用自托管的Azure Service Fabric调用Web API时出错 - Error when calling Web API with self-hosted Azure Service Fabric “创建管道时出错。” 在 Azure 管道自托管代理中运行 powershell 脚本时 - "An error occurred while creating the pipeline." when running powershell script in Azure pipeline self-hosted agent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM