簡體   English   中英

gcloud 控制台中的奇怪警告:路徑位於已安裝的秘密卷 [...] 但不對應於任何秘密

[英]Weird warning in gcloud console: The path is in a mounted secrets volume [...] but does not correspond to any secret

我正在部署一個 gcloud function 並安裝了兩個秘密(來自谷歌秘密管理器),我的本地目錄結構如下:

├── index.js
├── mounted-secret-config
│   ├── config.js
├── mounted-secret-credentials
│   └── googleServiceAccountCredentials.json
├── package-lock.json
└── package.json

config.jsgoogleServiceAccountCredentials.json被忽略,因此部署過程不會上傳它們。

我使用此命令進行部署:

gcloud functions deploy <...> --region <...> --trigger-http --runtime nodejs16 --allow-unauthenticated --gen2 --memory 256Mi --set-secrets=/workspace/mounted-secret-config/config.js=configjs:latest,/workspace/mounted-secret-credentials/googleServiceAccountCredentials.json=googleServiceAccountCredentials:latest

它有效,節點應用程序找到文件並且整體有效,但每次部署后我都會在 gcloud 日志中看到:

2022-08-26 10:11:18.130 CEST Could not open file at path /secret_volume_0/config. The path is in a mounted secrets volume, but the exact path does not correspond to any secret specified in the mount configuration.
Warning
2022-08-26 10:11:18.182 CEST Could not open file at path /secret_volume_0/package.json. The path is in a mounted secrets volume, but the exact path does not correspond to any secret specified in the mount configuration.
Warning

在對我的服務提出每個 http 請求后,我得到:

2022-08-26 10:05:33.511 CEST Could not open file at path /workspace/mounted-secret-config/config. The path is in a mounted secrets volume, but the exact path does not correspond to any secret specified in the mount configuration.
Warning
2022-08-26 10:05:33.572 CEST Could not open file at path /workspace/mounted-secret-config/package.json. The path is in a mounted secrets volume, but the exact path does not correspond to any secret specified in the mount configuration.

我不知道這里發生了什么,我什至不知道是誰在記錄這個。 /workspace/mounted-secret-config/config不存在,但/workspace/mounted-secret-config/config.js (注意 .js 擴展名)存在,並且應用程序會找到它,或者它甚至不會啟動。 /workspace/mounted-secret-config/package.json這不是但不應該,誰甚至試圖訪問它? 為什么它不抱怨另一個已安裝的秘密?

config.js 是必需的: require('./mounted-secret-config/config')

如果我將其更改為require('./mounted-secret-config/config.js') (adding.js) 兩個警告之一就會消失。 節點是否嘗試導入確切的名稱(發出警告)然后回退到config.js 但是package.json呢?

這不是一個真正的解決方案,更像是一種解決方法,如果您找到它,請隨時添加一個真正的解決方案。

我為“解決”問題所做的是將我的配置文件的格式從.js更改為.json (在我的情況下很容易,因為它只包含一個幾乎沒有鍵/值的字典)

其他一切都保持不變,我仍然使用require讀取文件。 我不知道節點對.js做了什么奇怪的事情,但對.json卻沒有。

兩個警告都消失了(包括關於package.json的警告)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM