]> git.proxmox.com Git - pve-cluster.git/commitdiff
api: join info: return explicit error code for no-cluster
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 7 Nov 2021 19:45:39 +0000 (20:45 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 7 Nov 2021 19:45:41 +0000 (20:45 +0100)
allows an API client to more easily differ between this OK "error"
and an actual exception.

Note that I'd rather now just return undef or an empty object for the
no cluster case (not to sure about the original reasons about the die
anymore), but that would be a breaking change, and in fact it would
break current pve-manager versions out there, so schedule that for
the next major release (if we still want it then)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/API2/ClusterConfig.pm

index df3332d21c9588d2815e6a637562377de30f1b16..8f4a5bbe88e18d668bba64dcf8263a823d6aeaa9 100644 (file)
@@ -546,8 +546,11 @@ __PACKAGE__->register_method ({
        PVE::Cluster::cfs_update(1);
        my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
 
-       die "node is not in a cluster, no join info available!\n"
-           if !($conf && $conf->{main});
+       # FIXME: just return undef or empty object in PVE 8.0 (check if manager can handle it!)
+       PVE::Exception::raise(
+           'node is not in a cluster, no join info available!',
+           code => HTTP::Status::HTTP_FAILED_DEPENDENCY,
+       ) if !($conf && $conf->{main});
 
        my $totem_cfg = $conf->{main}->{totem} // {};
        my $nodelist = $conf->{main}->{nodelist}->{node} // {};