Awx-operator: 如果部署中的值有冒号,则还原失败

创建于 2021-06-04  ·  14评论  ·  资料来源: ansible/awx-operator

问题类型
  • 错误报告
概括

在 awx 对象规范中,我有ingress_annotations: 'cert-manager.io/cluster-issuer: letsencrypt' ,该值带有冒号。 在这种情况下,awx 对象无法正确序列化并且恢复失败并显示“未知剧本失败”。

环境
  • AWX 版本:19.2.0
  • 运营商版本:0.10.0
  • Kubernetes 版本:v1.21.0+k3s1
  • AWX 安装方式:kubernetes
重现步骤

备份:

---
apiVersion: awx.ansible.com/v1beta1
kind: AWXBackup
metadata:
  name: awxbackup-manual-2021-06-04-01
spec:
  deployment_name: awx
  postgres_label_selector: app.kubernetes.io/instance=postgres-awx
  backup_pvc: manual-claim

恢复:

---
apiVersion: awx.ansible.com/v1beta1
kind: AWXRestore
metadata:
  name: awxrestore-init
spec:
  deployment_name: awx
  backup_pvc: manual-claim
  backup_dir: '/backups/tower-openshift-backup-2021-06-04-11:42:15'
  backup_pvc_namespace: default
预期成绩

恢复应该成功

实际结果

恢复因“未知剧本失败”而失败。

附加信息

这是awx_object持久化的样子:

{admin_user: admin, api_version: awx.ansible.com/v1beta1, create_preload_data: True, deployment_type: awx, garbage_collect_secrets: False, hostname: nevermind.domain.tld, image_pull_policy: IfNotPresent, ingress_annotations: cert-manager.io/cluster-issuer: letsencrypt, ingress_tls_secret: awx-le-certificate, ingress_type: Ingress, kind: AWX, loadbalancer_port: 80, loadbalancer_protocol: http, projects_persistence: False, projects_storage_access_mode: ReadWriteMany, projects_storage_size: 8Gi, replicas: 1, route_tls_termination_mechanism: Edge, task_privileged: False}

请注意cert-manager.io/cluster-issuer: letsencrypt周围没有引号。 这样做的原因是该行并不完全符合作者的意图。

建议修复:

bash -c 'echo "$0" > {{ backup_dir }}/awx_object' {{ awx_spec|quote }}
AWX 操作员日志

可以在这里找到: https :

bug high operator

所有14条评论

你好
如果您在 task_extra_env 和/或 web_extra_env 中定义了额外的环境,它也会失败。

以下 awx 定义:

---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
spec:
  admin_email: [email protected]
  admin_user: admin
  hostname: host.domain.tld
  ingress_tls_secret: xxx-tls
  ingress_type: Ingress
  task_extra_env: |
    - name: http_proxy
      value: "http://proxy.domain.tld:3128"
    - name: https_proxy
      value: "http://proxy.domain.tld:3128"
    - name: no_proxy
      value: "localhost,127.0.0.1,.domain.tld,.cluster.local"
  web_extra_env: |
    - name: http_proxy
      value: "http://proxy.domain.tld:3128"
    - name: https_proxy
      value: "http://proxy.domain.tld:3128"
    - name: no_proxy
      value: "localhost,127.0.0.1,.domain.tld,.cluster.local"

结果到以下备份的 awx_object:

