- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Google App Engine Admin API通过 Python 客户端库和纯 cURL 调用。
这在本地机器上运行良好,但在 GCE 机器上就不行了。
我正在尝试的 cURL 命令是这样的:
$ curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" https://appengine.googleapis.com/v1beta4/apps/myapp
{
"name": "apps/myapp",
"id": "myapp"
}
这是在我的本地机器上成功执行的结果,其中 TOKEN 是我个人帐户的 oauth2 舞蹈的结果。
GCE 机器上的相同命令:
$ curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" https://appengine.googleapis.com/v1beta4/apps/myapp
curl: (7) Failed to connect to appengine.googleapis.com port 443: Connection timed out
无论我使用的是我个人的基于 oauth2 的 token ,还是从运行中获得的基于服务帐户的 token ,都会出现此行为
curl http://metadata/computeMetadata/v1/instance/service-accounts/default/token -H "Metadata-Flavor: Google"
尝试使用 Python 客户端库时也是如此。
这是我在 Python 中所做的部分片段:
gae = discovery.build('appengine', 'v1beta4')
method = gae.apps().get(appsId='myapp')
method.execute(http=my_authorized_http_instance)
my_authorized_http_instance
是授权的 httplib2.Http()
实例,使用 https://www.googleapis.com/auth/cloud-platform
范围。
在本地机器上,这工作正常,我收到描述 myapp
的响应。
在 GCE 实例上,最后一行需要很长时间才能执行,并最终引发此异常:
ResponseNotReady Traceback (most recent call last)
<ipython-input-9-b5373a41f867> in <module>()
----> 1 meth.execute(http=http)
/usr/local/lib/python2.7/dist-packages/oauth2client/util.pyc in positional_wrapper(*args, **kwargs)
135 else: # IGNORE
136 pass
--> 137 return wrapped(*args, **kwargs)
138 return positional_wrapper
139
/usr/local/lib/python2.7/dist-packages/googleapiclient/http.pyc in execute(self, http, num_retries)
720
721 resp, content = http.request(str(self.uri), method=str(self.method),
--> 722 body=self.body, headers=self.headers)
723 if resp.status < 500:
724 break
/usr/local/lib/python2.7/dist-packages/oauth2client/util.pyc in positional_wrapper(*args, **kwargs)
135 else: # IGNORE
136 pass
--> 137 return wrapped(*args, **kwargs)
138 return positional_wrapper
139
/usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in new_request(uri, method, body, headers, redirections, connection_type)
549
550 resp, content = request_orig(uri, method, body, clean_headers(headers),
--> 551 redirections, connection_type)
552
553 if resp.status in REFRESH_STATUS_CODES:
/usr/local/lib/python2.7/dist-packages/httplib2/__init__.pyc in request(self, uri, method, body, headers, redirections, connection_type)
1606 content = ""
1607 else:
-> 1608 (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
1609 except Exception, e:
1610 if self.force_exception_to_status_code:
/usr/local/lib/python2.7/dist-packages/httplib2/__init__.pyc in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
1348 auth.request(method, request_uri, headers, body)
1349
-> 1350 (response, content) = self._conn_request(conn, request_uri, method, body, headers)
1351
1352 if auth:
/usr/local/lib/python2.7/dist-packages/httplib2/__init__.pyc in _conn_request(self, conn, request_uri, method, body, headers)
1304 continue
1305 try:
-> 1306 response = conn.getresponse()
1307 except httplib.BadStatusLine:
1308 # If we get a BadStatusLine on the first try then that means
/usr/lib/python2.7/httplib.pyc in getresponse(self, buffering)
1037 #
1038 if self.__state != _CS_REQ_SENT or self.__response:
-> 1039 raise ResponseNotReady()
1040
1041 args = (self.sock,)
ResponseNotReady:
是的,GCE 实例具有 cloud-platform
服务帐户:
$ curl -s http://metadata/computeMetadata/v1/instance/service-accounts/default/scopes -H "Metadata-Flavor: Google" | grep cloud-platform
https://www.googleapis.com/auth/cloud-platform
此外,我想弄清楚这里是否是服务帐户问题,所以我尝试在 GCE 实例上以自己的身份授权,而不是使用服务帐户。我遇到了同样的错误。
有什么想法吗?我做错了什么吗?
最佳答案
您遇到了我们正在修复的托管 VM 的内部错误。
目前,appengine.googleapis.com
映射到 VM 上的内部地址,该地址用于私有(private) VM 到 AppEngine 的流量,但不会将 HTTPS 请求转发到公共(public) API。我们正在转移这个内部 channel ,以免干扰公共(public) channel 。
与此同时,您可以将 appengine.googleapis.com
的手动条目添加到机器上的 /etc/hosts
文件,并重新映射端口 10001(这用于内部通信)指向内部传输地址,像这样:
echo '64.233.181.95 appengine.googleapis.com' >> /etc/hosts
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -d 64.18.0.0/20,64.233.160.0/19,66.102.0.0/20,66.249.80.0/20,72.14.192.0/18,74.125.0.0/16,108.177.8.0/21,173.194.0.0/16,207.126.144.0/20,209.85.128.0/17,216.58.192.0/19,216.239.32.0/19 --dport 10001 -j DNAT --to-destination 169.254.169.253:10001
(其中 IP 地址集源自 _spf.google.com
记录。)
这只会影响已启用托管 VM 的项目。我们希望很快(几周)准备好修复。
UPD:修复了上面命令中的 appengine.googleapis.com 域名
关于python - 从 GCE 实例使用时,Google App Engine Admin API 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32437261/
我在Windows 10中使用一些简单的Powershell代码遇到了这个奇怪的问题,我认为这可能是我做错了,但我不是Powershell的天才。 我有这个: $ix = [System.Net.Dn
var urlsearch = "http://192.168.10.113:8080/collective-intellegence/StoreClicks?userid=" + userId +
我有一个非常奇怪的问题,过去两天一直让我抓狂。 我有一个我试图控制的串行设备(LS 100 光度计)。使用设置了正确参数的终端(白蚁),我可以发送命令(“MES”),然后是定界符(CR LF),然后我
我目前正试图让无需注册的 COM 使用 Excel 作为客户端,使用 .NET dll 作为服务器。目前,我只是试图让概念验证工作,但遇到了麻烦。 显然,当我使用 Excel 时,我不能简单地使用与可
我开发了简单的 REST API - https://github.com/pavelpetrcz/MandaysFigu - 我的问题是在本地主机上,WildFly 16 服务器的应用程序运行正常。
我遇到了奇怪的情况 - 从 Django shell 创建一些 Mongoengine 对象是成功的,但是从 Django View 创建相同的对象看起来成功,但 MongoDB 中没有出现任何数据。
我是 flask 的新手,只编写了一个相当简单的网络应用程序——没有数据库,只是一个航类搜索 API 的前端。一切正常,但为了提高我的技能,我正在尝试使用应用程序工厂和蓝图重构我的代码。让它与 pus
我的谷歌分析 JavaScript 事件在开发者控制台中运行得很好。 但是当从外部 js 文件包含在页面上时,它们根本不起作用。由于某种原因。 例如; 下面的内容将在包含在控制台中时运行。但当包含在单
这是一本名为“Node.js 8 the Right Way”的书中的任务。你可以在下面看到它: 这是我的解决方案: 'use strict'; const zmq = require('zeromq
我正在阅读文本行,并创建其独特单词的列表(在将它们小写之后)。我可以使它与 flatMap 一起工作,但不能使它与 map 的“子”流一起工作。 flatMap 看起来更简洁和“更好”,但为什么 di
我正在编写一些 PowerShell 脚本来进行一些构建自动化。我发现 here echo $? 根据前面的语句返回真或假。我刚刚发现 echo 是 Write-Output 的别名。 写主机 $?
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我将一个工作 View Controller 类从另一个项目复制到一个新项目中。我无法在新项目中加载 View 。在旧项目中我使用了presentModalViewController。在新版本中,我
我对 javascript 很陌生,所以很难看出我哪里出错了。由于某种原因,我的功能无法正常工作。任何帮助,将不胜感激。我尝试在外部 js 文件、头部/主体中使用它们,但似乎没有任何效果。错误要么出在
我正在尝试学习Flutter中的复选框。 问题是,当我想在Scaffold(body :)中使用复选框时,它正在工作。但我想在不同的地方使用它,例如ListView中的项目。 return Cente
我们当前使用的是 sleuth 2.2.3.RELEASE,我们看不到在 http header 中传递的 userId 字段没有传播。下面是我们的代码。 BaggageField REQUEST_I
我有一个组合框,其中包含一个项目,比如“a”。我想调用该组合框的 Action 监听器,仅在手动选择项目“a”完成时才调用。我也尝试过 ItemStateChanged,但它的工作原理与 Action
你能看一下照片吗?现在,一步前我执行了 this.interrupt()。您可以看到 this.isInterrupted() 为 false。我仔细观察——“这个”没有改变。它具有相同的 ID (1
我们当前使用的是 sleuth 2.2.3.RELEASE,我们看不到在 http header 中传递的 userId 字段没有传播。下面是我们的代码。 BaggageField REQUEST_I
我正在尝试在我的网站上设置一个联系表单,当有人点击发送时,就会运行一个作业,并在该作业中向所有管理员用户发送通知。不过,我在失败的工作表中不断收到此错误: Illuminate\Database\El
我是一名优秀的程序员,十分优秀!