GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs
using gcloud functions deploy --set-secrets=/workspace will trigger an error
- Ngôn ngữ chính
- TypeScript
- Star
- 1.4k
- Fork
- 181
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
## Expected
It is possible to deploy a secret file into `/workspace` within a cloud function environment.
## Observed
After function is deployed, the step that tests it fails, and it prints this error:
```
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided code location '/workspace' is not a loadable module.
```
I've googled "Error message: Provided code location '/workspace' is not a loadable module." but not much luck yet finding where this comes from.
## Steps to reproduce
Assuming you have a gen 1 function e.g. named `my-existing-gen1-cloud-function` (I'm not sure if this works on Gen 2; I haven't yet tried it):
```
gcloud functions deploy my-existing-gen1-cloud-function --entry-point=webhook --set-secrets=/workspace/.env-file=Secrets-Env-File:latest
```
Note there is a warning printed: "Ensure that the runtime service account...has access to the secrets." (which I've done)
## Logs
```
For Cloud Build Logs, visit: https://console.cloud.google.com/cloud-build/builds;region=us-central1/(redacted)?project=(redacted)
Deploying function (may take a while - up to 2 minutes)...⠏
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided code location '/workspace' is not a loadable module.
Did you specify the correct location for the module defining your function?
Could not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
```
## Workarounds
It seems possible to deploy the secret file to another directory, such as `/tmp` or `/etc`.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện chính xác lệnh triển khai Gen 1 với entry point `webhook` và một secret được mount tại `/workspace`, sau đó so sánh với các workaround đã được ghi chép cho `/tmp` hoặc `/etc`. Điều tra lý do hàm đã triển khai coi `/workspace` là vị trí mã của nó; được xem là hoàn tất khi secret được mount tại đó mà không gây ra lỗi tải hàm.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- google-cloud, nodejs
- Lĩnh vực
- backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100