[pve-devel] [PATCH v4 pve-manager 55/69] api: notification: disallow removing targets if they are used
Lukas Wagner
l.wagner at proxmox.com
Mon Jul 24 16:09:22 CEST 2023
On 7/24/23 15:50, Wolfgang Bumiller wrote:
>> +sub target_used_by {
>> + my ($target) = @_;
>> +
>> + my $used_by = [];
>> +
>> + # Check keys in datacenter.cfg
>> + my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
>> + for my $key (qw(target-package-updates target-replication target-fencing)) {
>> + if ($dc_conf->{notify} && $dc_conf->{notify}->{$key} eq $target) {
>> + push @$used_by, $key;
>> + }
>> + }
>> +
>> + # Check backup jobs
>> + my $jobs_conf = PVE::Cluster::cfs_read_file('jobs.cfg');
>
> I'm not exactly a big fan of requiring a function to know all the places
> that might declare notification targets, but I suppose for now this is
> "good enough".
>
> If more of these get added we might need a better way, for instance we
> could give other packages a way to register callbacks to collect this
> information...
>
Yes, I plan to implement a 'notification sender registry' at some point,
I think your suggestion could be integrated there quite nicely.
Thanks!
--
- Lukas
More information about the pve-devel
mailing list