Skip to content

Commit c6dae7c

Browse files
authored
[core] Check if oozie is present in INSTALLED_APPS before importing Job model in config_validator (#4056)
1 parent ff157d2 commit c6dae7c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

desktop/core/src/desktop/conf.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,6 @@ def config_validator(user):
26492649
from desktop.lib import i18n
26502650
from desktop.models import Document, Document2 # Avoid cyclic loop
26512651
from desktop.settings import DOCUMENT2_MAX_ENTRIES # Avoid cyclic loop
2652-
from oozie.models import Job
26532652

26542653
res = []
26552654

@@ -2678,10 +2677,14 @@ def config_validator(user):
26782677
res.append(('SavedQuery_CLEANUP_WARNING', str(_('Saved Query has more than %d entries: %d, '
26792678
'please run "hue desktop_document_cleanup --cm-managed" to remove old entries' % (DOCUMENT2_MAX_ENTRIES, sq_count)))))
26802679

2681-
job_count = Job.objects.count()
2682-
if job_count > DOCUMENT2_MAX_ENTRIES:
2683-
res.append(('OOZIEJOB_CLEANUP_WARNING', str(_('Oozie Job has more than %d entries: %d, '
2684-
'please run "hue desktop_document_cleanup --cm-managed" to remove old entries' % (DOCUMENT2_MAX_ENTRIES, job_count)))))
2680+
# Check if oozie is enabled and present in INSTALLED_APPS
2681+
from desktop.settings import INSTALLED_APPS # Avoid circular import
2682+
if 'oozie' in INSTALLED_APPS:
2683+
from oozie.models import Job
2684+
job_count = Job.objects.count()
2685+
if job_count > DOCUMENT2_MAX_ENTRIES:
2686+
res.append(('OOZIEJOB_CLEANUP_WARNING', str(_('Oozie Job has more than %d entries: %d, '
2687+
'please run "hue desktop_document_cleanup --cm-managed" to remove old entries' % (DOCUMENT2_MAX_ENTRIES, job_count)))))
26852688

26862689
if not get_secret_key():
26872690
res.append((SECRET_KEY, str(_("Secret key should be configured as a random string. All sessions will be lost on restart"))))

0 commit comments

Comments
 (0)