gcloud 403错误项目的权限错误

时间:2018-04-02 16:45:27

标签: google-cloud-platform gcloud

我曾经在一家公司工作,之前用gcloud initgcloud auth login设置了我的gcloud(我不记得是哪一个)。我们使用的是谷歌容器引擎(GKE)。

我已离开公司,并已从该项目的权限中删除。

今天,我想为自己设置一个全新的应用引擎,与以前的公司无关。

为什么在没有收到以下错误的情况下我无法运行任何命令? gcloud initgcloud auth login甚至gcloud --helpgcloud config list都显示错误。看起来它正试图用gcloud container cluster登录我以前公司的项目,但我根本没有输入该命令,而是在一个不同的区域并对另一个项目感兴趣。我的gcloud配置在哪里获得这些默认值?

这是我需要删除.config/gcloud文件夹的情况吗?对于登录不同的项目而言,似乎只是极端的解决方案?

Traceback (most recent call last):
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/gcloud.py", line 65, in <module>
    main()
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/gcloud.py", line 61, in main
    sys.exit(googlecloudsdk.gcloud_main.main())
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/gcloud_main.py", line 130, in main
    gcloud_cli = CreateCLI([])
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/gcloud_main.py", line 119, in CreateCLI
    generated_cli = loader.Generate()
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 329, in Generate
    cli = self.__MakeCLI(top_group)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 517, in __MakeCLI
    log.AddFileLogging(self.__logs_dir)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/log.py", line 676, in AddFileLogging
    _log_manager.AddLogsDir(logs_dir=logs_dir)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/log.py", line 365, in AddLogsDir
    self._CleanUpLogs(logs_dir)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/log.py", line 386, in _CleanUpLogs
    self._CleanLogsDir(logs_dir)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/log.py", line 412, in _CleanLogsDir
    os.remove(log_file_path)
OSError: [Errno 13] Permission denied: '/Users/terence/.config/gcloud/logs/2017.07.27/19.07.37.248117.log'

和日志文件: /Users/terence/.config/gcloud/logs/2017.07.27/19.07.37.248117.log

2017-07-27 19:07:37,252 DEBUG    root            Loaded Command Group: ['gcloud', 'container']
2017-07-27 19:07:37,253 DEBUG    root            Loaded Command Group: ['gcloud', 'container', 'clusters']
2017-07-27 19:07:37,254 DEBUG    root            Loaded Command Group: ['gcloud', 'container', 'clusters', 'get_credentials']
2017-07-27 19:07:37,330 DEBUG    root            Running [gcloud.container.clusters.get-credentials] with arguments: [--project: "REMOVED_PROJECT", --zone: "DIFFERENT_ZONE", NAME: "REMOVED_CLUSTER_NAME"]
2017-07-27 19:07:37,331 INFO     ___FILE_ONLY___ Fetching cluster endpoint and auth data.

2017-07-27 19:07:37,591 DEBUG    root            (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get" permission for "projects/REMOVED_PROJECT/zones/DIFFERENT_ZONE/clusters/REMOVED_CLUSTER_NAME".
Traceback (most recent call last):
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 712, in Execute
    resources = args.calliope_command.Run(cli=self, args=args)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 871, in Run
    resources = command_instance.Run(args)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/container/clusters/get_credentials.py", line 69, in Run
    cluster = adapter.GetCluster(cluster_ref)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/container/api_adapter.py", line 213, in GetCluster
    raise api_error
HttpException: ResponseError: code=403, message=Required "container.clusters.get" permission for "projects/REMOVED_PROJECT/zones/DIFFERENT_ZONE/clusters/REMOVED_CLUSTER_NAME".
2017-07-27 19:07:37,596 ERROR    root            (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get" permission for "projects/REMOVED_PROJECT/zones/DIFFERENT_ZONE/clusters/REMOVED_CLUSTER_NAME".

3 个答案:

答案 0 :(得分:2)

虽然我不相信这是一个很好的解决方案,但我不得不删除.config/gcloud来完成这项工作。

答案 1 :(得分:0)

好的,因此不确定是否已更改但遇到类似问题。在取消配置之前,请尝试此操作。

gcloud支持多个帐户,您可以通过运行gcloud auth list来查看哪个帐户处于活动状态。

ACTIVE  ACCOUNT
*        Work-Email@company.com
         Personal-Email@gmail.com

如果您选择的不是正确的,则可以

$ gcloud config set account Personal-Email@gmail.com

它将设置正确的帐户。再次运行gcloud auth list应该会立即在您的个人计算机上显示“活动”。

如果您尚未验证个人身份,则需要登录。您可以运行gcloud auth login Personal-Email@gmail.com,并按照从那里开始的流程进行操作,然后返回到上面。

确保设置PROJECT_ID或切换时可能需要的任何设置。

现在从那里我发现仍然有可能未正确验证您的身份。我想为此,您可能需要重新启动终端会话,甚至只需执行source ~/.bash_profile就足够了。 (也许我需要这样做才能刷新GOOGLE_APPLICATION_CREDENTIALS环境变量,但不确定)。

希望这会有所帮助。在核对之前尝试一下

答案 2 :(得分:0)

重命名/删除config / gcloud / logs文件夹,然后尝试代替删除.config / gcloud文件夹。

此解决方案对我有用:)