~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/sview/part_info.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7
7
 *  Written by Danny Auble <da@llnl.gov>
8
8
 *
9
 
 *  LLNL-CODE-402394.
 
9
 *  CODE-OCEC-09-009. All rights reserved.
10
10
 *   
11
11
 *  This file is part of SLURM, a resource management program.
12
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
12
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
13
 *  Please also read the included file: DISCLAIMER.
13
14
 *  
14
15
 *  SLURM is free software; you can redistribute it and/or modify it under
15
16
 *  the terms of the GNU General Public License as published by the Free
86
87
#ifndef HAVE_BG
87
88
        SORTID_NODELIST, 
88
89
#endif
 
90
        SORTID_NODE_INX,
89
91
        SORTID_NODES, 
90
92
        SORTID_ONLY_LINE, 
91
93
        SORTID_PRIORITY,
154
156
         create_model_part, admin_edit_part},
155
157
        {G_TYPE_INT, SORTID_ONLY_LINE, NULL, FALSE, EDIT_NONE, refresh_part,
156
158
         create_model_part, admin_edit_part},
 
159
        {G_TYPE_POINTER, SORTID_NODE_INX,  NULL, FALSE, EDIT_NONE, 
 
160
         refresh_part, create_model_part, admin_edit_part},
157
161
        {G_TYPE_INT, SORTID_UPDATED, NULL, FALSE, EDIT_NONE, refresh_part,
158
162
         create_model_part, admin_edit_part},
159
163
 
190
194
        {G_TYPE_STRING, NODE_PAGE, "Nodes", TRUE, PART_PAGE},
191
195
#endif
192
196
        {G_TYPE_STRING, SUBMIT_PAGE, "Job Submit", FALSE, PART_PAGE},
 
197
        {G_TYPE_STRING, RESV_PAGE, "Reservations", TRUE, PART_PAGE},
193
198
        {G_TYPE_NONE, -1, NULL, FALSE, EDIT_NONE}
194
199
};
195
200
 
196
 
#ifdef HAVE_BG
197
 
static void _update_nodes_for_bg(int node_scaling,
198
 
                                 node_info_msg_t *node_msg,
199
 
                                 bg_info_record_t *bg_info_record);
200
 
/* ERROR_STATE must be last since that will affect the state of the rest of the
201
 
   midplane.
202
 
*/
203
 
enum {
204
 
        SVIEW_BG_IDLE_STATE,
205
 
        SVIEW_BG_ALLOC_STATE,
206
 
        SVIEW_BG_ERROR_STATE
207
 
};
208
 
#endif
209
 
 
210
201
static display_data_t *local_display_data = NULL;
211
202
 
212
203
static char *got_edit_signal = NULL;
220
211
                                    int line);
221
212
static node_info_t *_find_node(char *node_name, node_info_msg_t *node_msg);
222
213
 
223
 
#ifdef HAVE_BG
224
 
 
225
 
static void _update_nodes_for_bg(int node_scaling,
226
 
                                 node_info_msg_t *node_msg,
227
 
                                 bg_info_record_t *bg_info_record)
228
 
{
229
 
        node_info_t *node_ptr = NULL;
230
 
        hostlist_t hl;
231
 
        char *node_name = NULL;
232
 
 
233
 
        /* we are using less than one node */
234
 
        if(bg_info_record->conn_type == SELECT_SMALL) 
235
 
                node_scaling = bg_info_record->node_cnt;
236
 
                   
237
 
        hl = hostlist_create(bg_info_record->nodes);
238
 
        while (1) {
239
 
                if (node_name)
240
 
                        free(node_name);
241
 
                node_name = hostlist_shift(hl);
242
 
                if (!node_name)
243
 
                        break;
244
 
                node_ptr = _find_node(node_name, node_msg);
245
 
                if (!node_ptr)
246
 
                        continue;
247
 
                /* cores is overloaded to be the cnodes in an error
248
 
                 * state and used_cpus is overloaded to be the nodes in
249
 
                 * use.  No block should be sent in here if it isn't
250
 
                 * in use (that doesn't mean in a free state, it means
251
 
                 * the user isn't slurm or the block is in an error state.  
252
 
                 */
253
 
                if(bg_info_record->state == RM_PARTITION_ERROR) 
254
 
                        node_ptr->cores += node_scaling;
255
 
                else
256
 
                        node_ptr->used_cpus += node_scaling;
257
 
        }
258
 
        hostlist_destroy(hl);
259
 
        
260
 
}
261
 
