Ticket #1549: 0001-Preserve-project-usage-across-qmaster-restarts.patch

File 0001-Preserve-project-usage-across-qmaster-restarts.patch, 2.8 KB (added by markdixon, 5 years ago)
  • source/daemons/qmaster/setup_qmaster.c

    From 58418185b7d65613235c7ffe64d519b5aa43310f Mon Sep 17 00:00:00 2001
    From: Mark Dixon <m.c.dixon@leeds.ac.uk>
    Date: Mon, 20 Jul 2015 12:15:08 +0100
    Subject: [PATCH] Preserve project usage across qmaster restarts
    
    Project usage is only stored in the spool's user objects, not project
    objects. This commit regenerates the project usage from the available
    user objects.
    
    Without this change, project usage is lost across qmaster restarts.
    ---
     source/daemons/qmaster/setup_qmaster.c | 37 +++++++++++++++++++++++++++++++++-
     1 file changed, 36 insertions(+), 1 deletion(-)
    
    diff --git a/source/daemons/qmaster/setup_qmaster.c b/source/daemons/qmaster/setup_qmaster.c
    index 826d786..31a8ba4 100644
    a b remove_invalid_job_references(bool job_spooling, int user, object_description *o 
    133133
    134134static int    debit_all_jobs_from_qs(void);
    135135static void   init_categories(void);
     136static void   init_project_usage_from_users(lList *project_list, lList *user_list);
    136137
    137138
    138139/****** qmaster/setup_qmaster/sge_setup_qmaster() ******************************
    static int setup_qmaster(sge_gdi_ctx_class_t *ctx) 
    12351236   answer_list_output(&answer_list);
    12361237
    12371238   remove_invalid_job_references(job_spooling, 0, object_base);
    1238    
     1239   init_project_usage_from_users(*object_base[SGE_TYPE_PROJECT].list, *object_base[SGE_TYPE_USER].list);
     1240
    12391241   DPRINTF(("scheduler config -----------------------------------\n"));
    12401242   
    12411243   sge_read_sched_configuration(ctx, spooling_context, &answer_list);
    static void init_categories(void) 
    14741476   lFreeList(&u_list);
    14751477}
    14761478
     1479/****** setup_qmaster/init_project_usage_from_users() ****************************************
     1480*  NAME
     1481*     init_project_usage_from_users() -- Initialize projects wrts usage
     1482*
     1483*  SYNOPSIS
     1484*     static void init_project_usage_from_users(lList*, lList*)
     1485*
     1486*  FUNCTION
     1487*     Initialize projects with project usage stored in user objects
     1488*     (project usage is not saved to the spool copy of project objects)
     1489*
     1490*  NOTES
     1491*     MT-NOTE: ?
     1492*******************************************************************************/
     1493static void init_project_usage_from_users(lList *project_list, lList *user_list)
     1494{
     1495   lListElem *user;
     1496   for_each(user, user_list) {
     1497      lListElem *uu_project;
     1498      for_each(uu_project, lGetList(user, UU_project)) {
     1499
     1500         /* Add usage to project */
     1501         lListElem *project = prj_list_locate(project_list, lGetString(uu_project, UPP_name));
     1502         if (project) {
     1503            if (lGetList(project, PR_usage)) {
     1504               usage_list_sum(lGetList(project, PR_usage), lGetList(uu_project, UPP_usage));
     1505            } else {
     1506               lSetList(project, PR_usage, lCopyList("usage", lGetList(uu_project, UPP_usage)));
     1507            }
     1508         }
     1509      }
     1510   }
     1511}