[SOLVED] How to "lint" corosync config? What does pve7to8 use?

We have an easy way to check the syntax of the corosync config:

corosync -t -c /etc/pve/corosync.conf

However, I see that pve7to8 will check the semantics of the corosync config. For example:

Code:
Checking nodelist entries..
WARN: pve1: ring0_addr 'pve1-corosync-0' resolves to '172.16.3.31'.
 Consider replacing it with the currently resolved IP address.
WARN: pve2: ring0_addr 'pve2-corosync-0' resolves to '172.16.3.32'.
 Consider replacing it with the currently resolved IP address.
WARN: pve3: ring0_addr 'pve3-corosync-0' resolves to '172.16.3.33'.
 Consider replacing it with the currently resolved IP address.

(aside: this came up for me because the Corosync documentation recommends using hostnames and I only found out that Proxmox recommends against it when running pve7to8 last year... and I never changed it because, well, y'know, you don't touch corosync when you don't have to)

What tool(s) is pve7to8 using under the hood to lint corosync.conf? Can we run the checks independently?

Any other ideas for config linting strategies?

Backstory

This topic of linting corosync came up while I was in the Weehooey Proxmox training and we talked about about the syntactic check, but didn't know if there was a semantic check.

When thinking about how to help detect and prevent issues like https://forum.proxmox.com/threads/the-pve-cluster-mysteriously-rebooted-almost-simultaneously.164851, I remembered about the semantic checks of pve7to8 and wondered if it would have caught the issue of only having a single ring and what other checks it may have that could be useful in the field. And then... can we run that in isolation?
 
Last edited:
Thanks.

To sum that up for posterity:

- the parser and checker is NOT part of the corosync utils
- `PVE::Corosync` lives at https://github.com/proxmox/pve-cluster/blob/master/src/PVE/Corosync.pm#L222
- `PVE::Cluster` lives at https://github.com/proxmox/pve-cluster/blob/master/src/PVE/Cluster.pm#L578, and has a custom parser registered
- `pve7to8` uses those modules to parse and traverse the config tree, and provide the semantic checking

The only license I can find is under the debian folder:
https://github.com/proxmox/pve-manager/blob/master/debian/copyright
I believe that that is probably intended to be the license for the entire repository.

I'm not familiar with perl, but I'll check on the mailing list and see if they'd be open to splitting that out into its own tool because I think it's very useful.
 
  • Like
Reactions: weehooey-bh
There's also a parser in Python by Redhat:
- https://insights-core.readthedocs.io/en/latest/shared_parsers_catalog/corosync.html

There's another in Go by LINBIT
- https://pkg.go.dev/github.com/LINBIT/gocorosync

And another in Rust by a Suse employee
- https://github.com/dottorblaster/corosync-config-parser

It looks like the config file is slow moving and it may be possible to use an LLM to replicate the meaningful bits of the perl checks in other languages, but there's no other ready-made tool like pve7to8.
 
Last edited:
  • Like
Reactions: weehooey-bh