首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Cloud Secret Manager在计算引擎中运行时打印不必要的调试信息

Google Cloud Secret Manager在计算引擎中运行时打印不必要的调试信息
EN

Stack Overflow用户
提问于 2020-11-19 18:29:19
回答 1查看 321关注 0票数 0

我在GCP AI平台笔记本中的Jupyterlab笔记本中使用Google Cloud Secret Manager。我可以例外地访问机密,但我的代码打印出了许多与身份验证相关的调试行。

下面是我的代码:

代码语言:javascript
复制
from google.cloud import secretmanager
PROJECT_ID = "<PROJECT_ID >"

def access_secret_version(secret_id, version_id="latest"):
    # Create the Secret Manager client.
    client = secretmanager.SecretManagerServiceClient()

    # Build the resource name of the secret version.
    name = f"projects/{PROJECT_ID}/secrets/{secret_id}/versions/{version_id}"

    # Access the secret version.
    response = client.access_secret_version(name=name)

    # Return the decoded payload.
    return response.payload.data.decode('UTF-8')

# Get my secret
mySecret= access_secret_version('mySecret')

以下是运行我的代码时的日志(IP地址和服务帐户已更改):

代码语言:javascript
复制
DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
DEBUG:google.auth._default:Cloud SDK credentials not found on disk; not using them
DEBUG:google.auth._default:Checking for App Engine runtime as part of auth process...
DEBUG:google.auth._default:No App Engine library was found so cannot authentication via App Engine Identity Credentials.
DEBUG:google.auth.transport._http_client:Making request: GET http://111.222.333.444
DEBUG:google.auth.transport._http_client:Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
DEBUG:google.auth.transport.requests:Making request: GET http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): metadata.google.internal:80
DEBUG:urllib3.connectionpool:http://metadata.google.internal:80 "GET /computeMetadata/v1/instance/service-accounts/default/?recursive=true HTTP/1.1" 200 193
DEBUG:google.auth.transport.requests:Making request: GET http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/my-compute@developer.gserviceaccount.com/token
DEBUG:urllib3.connectionpool:http://metadata.google.internal:80 "GET /computeMetadata/v1/instance/service-accounts/my-compute@developer.gserviceaccount.com/token HTTP/1.1" 200 260

我尝试在终端中显式地设置计算引擎服务帐户,并在脚本中使用服务帐户JSON文件将其设置为环境变量。

打印Debug代码的原因是什么,如何让它消失?

EN

回答 1

Stack Overflow用户

发布于 2020-11-19 19:33:19

找到原因:

我已经将脚本的调试级别设置为debug:

代码语言:javascript
复制
logging.basicConfig(level=logging.debug)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64909787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档