#endif
262
214
 
263
215
static int 
264
216
_build_min_max_16_string(char *buffer, int buf_size, 
1050
1002
 
1051
1003
        gtk_tree_store_set(treestore, iter, SORTID_NODELIST, 
1052
1004
                           part_ptr->nodes, -1);
 
1005
 
 
1006
        gtk_tree_store_set(treestore, iter, 
 
1007
                           SORTID_NODE_INX, part_ptr->node_inx, -1);
1053
1008
        
1054
1009
        gtk_tree_store_set(treestore, iter, SORTID_ONLY_LINE, 0, -1);
1055
1010
        /* clear out info for the main listing */
1416
1371
        return sview_part_info;
1417
1372
}
1418
1373
 
 
1374
static int _sview_part_sort_aval_dec(sview_part_info_t* rec_a,
 
1375
                                     sview_part_info_t* rec_b)
 
1376
{
 
1377
        int size_a = rec_a->part_ptr->total_nodes;
 
1378
        int size_b = rec_b->part_ptr->total_nodes;
 
1379
 
 
1380
        if (size_a > size_b)
 
1381
                return -1;
 
1382
        else if (size_a < size_b)
 
1383
                return 1;
 
1384
 
 
1385
        if(rec_a->part_ptr->nodes && rec_b->part_ptr->nodes) {
 
1386
                size_a = strcmp(rec_a->part_ptr->nodes, rec_b->part_ptr->nodes);
 
1387
                if (size_a > 0)
 
1388
                        return -1;
 
1389
                else if (size_a < 0)
 
1390
                        return 1;
 
1391
        }
 
1392
        return 0;
 
1393
}
 
1394
 
