Github Action中调用Dremio API失败问题排查求助
GitHub Action调用Dremio API失败但本地正常的问题
在GitHub Action中执行Dremio API调用时失败,但本地运行相同代码可正常工作,报错为域名解析失败。
GitHub Action配置
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: Dremio Workflow on: workflow_call: env: dremio_url: ${{secrets.DREMIO_URL}} dremio_pat: ${{secrets.DREMIO_PAT}} envior: 'dev' permissions: contents: read jobs: env-set: runs-on: ubuntu-latest environment: PROD steps: - name: Check out code uses: actions/checkout@v2 - name: Set up Python 3.11.4 uses: actions/setup-python@v3 with: python-version: "3.11.4" - name: Downloading requirements run: | python -m pip install requests - name: Deploying against CR# ${{github.event.inputs.change_request_id}} run: | python .github/workflows/dremio.py --DREMIO_URL ${{secrets.DREMIO_URL}} --DREMIO_PAT ${{secrets.DREMIO_PAT}}
报错信息
Exception occured: HTTPSConnectionPool(host='*****', port=443): Max retries exceeded with url: /api/v3/catalog/by-path/dev/report/ap/ap_file (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f41ce193ed0>: Failed to resolve '*****' ([Errno -5] No address associated with hostname)")) Error: Process completed with exit code 1.
相关Python代码片段
try: url = f"{DREMIO_URL}/by-path/{environment}/{report}/{datasubject}/{r_name}" payload = "" headers = { 'Authorization': f'Bearer {PAT}', 'Content-Type': 'application/json' } print("URL ",url) response = requests.request("GET", url, headers=headers, data=payload) return "Success", response.text except Exception as e: return "Failure", f"Exception occured: {e}"
解决办法
- 排查域名解析能力:在GitHub Action步骤中添加
nslookup your-dremio-hostname命令,验证runner环境能否解析Dremio域名。如果不能,说明域名未公开可访问,需配置DNS解析或改用固定IP访问(不推荐,除非IP长期稳定)。 - 检查Secrets正确性:确认
DREMIO_URL这个Secret的值完整,必须包含https://前缀,无多余空格或特殊字符。对比本地运行的URL配置,排除内容差异。 - 解除网络访问限制:Dremio服务器可能设置了IP白名单,GitHub Action的runner IP不在允许范围内。联系Dremio管理员将GitHub Actions的IP段加入白名单,或者改用自托管Runner(部署在能访问Dremio的内网环境)执行任务。
- 核对变量传递:注意到Action的env中变量名为
envior,但代码中使用environment,虽报错路径已显示dev,仍需确认代码中environment变量的取值逻辑是否正确,避免因变量错误引发路径问题。
内容的提问来源于stack exchange,提问作者Pradyumn Joshi
相关产品推荐
相关产品推荐

