[pve-devel] [RFC manager 1/3] add get_local_services for ceph

Dominik Csapak d.csapak at proxmox.com
Fri Apr 26 12:11:45 CEST 2019


On 4/26/19 10:47 AM, Thomas Lamprecht wrote:
> Am 4/26/19 um 8:21 AM schrieb Dominik Csapak:
>> this returns a hash of existing service links for
>> mds/mgr/mons so that we know which services exists
>>
>> this is necessary since ceph itself does not save if a service is
>> defined somewhere, only when it runs
>>
>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>>   PVE/Ceph/Services.pm | 18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
>>
>> diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
>> index 739df266..a0203f9c 100644
>> --- a/PVE/Ceph/Services.pm
>> +++ b/PVE/Ceph/Services.pm
>> @@ -9,6 +9,24 @@ use PVE::RADOS;
>>   
>>   use File::Path;
>>   
>> +# checks links in /etc/systemd/system/ceph-* to list all services, even
>> +# those not running
> 
> hmm, what about (temporarily) disabled ones? or can we just say that won't
> happen with service unit templates.. Else we could possibly also check
> /var/lib/ceph/m{ds,gr,on} for old configured but not active (anymore) ones
> 
>> +sub get_local_services {
>> +    my $res = {};
>> +    for my $type (qw(mds mgr mon)) {
>> +	$res->{$type} = {};
>> +	my $path = "/etc/systemd/system/ceph-$type.target.wants";
>> +	my $regex = "ceph-$type\@(.*)\.service";
>> +	PVE::Tools::dir_glob_foreach($path, $regex, sub {
>> +	    my (undef, $id) = @_;
>> +	    $res->{$type}->{$id} = {
>> +		service => 1,
> 
> if we could get it in a cheap way it could be great to get it's state too
> (running, dead, ...?) or do we get that from ceph for running ones, and the
> difference from those and this set can be assumed to be dead?

the idea is that the user gets the full picture with the api call, which 
merges the metadata of the services (all running ones) and the existing
unit-instances (all existing ones)

so all existing but not running ones are either falsely enabled, or not 
running, we have no way to tell

oth, all services that run but have not corresponding service are either
falsely running or falsely disabled, again we have no real way of 
knowing so the admin has to pick the right course of action here

> 
>> +	    }
>> +	});
>> +    }
>> +    return $res;
>> +}
>> +
>>   sub ceph_service_cmd {
>>       my ($action, $service) = @_;
>>   
>>
> 





More information about the pve-devel mailing list