1419
1395
static List _create_part_info_list(partition_info_msg_t *part_info_ptr,
1420
1396
                                   node_info_msg_t *node_info_ptr,
1421
1397
                                   node_select_info_msg_t *node_select_ptr,
1432
1408
        hostlist_t hl;
1433
1409
#ifdef HAVE_BG
1434
1410
        int j;
1435
 
        bg_info_record_t *bg_info_record = NULL;
1436
1411
        int node_scaling = part_info_ptr->partition_array[0].node_scaling;
1437
 
        char *slurm_user = NULL;
 
1412
        int block_error = 0;
1438
1413
#endif
1439
1414
        if(!changed && info_list) {
1440
1415
                return info_list;
1449
1424
                return NULL;
1450
1425
        }
1451
1426
 
1452
 
#ifdef HAVE_BG
1453
 
        slurm_user = xstrdup(slurmctld_conf.slurm_user_name);
1454
 
 
1455
 
        for (i=0; i<node_info_ptr->record_count; i++) {
1456
 
                node_ptr = &(node_info_ptr->node_array[i]);
1457
 
                /* in each node_ptr we overload the threads var
1458
 
                 * with the number of cnodes in the used_cpus var
1459
 
                 * will be used to tell how many cnodes are
1460
 
                 * allocated and the cores will represent the cnodes
1461
 
                 * in an error state. So we can get an idle count by
1462
 
                 * subtracting those 2 numbers from the total possible
1463
 
                 * cnodes (which are the idle cnodes).
1464
 
                 */
1465
 
                node_ptr->threads = node_scaling;
1466
 
                node_ptr->cores = 0;
1467
 
                node_ptr->used_cpus = 0;
1468
 
        }
1469
 
 
1470
 
        for (i=0; i<node_select_ptr->record_count; i++) {
1471
 
                bg_info_record = &(node_select_ptr->bg_info_array[i]);
1472
 
                
1473
 
                /* this block is idle we won't mark it */
1474
 
                if (bg_info_record->state != RM_PARTITION_ERROR
1475
 
                    && !strcmp(slurm_user, bg_info_record->owner_name))
1476
 
                        continue;
1477
 
                _update_nodes_for_bg(node_scaling, node_info_ptr,
1478
 
                                     bg_info_record);
1479
 
        }
1480
 
        xfree(slurm_user);
1481
 
 
1482
 
#endif
1483
 
 
1484
 
 
1485
1427
        for (i=0; i<part_info_ptr->record_count; i++) {
1486
1428
                part_ptr = &(part_info_ptr->partition_array[i]);
1487
1429
                if (!part_ptr->nodes || (part_ptr->nodes[0] == '\0'))
1493
1435
                        node_ptr = _find_node(node_name, node_info_ptr);
1494
1436
                        free(node_name);
1495
1437
#ifdef HAVE_BG
1496
 
                        for(j=0; j<3; j++) {
 
1438
                        if((node_ptr->node_state & NODE_STATE_DRAIN) 
 
1439
                           && (node_ptr->node_state & NODE_STATE_FAIL)) {
 
1440
                                node_ptr->node_state &= ~NODE_STATE_DRAIN;
 
1441
                                node_ptr->node_state &= ~NODE_STATE_FAIL;
 
1442
                                block_error = 1;
 
1443
                        } else
 
1444
                                block_error = 0;
 
1445
                        node_ptr->threads = node_scaling;
 
1446
                        for(j=0; j<4; j++) {
1497
1447
                                int norm = 0;
1498
1448
                                switch(j) {
1499
1449
                                case SVIEW_BG_IDLE_STATE:
1517
1467
                                         */
1518
1468
                                        node_ptr->threads -=
1519
1469
                                                (node_ptr->cores
 
1470
                                                 + node_ptr->sockets
1520
1471
                                                 + node_ptr->used_cpus);
 
1472
                                        if((int16_t)node_ptr->threads < 0)
 
1473
                                                node_ptr->threads = 0;
1521
1474
                                        if(node_ptr->threads == node_scaling)
1522
1475
                                                norm = 1;
1523
1476
                                        else {
1539
1492
                                        node_ptr->threads =
1540
1493
                                                node_ptr->used_cpus;
1541
1494
                                        break;
 
1495
                                case SVIEW_BG_DRAINING_STATE:
 
1496
                                        /* get the draining node count */
 
1497
                                        if(!node_ptr->sockets) 
 
1498
                                                continue;
 
1499
                                        node_ptr->node_state =
 
1500
                                                NODE_STATE_ALLOCATED;
 
1501
                                        node_ptr->node_state |= 
 
1502
                                                NODE_STATE_DRAIN;
 
1503
                                        node_ptr->threads = node_ptr->sockets;
 
1504
                                        break;
1542
1505
                                case SVIEW_BG_ERROR_STATE:
1543
1506
                                        /* get the error node count */
1544
1507
                                        if(!node_ptr->cores) 
1545
1508
                                                continue;
1546
1509
                                        node_ptr->node_state &=
1547
1510
                                                NODE_STATE_FLAGS;
1548
 
                                        node_ptr->node_state |= 
 
1511
                                        node_ptr->node_state |=
1549
1512
                                                NODE_STATE_DRAIN;
1550
1513
                                        node_ptr->threads = node_ptr->cores;
1551
1514
                                        break;
1586
1549
                         */
1587
1550
                        if(norm) 
1588
1551
                                break;
 
1552
                        else if(i == SVIEW_BG_ERROR_STATE) {
 
1553
                                if(block_error)
 
1554
                                        node_ptr->node_state
 
1555
                                                |= NODE_STATE_FAIL;
 
1556
                        }
1589
1557
                        }
1590
1558
#endif
1591
1559
                }
1592
1560
                hostlist_destroy(hl);
1593
1561
                list_append(info_list, sview_part_info);
1594
1562
        }
 
1563
 
 
1564
        list_sort(info_list,
 
1565
                  (ListCmpF)_sview_part_sort_aval_dec);
 
1566
 
1595
1567
        return info_list;
1596
1568
}
1597
1569
 
1633
1605
                if(!strcmp(part_ptr->name, name)) {
1634
1606
                        j=0;
1635
1607
                        while(part_ptr->node_inx[j] >= 0) {
1636
 
                                if(!first_time)
1637
 
                                        change_grid_color(
1638
 
                                                popup_win->grid_button_list,
1639
 
                                                part_ptr->node_inx[j],
1640
 
                                                part_ptr->node_inx[j+1], i);
1641
 
                                else
1642
 
                                        get_button_list_from_main(
1643
 
                                                &popup_win->grid_button_list,
1644
 
                                                part_ptr->node_inx[j],
1645
 
                                                part_ptr->node_inx[j+1],
1646
 
                                                i);
 
1608
                                change_grid_color(
 
1609
                                        popup_win->grid_button_list,
 
1610
                                        part_ptr->node_inx[j],
 
1611
                                        part_ptr->node_inx[j+1], i,
 
1612
                                        true);
1647
1613
                                j += 2;
1648
1614
                        }
1649
1615
                        _layout_part_record(treeview, sview_part_info, update);
1674
1640
                        
1675
1641
                        goto need_refresh;
1676
1642
                }
1677
 
                put_buttons_in_table(popup_win->grid_table,
1678
 
                                     popup_win->grid_button_list);
1679
 
 
1680
1643
        }
1681
1644
        gtk_widget_show(spec_info->display_widget);
1682
1645
                
1705
1668
        static bool changed = 0;
1706
1669
                
1707
1670
        if(!force && ((now - last) < global_sleep_time)) {
 
1671
                if(*part_ptr != part_info_ptr)
 
1672
                        error_code = SLURM_SUCCESS;
1708
1673
                *part_ptr = part_info_ptr;
1709
1674
                if(changed) 
1710
1675
                        return SLURM_SUCCESS;
1729
1694
        }
1730
1695
        
1731
1696
        part_info_ptr = new_part_ptr;
 
1697
 
 
1698
        if(*part_ptr != part_info_ptr) 
 
1699
                error_code = SLURM_SUCCESS;
 
1700
 
1732
1701
        *part_ptr = new_part_ptr;
1733
1702
        return error_code;
1734
1703
}
2045
2014
                                change_grid_color(grid_button_list,
2046
2015
                                                  part_ptr->node_inx[j],
2047
2016
                                                  part_ptr->node_inx[j+1],
2048
 
                                                  i);
 
