rook / rook

Storage Orchestration for Kubernetes
https://rook.io
Apache License 2.0
12.1k stars 2.66k forks source link

prometheus-ceph-rules definition invalid in deploy/examples/localrules.yaml #10653

Closed solacelost closed 1 year ago

solacelost commented 1 year ago

Is this a bug report or feature request?

Deviation from expected behavior: PrometheusRule examples in localrules.yaml are not valid, with an incorrect indentation level starting at line 749 and continuing through 759. https://github.com/rook/rook/blob/master/deploy/examples/monitoring/localrules.yaml#L749,L759

Expected behavior: YAML files are valid and and indentation is consistent across an array.

How to reproduce it (minimal and precise): Try to deploy the PrometheusRules from deploy/examples/monitoring/localrules.yaml

File(s) to submit:

Environment: N/A

NOTE: I have no idea if any other PrometheusRules are also indented wrongly. The helm chart updated in the same PR doesn't appear to have wrong indentation, but I'm not deploying this way so have no error to report.

travisn commented 1 year ago

@solacelost Would you mind sharing the error message you're getting?

solacelost commented 1 year ago

As I mentioned in the PR, I'm deploying in kind of a weird way. I'm pointing the kubernetes.core.k8s Ansible module at the release branch manifests in apply mode, so the YAML is being parsed down to a Python object by pyyaml before being sent to the API server. Here's the code snippet where I'm applying, with a slight tweak, and the output of this task:

- name: Apply the basic Rook manifests
  kubernetes.core.k8s:
    state: present
    definition: '{{ lookup("url", "https://raw.githubusercontent.com/rook/rook/release-" + rook_version + "/deploy/examples/" + item + ".yaml", split_lines=False).replace("allowHostPID: false", "allowHostPID: true") }}'
    apply: yes
    wait: yes
  loop:
  - crds
  - common
  - monitoring/rbac
  - monitoring/localrules
  - operator-openshift
TASK [jharmison.home_infra.rook : Apply the basic Rook manifests] ****************************************************************************************************************************************************
changed: [okd] => (item=crds)
ok: [okd] => (item=common)
ok: [okd] => (item=monitoring/rbac)
An exception occurred during task execution. To see the full traceback, use -vvv. The error was:           ^
failed: [okd] (item=monitoring/localrules) => {"ansible_loop_var": "item", "changed": false, "item": "monitoring/localrules", "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1659396551.8897681-623-94912907838862/AnsiballZ_k8s.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1659396551.8897681-623-94912907838862/AnsiballZ_k8s.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1659396551.8897681-623-94912907838862/AnsiballZ_k8s.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.kubernetes.core.plugins.modules.k8s', init_globals=dict(_module_fqn='ansible_collections.kubernetes.core.plugins.modules.k8s', _modlib_path=modlib_path),\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_kubernetes.core.k8s_payload_7tiw07v4/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/modules/k8s.py\", line 486, in <module>\n  File \"/tmp/ansible_kubernetes.core.k8s_payload_7tiw07v4/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/modules/k8s.py\", line 482, in main\n  File \"/tmp/ansible_kubernetes.core.k8s_payload_7tiw07v4/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/modules/k8s.py\", line 458, in execute_module\n  File \"/tmp/ansible_kubernetes.core.k8s_payload_7tiw07v4/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/common.py\", line 741, in set_resource_definitions\n  File \"/tmp/ansible_kubernetes.core.k8s_payload_7tiw07v4/ansible_kubernetes.core.k8s_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/common.py\", line 741, in <listcomp>\n  File \"/usr/lib64/python3.8/site-packages/yaml/__init__.py\", line 130, in load_all\n    yield loader.get_data()\n  File \"/usr/lib64/python3.8/site-packages/yaml/constructor.py\", line 45, in get_data\n    return self.construct_document(self.get_node())\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 27, in get_node\n    return self.compose_document()\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 55, in compose_document\n    node = self.compose_node(None, None)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 84, in compose_node\n    node = self.compose_mapping_node(anchor)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 133, in compose_mapping_node\n    item_value = self.compose_node(node, item_key)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 84, in compose_node\n    node = self.compose_mapping_node(anchor)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 133, in compose_mapping_node\n    item_value = self.compose_node(node, item_key)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 82, in compose_node\n    node = self.compose_sequence_node(anchor)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 111, in compose_sequence_node\n    node.value.append(self.compose_node(node, index))\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 84, in compose_node\n    node = self.compose_mapping_node(anchor)\n  File \"/usr/lib64/python3.8/site-packages/yaml/composer.py\", line 127, in compose_mapping_node\n    while not self.check_event(MappingEndEvent):\n  File \"/usr/lib64/python3.8/site-packages/yaml/parser.py\", line 98, in check_event\n    self.current_event = self.state()\n  File \"/usr/lib64/python3.8/site-packages/yaml/parser.py\", line 438, in parse_block_mapping_key\n    raise ParserError(\"while parsing a block mapping\", self.marks[-1],\nyaml.parser.ParserError: while parsing a block mapping\n  in \"<unicode string>\", line 734, column 7:\n        - name: pools\n          ^\nexpected <block end>, but found '-'\n  in \"<unicode string>\", line 749, column 7:\n          - alert: CephPoolBackfillFull\n          ^\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
changed: [okd] => (item=operator-openshift)

The relevant section of the error:

\"/usr/lib64/python3.8/site-packages/yaml/parser.py\", line 438, in parse_block_mapping_key\n    raise ParserError(\"while parsing a block mapping\", self.marks[-1],\nyaml.parser.ParserError: while parsing a block mapping\n  in \"<unicode string>\", line 734, column 7:\n        - name: pools\n          ^\nexpected <block end>, but found '-'\n  in \"<unicode string>\", line 749, column 7:\n          - alert: CephPoolBackfillFull\n          ^\n

Yes, I know I'm probably committing atrocities by doing it this way. :)

travisn commented 1 year ago

Thanks for the context on the tools you're using, I was really curious why we hadn't seen the errors before with our testing.