Blame SOURCES/0023-Ticket-50177-import-task-should-not-be-deleted-too-r.patch

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