python - 使用 API 部署/更新 Marathon Docker 映像
问题描述
我正在编写代码以自动更新马拉松上部署的图像。我使用马拉松 API 参考http://mesosphere.github.io/marathon/api-console/index.html中列出的 REST 补丁方法
url = 'https://<my-hostname>:<my-port>/v2/apps'
h = {'Content-type': 'application/json', 'Accept': 'application/json'}
data = {'app': { "id": app,
'container': {
'docker': {
'image': image}}}}
print ('requests.patch(%s, %s)' % (url + app, json.dumps(data)))
r = requests.patch(url + app, headers = h, auth = auth, data = json.dumps(data))
if r.status_code == 200:
print('Deployed %s' % app)
代码运行成功,我得到了一个部署 ID,但 UI 没有任何变化。没有新的部署发生。如果我将补丁请求更改为没有数据的获取请求,我会取回我之前使用上面的代码更新的图像。
根据这个类似的 API 参考https://docs.mesosphere.com/1.11/deploying-services/marathon-api/#/apps/V2AppsByAppId1
它说“此操作将创建部署”,但什么也没发生。在 Marathon GUI 中,我根本看不到配置发生变化。如果我重新启动,则重新启动相同的旧部署。我是否错误地解释了 API 参考?
解决方案
如果我正确阅读 API 参考指南,正文应该是:
{ "id": app,
"container": {
"docker": {
"image": image
}
}
}
用马拉松 1.4.11 对此进行了测试,并且有效。不知道为什么你会得到一个部署ID,如果我按照你的方式做(使用额外的 {"app":} 层),我会收到一个 500 错误。顺便说一句,我不确定这对单引号和双引号有多敏感。
推荐阅读
- web - PWA 如何有用而不是开发简单的 Web 应用程序
- wordpress - 两个 WordPress 安装的永久链接问题
- excel - Excel - 从列表中选择唯一的随机值,复制 1000 行
- utf-8 - 在 pycharm 编辑器和控制台中显示彩色表情符号
- mysql - 如何将我计算机上的 React 应用程序连接到 Godaddy 上的 mysql 数据库
- timer - 如何使用静态 C++ 方法作为 Poco 计时器的回调?
- r - 在每个组的日期范围结束时删除零
- reactjs - 如何更改 react-script 自动生成的导入?
- javascript - 用 var 变量理解一些东西
- node.js - Node.js - 仅为了获取文件长度而将文件流保存到磁盘是否可以接受?