Skip to content

Commit 330b1b6

Browse files
authored
Merge pull request #6855 from BOINC/dpa_buda26
BUDA: add 'max output file size' parameter to BUDA apps
2 parents f0ab0d4 + c1ad987 commit 330b1b6

File tree

4 files changed

+43
-24
lines changed

4 files changed

+43
-24
lines changed

html/inc/buda.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ function user_can_submit($user, $app_desc) {
6464
return false;
6565
}
6666

67-
// can user edit app or variants?
67+
// can user edit the BUDA app or variants?
68+
// needs to be creator or have manage_all access
6869
//
6970
function user_can_manage($user, $app_desc) {
7071
if ($app_desc->user_id == $user->id) {
7172
return true;
7273
}
74+
$us = BoincUserSubmit::lookup_userid($user->id);
75+
if ($us->manage_all) return true;
7376
return false;
7477
}
7578

html/inc/submit_util.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,20 @@ function file_ref_in($fname) {
503503
$fname
504504
));
505505
}
506-
function file_info_out($i) {
506+
function file_info_out($i, $max_nbytes) {
507+
if (!$max_nbytes) {
508+
$max_nbytes = MEGA;
509+
}
507510
return sprintf(
508511
' <file_info>
509512
<name><OUTFILE_%d/></name>
510513
<generated_locally/>
511514
<upload_when_present/>
512-
<max_nbytes>5000000</max_nbytes>
515+
<max_nbytes>%d</max_nbytes>
513516
<url><UPLOAD_URL/></url>
514517
</file_info>
515518
',
516-
$i
519+
$i, $max_nbytes
517520
);
518521
}
519522

html/user/buda.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function file_row($app, $variant, $dir, $f) {
105105
}
106106

107107
function variant_view($user) {
108-
global $buda_root, $manage_access;
108+
global $buda_root;
109109
$app = get_str('app');
110110
if (!is_valid_filename($app)) die('bad arg');
111111
$app_desc = get_buda_app_desc($app);
@@ -134,7 +134,7 @@ function variant_view($user) {
134134
end_table();
135135
echo '<hr>';
136136

137-
if ($manage_access && user_can_manage($user, $app_desc)) {
137+
if (user_can_manage($user, $app_desc)) {
138138
echo '<p>';
139139
show_button_small(
140140
"buda.php?action=variant_form&app=$app&variant=$variant",
@@ -266,7 +266,7 @@ function create_templates($app, $desc, $dir) {
266266
$x = "<output_template>\n";
267267
$i = 0;
268268
foreach ($desc->output_file_names as $fname) {
269-
$x .= file_info_out($i++);
269+
$x .= file_info_out($i++, $desc->max_nbytes_mb*MEGA);
270270
}
271271
$x .= " <result>\n";
272272
$i = 0;
@@ -490,6 +490,7 @@ function app_form($desc=null) {
490490
$desc->long_name = null;
491491
$desc->input_file_names = [];
492492
$desc->output_file_names = [];
493+
$desc->max_nbytes_mb = 10;
493494
$desc->min_nsuccess = 1;
494495
$desc->max_total = 2;
495496
$desc->max_delay_days = 7;
@@ -510,6 +511,14 @@ function app_form($desc=null) {
510511
'output_file_names',
511512
implode(' ', $desc->output_file_names)
512513
);
514+
if (empty($desc->max_nbytes_mb)) {
515+
$desc->max_nbytes_mb = 10;
516+
}
517+
form_input_text(
518+
'Max output file size, MB',
519+
'max_nbytes_mb',
520+
$desc->max_nbytes_mb
521+
);
513522
form_input_text(
514523
'Run at most this many total instances of each job',
515524
'max_total',
@@ -620,6 +629,7 @@ function app_action($user) {
620629
} else {
621630
$output_file_names = [];
622631
}
632+
$desc->max_nbytes_mb = get_int('max_nbytes_mb');
623633
$desc->long_name = get_str('long_name');
624634
$desc->input_file_names = $input_file_names;
625635
$desc->output_file_names = $output_file_names;
@@ -674,7 +684,7 @@ function handle_app_edit() {
674684
}
675685

676686
function app_details($user) {
677-
global $buda_root, $manage_access;
687+
global $buda_root;
678688
$name = get_str('name');
679689
$desc = get_buda_app_desc($name);
680690
if (!$desc) error_page("no desc file $path");
@@ -699,6 +709,12 @@ function app_details($user) {
699709
'Output filenames:',
700710
implode(',', $desc->output_file_names)
701711
);
712+
if (!empty($desc->max_nbytes_mb)) {
713+
row2(
714+
'Max output file size, MB',
715+
$desc->max_nbytes_mb
716+
);
717+
}
702718
if (!empty($desc->max_total)) {
703719
row2('Max total instances per job:', $desc->max_total);
704720
} else {
@@ -714,7 +730,7 @@ function app_details($user) {
714730
} else {
715731
row2('Max job turnaround time, days:', '7');
716732
}
717-
if ($manage_access && user_can_manage($user, $desc)) {
733+
if (user_can_manage($user, $desc)) {
718734
row2('',
719735
button_text_small(
720736
sprintf('buda.php?action=%s&name=%s', 'app_edit', $desc->name),
@@ -731,15 +747,15 @@ function app_details($user) {
731747
);
732748
}
733749
row2('Variants', implode('<p>', $x));
734-
if ($manage_access && user_can_manage($user, $desc)) {
750+
if (user_can_manage($user, $desc)) {
735751
row2('',
736752
button_text_small(
737753
"buda.php?action=variant_form&app=$name",
738754
'Add variant'
739755
)
740756
);
741757
}
742-
} else if ($manage_access) {
758+
} else if (user_can_manage($user, $desc)) {
743759
row2('Variants',
744760
button_text_small(
745761
"buda.php?action=variant_form&app=$name",
@@ -759,42 +775,39 @@ function app_details($user) {
759775
page_tail();
760776
}
761777

762-
// Users with manage access to BUDA can add/delete apps and variants.
763-
// Others can just view.
764-
// Might want to refine this at some point
765-
766778
$user = get_logged_in_user();
767779
$buda_app = BoincApp::lookup("name='buda'");
768780
if (!$buda_app) error_page('no buda app');
769-
$manage_access = has_manage_access($user, $buda_app->id);
781+
782+
// does user have right to right to view and create BUDA apps?
783+
//
784+
if (!has_manage_access($user, $buda_app->id)) {
785+
error_page('no access');
786+
}
787+
788+
$us = BoincUserSubmit::lookup_userid($user->id);
789+
$manage_all = $us->manage_all;
770790

771791
$action = get_str('action', true);
772792
switch ($action) {
773793
case 'app_edit':
774-
if (!$manage_access) error_page('no access');
775794
handle_app_edit(); break;
776795
case 'app_form':
777-
if (!$manage_access) error_page('no access');
778796
app_form(); break;
779797
case 'app_action':
780-
if (!$manage_access) error_page('no access');
781798
app_action($user); break;
782799
case 'app_details':
783800
app_details($user); break;
784801
case 'app_delete':
785-
if (!$manage_access) error_page('no access');
786802
app_delete(); break;
787803
case 'variant_view':
788804
variant_view($user); break;
789805
case 'variant_form':
790-
if (!$manage_access) error_page('no access');
791806
variant_form($user); break;
792807
case 'variant_action':
793-
if (!$manage_access) error_page('no access');
794808
variant_action($user);
795809
break;
796810
case 'variant_delete':
797-
if (!$manage_access) error_page('no access');
798811
variant_delete();
799812
break;
800813
case 'view_file':

html/user/buda_submit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function submit_form($user) {
8989
'exp_runtime_days', .5
9090
);
9191
form_checkbox(
92-
"Enable debugging output <br><small>Write Docker commands and output to stderr. Not recommended for long-running jobs.</small>.",
92+
"Enable debugging output <br><small>Write Docker commands and output to stderr. Not recommended for long-running jobs.</small>",
9393
'wrapper_verbose'
9494
);
9595
form_submit('OK');

0 commit comments

Comments
 (0)