{admin_email: [email protected], admin_user: admin, api_version: awx.ansible.com/v1beta1, create_preload_data: True, deployment_type: awx, garbage_collect_secrets: False, hostname: host.domain.tld, image_pull_policy: IfNotPresent, ingress_tls_secret: xxx-tls, ingress_type: Ingress, kind: AWX, loadbalancer_port: 80, loadbalancer_protocol: http, projects_persistence: False, projects_storage_access_mode: ReadWriteMany, projects_storage_size: 8Gi, replicas: 1, route_tls_termination_mechanism: Edge, task_extra_env: - name: http_proxyn value: http://proxy.domain.tld:3128/n- name: https_proxyn value: http://proxy.domain.tld:3128n- name: no_proxyn value: localhost,127.0.0.1,.domain.tld,.cluster.localn, task_privileged: False, web_extra_env: - name: http_proxyn value: http://proxy.domain.tld:3128/n- name: https_proxyn value: http://proxy.domain.tld:3128/n- name: no_proxyn value: localhost,127.0.0.1,.domain.tld,cluster.localn}

如您所见,task_extra_env 和 web_extra_env 没有正确定义:

  • \ 新行已被删除
  • yaml 缩进丢失

问候

另一个问题是,对这样的字典进行模板化并不一定会产生有效的 yaml。 例如

- set_fact:
    bla:
      extra_volumes: |
        - name: myvolume
          persistentVolumeClaim:
            claimName: manual-claim
- template:
    src: test.yml
    dest: /full/path/to/written.txt

其中test.yml{{ bla }}

将模板转换为'extra_volumes': '- name: myvolume\n persistentVolumeClaim:\n claimName: manual-claim\n这不是等效的 yaml,因此它将失败。

此外,这一行也可能导致问题:文档说“_如果您需要在复制的文件中进行变量插值,请使用 ansible.builtin.template 模块。在内容字段中使用变量将导致不可预测的输出。_”事实上,如果您尝试{'a':'b'}写入带有content的文件,而不是从变量{"a": "b"}写入。 我不确定这个特定的问题现在是否会引起问题,但是最好避免使用content以确保我们以后没有问题。

当规范包含如上所述的\n时,这并不能解决第二种情况,我应该打开一个单独的问题吗? @Spredzy

抱歉,我可能错过了,我专注于最重要的消息。 请做。 我会努力的。

我现在无法打开这个问题,因为在最新版本中,有一个新问题阻止了我进行可靠的测试。

如果_this_ 问题中有任何不清楚的地方,请告诉我,如果是这种情况,我会添加更多详细信息。

@AndrewSav已针对上述问题进行了修复。 (额外的空间)如果你拉devel你应该很高兴去

我可以重现你提到的换行问题。 我将调查它并在此处报告我的发现(或 PR)。

@Zokormazo为什么关闭?

对不起,我应该在结束时解释这一点:

冒号问题已在https://github.com/ansible/awx-operator/pull/404 上修复
https://github.com/ansible/awx-operator/pull/411上 postgres 上的额外空间
丢失的换行符已在https://github.com/ansible/awx-operator/pull/427 上修复

我使用备份进行了测试,包括 tls 机密(换行符)、自定义私有 ee 图像(标识和冒号),一切都对我有用。

您对这个过程还有其他问题吗? 随意重新打开问题或打开一个新问题

您对这个过程还有其他问题吗?

不,只是因为没有上面的解释,不清楚为什么关闭它。 现在是了,谢谢。

是的,对此感到抱歉:)

@Zokormazo我在规范中又遇到了一次,我怀疑这里仍然存在问题。

spec:
    extra_volumes: |
      - name: myvolume
        persistentVolumeClaim:
          claimName: manual-claim

通过规范传递的 extra_volume 被添加到部署中(利用我在此命名空间中手动创建的 pvc)
这是应用规范在原始 awx 部署中的样子:

  spec:
    admin_email: admin<strong i="11">@localhost</strong>
    admin_user: admin
    create_preload_data: true
    development_mode: false
    extra_volumes: |
      - name: myvolume
        persistentVolumeClaim:
          claimName: manual-claim

但它确实在恢复时失败:

yaml.scanner.ScannerError: mapping values are not allowed here\n  in \"<unicode string>\", line 217, column 66:\n     ... stentVolumeClaim:\\n    claimName: manual-claim\\n\n                                         ^\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}[0m

这是规范在恢复的部署中的样子:

  spec:
    admin_email: admin<strong i="18">@localhost</strong>
    admin_password_secret: awx-admin-password
    admin_user: admin
    broadcast_websocket_secret: awx-broadcast-websocket
    create_preload_data: true
    development_mode: false
    extra_volumes: '- name: myvolume\n  persistentVolumeClaim:\n    claimName: manual-claim\n'

听起来像@Zokormazo@Spredzy认为这是一个发布阻止程序,因为即使我们修复了

使用一些 extra_envs 进行测试,现在它可以正常工作

此页面是否有帮助?
0 / 5 - 0 等级