2017
                                                  i, true);
2049
2018
                        j += 2;
2050
2019
                }
2051
2020
                i++;
2096
2065
        sview_part_info_t *sview_part_info_ptr = NULL;
2097
2066
        partition_info_t *part_ptr = NULL;
2098
2067
        ListIterator itr = NULL;
2099
 
        char *host = NULL, *host2 = NULL;
2100
 
        hostlist_t hostlist = NULL;
2101
 
        int found = 0;
 
2068
        hostset_t hostset = NULL;
2102
2069
        
2103
2070
        if(!spec_info->display_widget)
2104
2071
                setup_popup_info(popup_win, display_data_part, SORTID_CNT);
2203
2170
                                 SORTID_CNT);
2204
2171
        }
2205
2172
        
2206
 
        if(popup_win->grid_button_list) {
2207
 
                list_destroy(popup_win->grid_button_list);
2208
 
        }              
2209
 
        
2210
 
#ifdef HAVE_3D
2211
 
        popup_win->grid_button_list = copy_main_button_list();
2212
 
#else
2213
 
        popup_win->grid_button_list = list_create(destroy_grid_button);
2214
 
#endif  
 
2173
        setup_popup_grid_list(popup_win);
2215
2174
 
2216
2175
        spec_info->view = INFO_VIEW;
