769039
From aea4494eeb5351bcc26bf5e15411c28b96648445 Mon Sep 17 00:00:00 2001
769039
From: Thierry Bordaz <tbordaz@redhat.com>
769039
Date: Fri, 1 Feb 2019 15:36:01 +0100
769039
Subject: [PATCH] Ticket 50177 - import task should not be deleted too rapidely
769039
 after import finishes to be able to query the status
769039
769039
Bug Description:
769039
	scripts that create online import and export tasks do not define a Time To Life of the tasks.
769039
	As a consequence the task entry is cleared 2min (default value) after task completion.
769039
	This is too rapid and some admin scripts may miss the final task status.
769039
769039
Fix Description:
769039
	The fix is to keep the entry of completed online import and export tasks for 1 day.
769039
	It also allows defines a default TTL to 1h (instead of 2min)
769039
769039
https://pagure.io/389-ds-base/issue/50177
769039
769039
Reviewed by: Mark Reynolds
769039
769039
Platforms tested: F27
769039
769039
Flag Day: no
769039
769039
Doc impact: no
769039
---
769039
 ldap/admin/src/scripts/db2ldif.pl.in | 3 ++-
769039
 ldap/admin/src/scripts/ldif2db.pl.in | 3 ++-
769039
 ldap/servers/slapd/task.c            | 6 +++---
769039
 3 files changed, 7 insertions(+), 5 deletions(-)
769039
769039
diff --git a/ldap/admin/src/scripts/db2ldif.pl.in b/ldap/admin/src/scripts/db2ldif.pl.in
769039
index 0d220f00a..f7d12b48a 100644
769039
--- a/ldap/admin/src/scripts/db2ldif.pl.in
769039
+++ b/ldap/admin/src/scripts/db2ldif.pl.in
769039
@@ -241,7 +241,8 @@ if ($decrypt_on_export != 0) { $nsexportdecrypt = "nsExportDecrypt: true\n"; }
769039
 $nsprintkey = "";
769039
 if ($printkey == 0) { $nsprintkey = "nsPrintKey: false\n"; }
769039
 $nsldiffile = "nsFilename: ${ldiffile}\n";
769039
-$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsreplica}${nsnobase64}${nsnowrap}${nsnoversion}${nsnouniqueid}${nsuseid2entry}${nsonefile}${nsexportdecrypt}${nsprintkey}${nsldiffile}";
769039
+$ttl = "ttl: 86400";
769039
+$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsreplica}${nsnobase64}${nsnowrap}${nsnoversion}${nsnouniqueid}${nsuseid2entry}${nsonefile}${nsexportdecrypt}${nsprintkey}${nsldiffile}${ttl}";
769039
 
769039
 print("Exporting to ldif file: ${ldiffile}\n");
769039
 $rc = DSUtil::ldapmod($entry, %info);
769039
diff --git a/ldap/admin/src/scripts/ldif2db.pl.in b/ldap/admin/src/scripts/ldif2db.pl.in
769039
index a5d834f8e..486dcd053 100644
769039
--- a/ldap/admin/src/scripts/ldif2db.pl.in
769039
+++ b/ldap/admin/src/scripts/ldif2db.pl.in
769039
@@ -192,7 +192,8 @@ $nsmergechunksiz = "nsImportChunkSize: ${mergechunksiz}\n";
769039
 $nsgenuniqid = "nsUniqueIdGenerator: ${genuniqid}\n"; 
769039
 $nsuniqidname = "";
769039
 if ($uniqidname ne "") { $nsuniqidname = "nsUniqueIdGeneratorNamespace: ${uniqidname}\n"; }
769039
-$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsldiffiles}${nsnoattrindexes}${nsimportencrypt}${nsmergechunksiz}${nsgenuniqid}${nsuniqidname}";
769039
+$ttl = "ttl: 86400";
769039
+$entry = "${dn}${misc}${cn}${nsinstance}${nsincluded}${nsexcluded}${nsldiffiles}${nsnoattrindexes}${nsimportencrypt}${nsmergechunksiz}${nsgenuniqid}${nsuniqidname}${ttl}";
769039
 
769039
 $rc = DSUtil::ldapmod($entry, %info);
769039
 
769039
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
769039
index 698ee19b9..8c48c05b8 100644
769039
--- a/ldap/servers/slapd/task.c
769039
+++ b/ldap/servers/slapd/task.c
769039
@@ -46,7 +46,7 @@ static int shutting_down = 0;
769039
 #define TASK_PROGRESS_NAME "nsTaskCurrentItem"
769039
 #define TASK_WORK_NAME "nsTaskTotalItems"
769039
 
769039
-#define DEFAULT_TTL "120"                        /* seconds */
769039
+#define DEFAULT_TTL "3600"                        /* seconds */
769039
 #define TASK_SYSCONFIG_FILE_ATTR "sysconfigfile" /* sysconfig reload task file attr */
769039
 #define TASK_SYSCONFIG_LOGCHANGES_ATTR "logchanges"
769039
 #define TASK_TOMBSTONE_FIXUP "fixup tombstones task"
769039
@@ -387,8 +387,8 @@ slapi_task_status_changed(Slapi_Task *task)
769039
         if (e == NULL)
769039
             return;
769039
         ttl = atoi(fetch_attr(e, "ttl", DEFAULT_TTL));
769039
-        if (ttl > 3600)
769039
-            ttl = 3600; /* be reasonable. */
769039
+        if (ttl > (24*3600))
769039
+            ttl = (24*3600); /* be reasonable, allow to check task status not longer than one day  */
769039
         expire = time(NULL) + ttl;
769039
         task->task_flags |= SLAPI_TASK_DESTROYING;
769039
         /* queue an event to destroy the state info */
769039
-- 
769039
2.17.2
769039