Skip to content

Commit 38527fe

Browse files
mattiagiupponigiohappy
authored andcommitted
[Backport Fixes #12828] New remote datasets are not registered inside proxy allowed hosts when GeoNode runs asynchoronously
1 parent aa28677 commit 38527fe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

geonode/proxy/utils.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.conf import settings
44
from django.db.models import signals
5-
5+
from django.utils.timezone import now
66

77
site_url = urlsplit(settings.SITEURL)
88

@@ -11,6 +11,8 @@
1111

1212
class ProxyUrlsRegistry:
1313
_first_init = True
14+
_last_registry_load = None
15+
_registry_reload_threshold = getattr(settings, "PROXY_RELOAD_REGISTRY_THRESHOLD_DAYS", 1)
1416

1517
def initialize(self):
1618
from geonode.base.models import Link
@@ -30,12 +32,16 @@ def initialize(self):
3032
signals.post_delete.connect(link_post_delete, sender=Link)
3133
self._first_init = False
3234

35+
self._last_registry_load = now()
36+
3337
def set(self, hosts):
3438
self.proxy_allowed_hosts = set(hosts)
39+
self._last_registry_load = now()
3540
return self
3641

3742
def clear(self):
3843
self.proxy_allowed_hosts = set()
44+
self._last_registry_load = now()
3945
return self
4046

4147
def register_host(self, host):
@@ -45,6 +51,11 @@ def unregister_host(self, host):
4551
self.proxy_allowed_hosts.remove(host)
4652

4753
def get_proxy_allowed_hosts(self):
54+
if (
55+
self._last_registry_load is None
56+
or (now() - self._last_registry_load).days >= self._registry_reload_threshold
57+
):
58+
self.initialize()
4859
return self.proxy_allowed_hosts
4960

5061

0 commit comments

Comments
 (0)