"The remote name could not be resolved" 当 运行 Service Fabric 中的 Azure DevOps 自托管构建代理时
"The remote name could not be resolved" when running an Azure DevOps self-hosted build agent in Service Fabric
按照这篇文章,我可以在我的 Windows 10 机器上成功启动自托管代理:
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#windows
然而,当我尝试在 Service Fabric 中使用 Windows Server 20H2 节点启动完全相同的 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
Docker文件
FROM mcr.microsoft.com/windows/servercore:20H2
WORKDIR /azp
COPY start.ps1 .
CMD powershell .\start.ps1
ApplicationManifest.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 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>
我也试过没有这些规格:
- ServicePackageResourceGovernancePolicy
- 资源治理策略
- 健康配置
我想知道是否可以在没有 HTTP 或 TCP 端点的情况下在 Service Fabric 中启动容器。
编辑:
另一个观察:当我 SSH/remote 到我部署图像的节点之一上并直接 docker run -it
图像时,可以解析远程名称并且安装过程有效(?) .所以它接缝 SF 以不同的方式启动容器。
编辑 2:
尝试使用简化的 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
带来同样的错误。在 SF 控制的容器和直接启动的容器上比较 docker inspect
我发现一个可能相关的偏差:
SF(不工作)
"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,
直接(工作)
"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,
当使用 compose 部署部署相同的图像时 网络解析工作正常并且构建代理安装并成功启动。
比较清单我添加了端点并且它正在运行:
ApplicationManifest.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 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>
按照这篇文章,我可以在我的 Windows 10 机器上成功启动自托管代理:
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#windows
然而,当我尝试在 Service Fabric 中使用 Windows Server 20H2 节点启动完全相同的 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
Docker文件
FROM mcr.microsoft.com/windows/servercore:20H2
WORKDIR /azp
COPY start.ps1 .
CMD powershell .\start.ps1
ApplicationManifest.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 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>
我也试过没有这些规格:
- ServicePackageResourceGovernancePolicy
- 资源治理策略
- 健康配置
我想知道是否可以在没有 HTTP 或 TCP 端点的情况下在 Service Fabric 中启动容器。
编辑:
另一个观察:当我 SSH/remote 到我部署图像的节点之一上并直接 docker run -it
图像时,可以解析远程名称并且安装过程有效(?) .所以它接缝 SF 以不同的方式启动容器。
编辑 2:
尝试使用简化的 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
带来同样的错误。在 SF 控制的容器和直接启动的容器上比较 docker inspect
我发现一个可能相关的偏差:
SF(不工作)
"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,
直接(工作)
"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,
当使用 compose 部署部署相同的图像时 网络解析工作正常并且构建代理安装并成功启动。
比较清单我添加了端点并且它正在运行:
ApplicationManifest.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 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>