Skip to content

Commit a8629cf

Browse files
client: show correct user credit if using Science United
Science United uses a single user account on each project; all SU users share that account. When the client does a scheduler RPC to the project, the reported user credit (average and total) is the total over all SU users. The only way to fix this (that I could think of, and that doesn't involve server code changes) is to get user credit from SU rather than from projects. This involves two parts: - SU's RPC reply now includes, for each project returned, new fields 'user_avg_ec' and 'user_total_ec'. These are the sums, over the user's hosts, of the recent averate total estimated credit (EC) for that project. Note: EC has the same units as credit, but it's based on CPU/GPU time and benchmarks, rather than project-granted credit. - In the BOINC client, if a project is attached via a dynamic AM (that is, via SU) then we get its user credit numbers (avg and total) from AM RPC replies, rather than scheduler RPC replies.
1 parent e83909d commit a8629cf

4 files changed

Lines changed: 27 additions & 4 deletions

File tree

client/acct_mgr.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ 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;
303305

304306
while (!xp.get_tag()) {
305307
if (!xp.is_tag) {
@@ -325,6 +327,8 @@ int AM_ACCOUNT::parse(XML_PARSER& xp) {
325327
if (xp.parse_string("authenticator", authenticator)) continue;
326328
if (xp.parse_bool("detach", detach)) continue;
327329
if (xp.parse_bool("update", update)) continue;
330+
if (xp.parse_double("user_avg_ec", user_avg_ec)) continue;
331+
if (xp.parse_double("user_total_ec", user_total_ec)) continue;
328332
if (xp.parse_bool("no_cpu", btemp)) {
329333
handle_no_rsc("CPU", btemp);
330334
continue;
@@ -652,6 +656,10 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
652656
for (const AM_ACCOUNT& acct: accounts) {
653657
pp = gstate.lookup_project(acct.url.c_str());
654658
if (pp) {
659+
if (gstate.acct_mgr_info.dynamic) {
660+
pp->user_expavg_credit = acct.user_avg_ec;
661+
pp->user_total_credit = acct.user_total_ec;
662+
}
655663
if (acct.detach) {
656664
if (pp->attached_via_acct_mgr) {
657665
gstate.detach_project(pp);
@@ -781,6 +789,10 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
781789
if (acct.suspend.present && acct.suspend.value) {
782790
pp->suspend();
783791
}
792+
if (gstate.acct_mgr_info.dynamic) {
793+
pp->user_expavg_credit = acct.user_avg_ec;
794+
pp->user_total_credit = acct.user_total_ec;
795+
}
784796
} else {
785797
msg_printf(NULL, MSG_INTERNAL_ERROR,
786798
"Failed to add project: %s",

client/acct_mgr.h

Lines changed: 7 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,8 @@ 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;
159164

160165
void handle_no_rsc(const char*, bool);
161166
int parse(XML_PARSER&);

client/project.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ struct PROJECT : PROJ_AM {
200200
// Used for a clean exit to a project,
201201
// or if a user wants to pause doing work for the project
202202
bool attached_via_acct_mgr;
203+
// if set, don't let user remove project directly
203204
bool detach_when_done;
204205
// when no results for this project, detach it.
205206
// if using AM, do AM RPC before detaching

client/scheduler_op.cpp

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

617+
// if project is attached via a dynamic AM (like Science United)
618+
// we get user credit from the AM, not the project
619+
//
620+
bool ignore_host_credit = project->attached_via_acct_mgr && gstate.acct_mgr_info.dynamic;
621+
617622
// First line should either be tag (HTTP 1.0) or
618623
// hex length of response (HTTP 1.1)
619624
//
@@ -668,8 +673,8 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
668673
}
669674
else if (xp.parse_str("symstore", project->symstore, sizeof(project->symstore))) continue;
670675
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;
676+
else if (!ignore_host_credit && xp.parse_double("user_total_credit", project->user_total_credit)) continue;
677+
else if (!ignore_host_credit && xp.parse_double("user_expavg_credit", project->user_expavg_credit)) continue;
673678
else if (xp.parse_double("user_create_time", project->user_create_time)) continue;
674679
else if (xp.parse_double("cpid_time", cpid_time)) continue;
675680
else if (xp.parse_str("team_name", project->team_name, sizeof(project->team_name))) continue;

0 commit comments

Comments
 (0)