Firebase Cloud Functions Deployment Error,错误代码为"NoSuchKey"; [英] Firebase Cloud Functions Deployment Error with error code "NoSuchKey"

查看:84
本文介绍了Firebase Cloud Functions Deployment Error,错误代码为"NoSuchKey";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Firebase CLI(版本8.12.1)部署我的功能之一,但该功能一直失败.该功能在几周内没有发生变化,因此我对现在为什么失败感到有些困惑.

I'm trying to deploy one of my functions from firebase CLI (version 8.12.1) and it keeps failing. The function hasn't changed in weeks, so I am a bit confused as to why it's failing now.

CLI中的错误

functions [http-api-(europe-west1)]:部署错误.构建失败:构建错误详细信息不可用.请通过> https://console.cloud.google.com/logs/查看日志.查看器?project = & advancedFilter = resource.type%3Dbuild%0Aresource.labels.build_id%3Dfeb2697d-29b4-4ab7-9b84-90d9f847be42%0AlogName%3Dprojects%2Fvestico-dev%2Flogs%2Fcloudbuild

functions[http-api-(europe-west1)]: Deployment error. Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3Dfeb2697d-29b4-4ab7-9b84-90d9f847be42%0AlogName%3Dprojects%2Fvestico-dev%2Flogs%2Fcloudbuild

来自云控制台的日志

步骤#3-恢复器":恢复"google.nodejs.functions-framework:functions-framework"的数据从缓存

Step #3 - "restorer": Restoring data for "google.nodejs.functions-framework:functions-framework" from cache

第3步-"restorer":\ u001b [31; 1mERROR:\ u001b [0mf恢复失败:还原数据:GET https://storage.googleapis.com/eu.artifacts..appspot.com/containers/images/sha256:484d08dfc6a8f356c34a86fa4440fedf86f4fc398967eea66e4aab4e9ee81e3d?access_token =已不支持的状态代码404;正文: NoSuchKey 指定的密钥不存在.此类对象:eu.artifacts..appspot.com/containers/images/sha256:484d08dfc6a8f356c34a86fa4440fedf86f4fc398967eea66e4aab4e9ee81e3d

Step #3 - "restorer": \u001b[31;1mERROR: \u001b[0mfailed to restore: restoring data: GET https://storage.googleapis.com/eu.artifacts..appspot.com/containers/images/sha256:484d08dfc6a8f356c34a86fa4440fedf86f4fc398967eea66e4aab4e9ee81e3d?access_token=REDACTED: unsupported status code 404; body: NoSuchKeyThe specified key does not exist.No such object: eu.artifacts..appspot.com/containers/images/sha256:484d08dfc6a8f356c34a86fa4440fedf86f4fc398967eea66e4aab4e9ee81e3d

第3步完成-还原器"

Finished Step #3 - "restorer"

错误:构建步骤3"eu.gcr.io/fn-img/buildpacks/nodejs10/builder:nodejs10_20201005_20_RC00"失败:步骤退出,状态为非零:46

ERROR: build step 3 "eu.gcr.io/fn-img/buildpacks/nodejs10/builder:nodejs10_20201005_20_RC00" failed: step exited with non-zero status: 46

有趣的部分可能是上面的错误:

The interesting piece is probably the error from above:

<Error>
  <Code>NoSuchKey</Code>
  <Message>The specified key does not exist.</Message>
  <Details>No such object: eu.artifacts.<project-id>.appspot.com/containers/images/sha256:484d08dfc6a8f356c34a86fa4440fedf86f4fc398967eea66e4aab4e9ee81e3d</Details>
</Error>

构建器指的是什么键?< project-id> @ appspot.gserviceaccount.com 可以访问具有角色 Cloud Functions Admin Editor 的云功能.

What key is builder referring to? <project-id>@appspot.gserviceaccount.com has accesss to the cloud function with roles Cloud Functions Admin and Editor.

通过 firebase部署-仅部署功能:< my-api>

该函数使用 @ google-cloud/storage 获取存储资源的公共网址.

That function uses @google-cloud/storage to get a public url for a storage resource.

我正在像这样加载服务帐户配置:

I'm loading the service account configs like this:


const devServiceAccount = require("../../service-accounts/dev.json");
const prodServiceAccount = require("../../service-accounts/prod.json");

export const getAdminConfig = (): (AppOptions | undefined) => {
  const baseConfigEnv = process.env.FIREBASE_CONFIG;
  if (!baseConfigEnv) {
    console.error("no firebase config environment");
    return undefined;
  }

  const app = functions.config().app;
  if (app === undefined) {
    console.error("no firebase app config");
    return undefined;
  }

  const serviceAccount = app.environment === 'dev' ? devServiceAccount : prodServiceAccount;
  const adminConfig = JSON.parse(baseConfigEnv) as AppOptions;
  adminConfig.credential = credential.cert(serviceAccount);

  return adminConfig;
}

此处使用云存储.

const options = {
    action: 'read',
    expires: Date.now() + 1000 * 60 * 60 //1 hour
  } as GetSignedUrlConfig;

const file = bucket.file(path);
filePathPromises.push(file.getSignedUrl(options))
  });

我的文件夹结构如下.

+ functions
  + lib
    + function.js
  + service-accounts
    + dev.json
    + prod.json
  + src
    + function.ts

由于要为项目中的所有功能将文件加载到 getAdminConfig()中,因此我无法确定服务帐户文件是问题.

I was ruling out that the service account files are the issue given that the files are loaded in getAdminConfig() for all functions in the project.

我已经验证了上传到GCF存储容器的文件.JSON键在正确的位置.路径匹配,因此在GCF运行时应 找到它们.

I've verified the files uploaded to the GCF storage container. The JSON keys are there and in the right location. The paths match, so they should be found when the GCF is running.

推荐答案

为遇到此问题的下一个灵魂添加提示.这似乎是由于还原/回滚过程中文件丢失/不可访问而引起的.

Adding a hint for the next soul running into this problem. It seems to be caused by missing/inaccessible file in the restore/rollback process.

我已经成功地通过简单的方法解决了这个问题:

I was successfully removing the problem by simply:

  1. 使用Web Firebase控制台删除我的功能.
  2. 再次正常部署> firebase部署

这篇关于Firebase Cloud Functions Deployment Error,错误代码为"NoSuchKey";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