Skip to content

Commit 0516420

Browse files
authored
Merge pull request #6955 from BOINC/dpa_user_credit
Fix credit accounting when using Science United
2 parents f406d10 + 296b561 commit 0516420

4 files changed

Lines changed: 67 additions & 14 deletions

File tree

client/acct_mgr.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,14 @@ int AM_ACCOUNT::parse(XML_PARSER& xp) {
300300
safe_strcpy(url_signature, "");
301301
authenticator.clear();
302302
resource_share.init();
303+
user_avg_ec = 0;
304+
user_total_ec = 0;
305+
cpu_ec = 0;
306+
cpu_time = 0;
307+
gpu_ec = 0;
308+
gpu_time = 0;
309+
njobs_success = 0;
310+
njobs_error = 0;
303311

304312
while (!xp.get_tag()) {
305313
if (!xp.is_tag) {
@@ -325,6 +333,14 @@ int AM_ACCOUNT::parse(XML_PARSER& xp) {
325333
if (xp.parse_string("authenticator", authenticator)) continue;
326334
if (xp.parse_bool("detach", detach)) continue;
327335
if (xp.parse_bool("update", update)) continue;
336+
if (xp.parse_double("user_avg_ec", user_avg_ec)) continue;
337+
if (xp.parse_double("user_total_ec", user_total_ec)) continue;
338+
if (xp.parse_double("cpu_ec", cpu_ec)) continue;
339+
if (xp.parse_double("cpu_time", cpu_time)) continue;
340+
if (xp.parse_double("gpu_ec", gpu_ec)) continue;
341+
if (xp.parse_double("gpu_time", gpu_time)) continue;
342+
if (xp.parse_int("njobs_success", njobs_success)) continue;
343+
if (xp.parse_int("njobs_error", njobs_error)) continue;
328344
if (xp.parse_bool("no_cpu", btemp)) {
329345
handle_no_rsc("CPU", btemp);
330346
continue;
@@ -652,6 +668,10 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
652668
for (const AM_ACCOUNT& acct: accounts) {
653669
pp = gstate.lookup_project(acct.url.c_str());
654670
if (pp) {
671+
if (gstate.acct_mgr_info.dynamic) {
672+
pp->user_expavg_credit = acct.user_avg_ec;
673+
pp->user_total_credit = acct.user_total_ec;
674+
}
655675
if (acct.detach) {
656676
if (pp->attached_via_acct_mgr) {
657677
gstate.detach_project(pp);
@@ -781,6 +801,21 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
781801
if (acct.suspend.present && acct.suspend.value) {
782802
pp->suspend();
783803
}
804+
805+
// The AM supplies initial accounting info
806+
// (in case the client was previously attached,
807+
// then detached).
808+
//
809+
if (gstate.acct_mgr_info.dynamic) {
810+
pp->user_expavg_credit = acct.user_avg_ec;
811+
pp->user_total_credit = acct.user_total_ec;
812+
pp->cpu_ec = acct.cpu_ec;
813+
pp->cpu_time = acct.cpu_time;
814+
pp->gpu_ec = acct.gpu_ec;
815+
pp->gpu_time = acct.gpu_time;
816+
pp->njobs_success = acct.njobs_success;
817+
pp->njobs_error = acct.njobs_error;
818+
}
784819
} else {
785820
msg_printf(NULL, MSG_INTERNAL_ERROR,
786821
"Failed to add project: %s",

client/acct_mgr.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ struct ACCT_MGR_INFO : PROJ_AM {
8181

8282
bool password_error;
8383
bool dynamic;
84-
// This AM dynamically decides what projects to assign.
85-
// - send EC in AM RPCs
84+
// This AM dynamically decides what projects to assign,
85+
// and has a single user per project.
86+
// Like Science United.
87+
// - send EC in AM RPC requests
88+
// - RPC replies will include user_avg_ec, user_total_ec per project
8689
// - send starvation info if idle resources
8790
// - network preferences are those from AM
8891
USER_KEYWORDS user_keywords;
@@ -156,6 +159,16 @@ struct AM_ACCOUNT {
156159
OPTIONAL_DOUBLE resource_share;
157160
OPTIONAL_BOOL suspend;
158161
OPTIONAL_BOOL abort_not_started;
162+
double user_avg_ec;
163+
double user_total_ec;
164+
// the following supplied by dynamic AM if client not already attached
165+
// to the project
166+
double cpu_ec;
167+
double cpu_time;
168+
double gpu_ec;
169+
double gpu_time;
170+
int njobs_success;
171+
int njobs_error;
159172

160173
void handle_no_rsc(const char*, bool);
161174
int parse(XML_PARSER&);

client/project.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,16 @@ struct PROJECT : PROJ_AM {
121121
// and this should go to 1.
122122
// But we need to keep it around for older projects
123123

124-
// accounting info; estimated credit and time for CPU and GPU
124+
// accounting info for use with dynamic account managers;
125+
// obtained from the AM on attach,
126+
// updated by the client, and reported in AM RPCs
125127
//
126-
double cpu_ec;
127-
double cpu_time;
128+
double cpu_ec; // estimated credit
129+
double cpu_time; // device/seconds
128130
double gpu_ec;
129131
double gpu_time;
132+
int njobs_success;
133+
int njobs_error;
130134

131135
// stuff related to scheduler RPCs and master fetch
132136
//
@@ -154,6 +158,7 @@ struct PROJECT : PROJ_AM {
154158
// computed by get_disk_usages()
155159
double disk_share;
156160
// computed by get_disk_shares();
161+
bool dont_use_dcf;
157162

158163
/////// END OF ITEMS STORED IN client_state.xml
159164

@@ -192,14 +197,13 @@ struct PROJECT : PROJ_AM {
192197
// if nonzero, send this project's job log from that point on
193198
bool send_full_workload;
194199

195-
bool dont_use_dcf;
196-
197200
bool suspended_via_gui;
198201
bool dont_request_more_work;
199202
// Return work, but don't request more
200203
// Used for a clean exit to a project,
201204
// or if a user wants to pause doing work for the project
202205
bool attached_via_acct_mgr;
206+
// if set, don't let user remove project directly
203207
bool detach_when_done;
204208
// when no results for this project, detach it.
205209
// if using AM, do AM RPC before detaching
@@ -315,11 +319,6 @@ struct PROJECT : PROJ_AM {
315319
//
316320
APP_CONFIGS app_configs;
317321

318-
// job counting
319-
//
320-
int njobs_success;
321-
int njobs_error;
322-
323322
// total elapsed time of this project's jobs (for export to GUI)
324323
//
325324
double elapsed_time;

client/scheduler_op.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,12 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
614614
}
615615
}
616616

617+
// if project is attached via a dynamic AM (like Science United),
618+
// ignore project-supplied user credit;
619+
// we get it from the AM, not the project
620+
//
621+
bool ignore_user_credit = project->attached_via_acct_mgr && gstate.acct_mgr_info.dynamic;
622+
617623
// First line should either be tag (HTTP 1.0) or
618624
// hex length of response (HTTP 1.1)
619625
//
@@ -668,8 +674,8 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
668674
}
669675
else if (xp.parse_str("symstore", project->symstore, sizeof(project->symstore))) continue;
670676
else if (xp.parse_str("user_name", project->user_name, sizeof(project->user_name))) continue;
671-
else if (xp.parse_double("user_total_credit", project->user_total_credit)) continue;
672-
else if (xp.parse_double("user_expavg_credit", project->user_expavg_credit)) continue;
677+
else if (!ignore_user_credit && xp.parse_double("user_total_credit", project->user_total_credit)) continue;
678+
else if (!ignore_user_credit && xp.parse_double("user_expavg_credit", project->user_expavg_credit)) continue;
673679
else if (xp.parse_double("user_create_time", project->user_create_time)) continue;
674680
else if (xp.parse_double("cpid_time", cpid_time)) continue;
675681
else if (xp.parse_str("team_name", project->team_name, sizeof(project->team_name))) continue;

0 commit comments

Comments
 (0)