首页 > 解决方案 > 开发人员云服务和 Packer 构建失败,HTTP 401 未经授权?

问题描述

我的 Oracle Developer 构建失败并说明了一些关于 HTTP 未经授权的代码:

 oracle-oci: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401

我的打包器 json 构建有一堆我刚刚设置的元素,其中一堆OCI在字符串中......

  "builders": [
    {
      "user_ocid":"ocid1.user.oc1..",
      "tenancy_ocid": "ocid1.tenancy.oc1..",
      "fingerprint":"0d:1e:...",
      "key_file":"oci_api_key.pem",
      "availability_domain": "uKbv:CA-TORONTO-1-AD-1",
      "region": "us-ashburn-1",
      "base_image_ocid": "ocid1.image.oc1.iad...",
      "compartment_ocid": "ocid1.compartment.oc1..",
      "image_name": "DevCS_MYSQL",
      "shape": "VM.Standard2.2",
      "ssh_username": "opc",
      "ssh_password": "welcome1",
      "subnet_ocid": "ocid1.subnet.oc1.ca-johnstown-1...",
      "type": "oracle-oci"
    }
  ],

如何判断哪个是错误的并导致 HTTP 401 未经授权的代码?我没有看到提到的任何元素,也没有看到

[2019-08-21 12:44:50] Build scheduled. Build started by user helpdeskaleer@gmail.com
[2019-08-21 12:44:50] Build task id: 830601c8-5ba8-4dc4-8bdc-07abaff9de73
[2019-08-21 12:55:03] Build execution started.
[2019-08-21 12:55:03] Building on slave PackerTerraformNodeJS
[2019-08-21 12:55:02] Git: Checkout directory is the workspace root.
[2019-08-21 12:55:02] Git: git version 1.8.3.1
[2019-08-21 12:55:02] Git: Fetching from remote repository https://mysqlalphaoffice-helpdeskaleer.developer.ocp.oraclecloud.com/mysqlalphaoffice-helpdeskaleer/s/mysqlalphaoffice-helpdeskaleer_mysql-alphaoffice_10254/scm/MYSQL-PackerTerraform.git
[2019-08-21 12:55:02] /bin/git fetch --no-tags https://mysqlalphaoffice-helpdeskaleer.developer.ocp.oraclecloud.com/mysqlalphaoffice-helpdeskaleer/s/mysqlalphaoffice-helpdeskaleer_mysql-alphaoffice_10254/scm/MYSQL-PackerTerraform.git +refs/heads/*:refs/remotes/origin/*
[2019-08-21 12:55:04] Git: Checking out branch master
[2019-08-21 12:55:04] Git: Done
[2019-08-21 12:55:04] BEGIN shell script execution with /bin/sh -ex
[2019-08-21 12:55:04] + packer --version
[2019-08-21 12:55:04] 1.3.5
[2019-08-21 12:55:04] + tee output.txt
[2019-08-21 12:55:04] + packer build build.json
[2019-08-21 12:55:05] [1;32moracle-oci output will be in this color.[0m
[2019-08-21 12:55:05] [1;32m==> oracle-oci: Creating temporary ssh key for instance...[0m
[2019-08-21 12:55:05] [1;32m==> oracle-oci: Creating instance...[0m
[2019-08-21 12:55:05] [1;31m==> oracle-oci: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401[0m
[2019-08-21 12:55:05] [1;31mBuild 'oracle-oci' errored: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401[0m
[2019-08-21 12:55:05] ==> Some builds didn't complete successfully and had errors:
[2019-08-21 12:55:05] --> oracle-oci: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401
[2019-08-21 12:55:05] ==> Builds finished but no artifacts were created.
[2019-08-21 12:55:05] + ls -l
[2019-08-21 12:55:05] total 56
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 2577 Aug 21 12:55 build.json
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 1406 Aug 21 12:55 compute.tf
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  888 Aug 21 12:55 datasources.tf
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder   99 Aug 21 12:55 Dockerfile
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  786 Aug 21 12:55 env-vars
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 2983 Aug 21 12:55 network.tf
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 1675 Aug 21 12:55 oci_api_key.pem
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  450 Aug 21 12:55 oci_api_key_public.pem
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 1678 Aug 21 12:55 oci_instance_key
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  402 Aug 21 12:55 oci_instance_key.pub
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  488 Aug 21 12:55 outputs.tf
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  874 Aug 21 12:55 output.txt
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder  260 Aug 21 12:55 provider.tf
[2019-08-21 12:55:05] -rw-r-----. 1 builder builder 1726 Aug 21 12:55 variables.tf
[2019-08-21 12:55:05] + cat output.txt
[2019-08-21 12:55:05] [1;32moracle-oci output will be in this color.[0m
[2019-08-21 12:55:05] [1;32m==> oracle-oci: Creating temporary ssh key for instance...[0m
[2019-08-21 12:55:05] [1;32m==> oracle-oci: Creating instance...[0m
[2019-08-21 12:55:05] [1;31m==> oracle-oci: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401[0m
[2019-08-21 12:55:05] [1;31mBuild 'oracle-oci' errored: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401[0m
[2019-08-21 12:55:05] ==> Some builds didn't complete successfully and had errors:
[2019-08-21 12:55:05] --> oracle-oci: Problem creating instance: Service error:NotAuthenticated. The required information to complete authentication was not provided or was incorrect.. http status code: 401
[2019-08-21 12:55:05] ==> Builds finished but no artifacts were created.
[2019-08-21 12:55:05] /data/cibuild/830601c8-5ba8-4dc4-8bdc-07abaff9de73/tmp/script5780075887420937130.sh: line 5: unexpected EOF while looking for matching ``'
[2019-08-21 12:55:05] Error: Command exited with status 2
[2019-08-21 12:55:05] END shell script execution
[2019-08-21 12:55:05] No artifacts requested
Slave log size 4.6 KB (4,622)
[2019-08-21 12:55:07]
[2019-08-21 12:55:07] Build completed.
[2019-08-21 12:55:07] Status: DONE Result: FAILED Duration: 5.0 sec

标签: linuxpackeroracle-cloud-infrastructureoraclelinux

解决方案


401 NotAuthenticated 表示以下值之一存在问题:

"user_ocid":"ocid1.user.oc1..",
"tenancy_ocid": "ocid1.tenancy.oc1..",
"fingerprint":"0d:1e:...",
"key_file":"oci_api_key.pem",

这些设置都用于构造用于向 OCI 进行身份验证的签名字符串。当该身份验证失败时,您会收到 401 NotAuthenticated 响应。


推荐阅读