2217
2176
        if(spec_info->type == INFO_PAGE) {
2224
2183
        send_info_list = list_create(NULL);     
2225
2184
        
2226
2185
        itr = list_iterator_create(info_list);
 
2186
        i = -1;
2227
2187
        while ((sview_part_info_ptr = list_next(itr))) {
2228
2188
                i++;
2229
 
                part_ptr = sview_part_info_ptr->part_ptr;       
 
2189
                part_ptr = sview_part_info_ptr->part_ptr;
2230
2190
                switch(spec_info->type) {
 
2191
                case RESV_PAGE:
2231
2192
                case NODE_PAGE:
2232
2193
                        if(!part_ptr->nodes)
2233
2194
                                continue;
2234
2195
 
2235
 
                        hostlist = hostlist_create(
2236
 
                                spec_info->search_info->gchar_data);
2237
 
                        host = hostlist_shift(hostlist);
2238
 
                        hostlist_destroy(hostlist);
2239
 
                        if(!host) 
2240
 
                                continue;
2241
 
                        
2242
 
                        hostlist = hostlist_create(part_ptr->nodes);
2243
 
                        found = 0;
2244
 
                        while((host2 = hostlist_shift(hostlist))) { 
2245
 
                                if(!strcmp(host, host2)) {
2246
 
                                        free(host2);
2247
 
                                        found = 1;
2248
 
                                        break; 
2249
 
                                }
2250
 
                                free(host2);
 
2196
                        if(!(hostset = hostset_create(
 
2197
                                     spec_info->search_info->gchar_data)))
 
2198
                                continue;
 
2199
                        if(!hostset_intersects(hostset, part_ptr->nodes)) {
 
2200
                                hostset_destroy(hostset);
 
2201
                                continue;
2251
2202
                        }
2252
 
                        hostlist_destroy(hostlist);
2253
 
                        if(!found)
2254
 
                                continue;
 
2203
                        hostset_destroy(hostset);                               
2255
2204
                        break;
2256
2205
                case PART_PAGE:
2257
2206
                case BLOCK_PAGE:
2268
2217
                list_push(send_info_list, sview_part_info_ptr);
2269
2218
                j=0;
2270
2219
                while(part_ptr->node_inx[j] >= 0) {
2271
 
#ifdef HAVE_3D
2272
2220
                        change_grid_color(
2273
2221
                                popup_win->grid_button_list,
2274
2222
                                part_ptr->node_inx[j],
2275
 
                                part_ptr->node_inx[j+1], i);
2276
 
#else
2277
 
                        get_button_list_from_main(
2278
 
                                &popup_win->grid_button_list,
2279
 
                                part_ptr->node_inx[j],
2280
 
                                part_ptr->node_inx[j+1], i);
2281
 
#endif
 
2223
                                part_ptr->node_inx[j+1], i, false);
2282
2224
                        j += 2;
2283
2225
                }
2284
2226
        }
2285
2227
        list_iterator_destroy(itr);
2286
 
        put_buttons_in_table(popup_win->grid_table,
2287
 
                             popup_win->grid_button_list);
2288
2228
         
2289
2229
        _update_info_part(send_info_list, 
2290
2230
                          GTK_TREE_VIEW(spec_info->display_widget));
2304
2244
 
2305
2245
        switch(type) {
2306
2246
        case TAB_CLICKED:
2307
 
                make_fields_menu(menu, display_data_part, SORTID_CNT);
 
2247
                make_fields_menu(NULL, menu, display_data_part, SORTID_CNT);
2308
2248
                break;
2309
2249
        case ROW_CLICKED:
2310
2250
                make_options_menu(tree_view, path, menu, options_data_part);
2311
2251
                break;
2312
2252
        case POPUP_CLICKED:
2313
 
                make_popup_fields_menu(popup_win, menu);
 
2253
                make_fields_menu(popup_win, menu,
 
2254
                                 popup_win->display_data, SORTID_CNT);
2314
2255
                break;
2315
2256
        default:
2316
2257
                g_error("UNKNOWN type %d given to set_fields\n", type);
2326
2267
        ListIterator itr = NULL;
2327
2268
        popup_info_t *popup_win = NULL;
2328
2269
        GError *error = NULL;
2329
 
                                
 
2270
        GtkTreeIter par_iter;
 
2271
                        
2330
2272
        gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1);
2331
2273
        
2332
2274
        switch(id) {
2333
2275
        case JOB_PAGE:
2334
2276
                snprintf(title, 100, "Job(s) in partition %s", name);
2335
2277
                break;
 
2278
        case RESV_PAGE:
 
2279
                snprintf(title, 100, "Reservation(s) in partition %s", name);
 
2280
                break;
2336
2281
        case NODE_PAGE:
2337
2282
                gtk_tree_model_get(model, iter, SORTID_ONLY_LINE,
2338
2283
                                   &only_line, -1);
2394
2339
                return;
2395
2340
        }
2396
2341
 
 
2342
        /* Pass the model and the structs from the iter so we can always get
 
2343
           the current node_inx.
 
2344
        */
 
2345
        popup_win->model = model;
 
2346
        popup_win->iter = *iter;
 
2347
        popup_win->node_inx_id = SORTID_NODE_INX;
 
2348
 
2397
2349
        switch(id) {
2398
2350
        case JOB_PAGE:
2399
2351
        case BLOCK_PAGE: 
2401
2353
                popup_win->spec_info->search_info->gchar_data = name;
2402
2354
                //specific_info_job(popup_win);
2403
2355
                break;
 
2356
        case RESV_PAGE:
2404
2357
        case NODE_PAGE:
2405
2358
                g_free(name);
2406
 
                gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1);
 
2359
                /* we want to include the parent's nodes here not just
 
2360
                   the subset */
 
2361
                if(gtk_tree_model_iter_parent(model, &par_iter, iter)) 
 
2362
                        gtk_tree_model_get(model, &par_iter,
 
2363
                                           SORTID_NODELIST, &name, -1);
 
2364
                else
 
2365
                        gtk_tree_model_get(model, iter, 
 
2366
                                           SORTID_NODELIST, &name, -1);
2407
2367
                popup_win->spec_info->search_info->gchar_data = name;
2408
2368
                if(state && strlen(state)) {
2409
2369
                        popup_win->spec_info->search_info->search_type =