Skip to content

Commit

Permalink
fixup! job-manager: Add user annotation support
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Jul 24, 2020
1 parent 69004d8 commit 9bd4db0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/modules/job-manager/alloc.c
Expand Up @@ -218,7 +218,8 @@ static void alloc_response_cb (flux_t *h, flux_msg_handler_t *mh,
errno = EEXIST;
goto teardown;
}
annotations_update (h, job, annotations);
if (annotations_update (h, job, annotations) < 0)
flux_log_error (h, "annotations_update: id=%ju", (uintmax_t)id);
if (annotations)
event_batch_pub_annotations (ctx->event, job);
if (job->annotations) {
Expand All @@ -237,7 +238,8 @@ static void alloc_response_cb (flux_t *h, flux_msg_handler_t *mh,
errno = EPROTO;
goto teardown;
}
annotations_update (h, job, annotations);
if (annotations_update (h, job, annotations) < 0)
flux_log_error (h, "annotations_update: id=%ju", (uintmax_t)id);
event_batch_pub_annotations (ctx->event, job);
break;
case FLUX_SCHED_ALLOC_DENY: // error
Expand Down
22 changes: 14 additions & 8 deletions src/modules/job-manager/annotate.c
Expand Up @@ -91,21 +91,22 @@ int update_annotation_recursive (struct job *job, json_t *orig, json_t *new)
return 0;
}

void annotations_update (flux_t *h, struct job *job, json_t *annotations)
int annotations_update (flux_t *h, struct job *job, json_t *annotations)
{
if (annotations) {
if (!job->annotations) {
if (!(job->annotations = json_object ()))
flux_log (h,
LOG_ERR,
"%s: id=%ju json_object",
__FUNCTION__, (uintmax_t)job->id);
if (!(job->annotations = json_object ())) {
errno = ENOMEM;
return -1;
}
}
if (job->annotations) {
if (update_annotation_recursive (job,
job->annotations,
annotations) < 0)
annotations) < 0) {
flux_log_error (h, "update_annotation_recursive");
return -1;
}
/* Special case: if user cleared all entries, assume we no
* longer need annotations object
*
Expand All @@ -117,6 +118,8 @@ void annotations_update (flux_t *h, struct job *job, json_t *annotations)
annotations_clear (job, NULL);
}
}

return 0;
}

void annotate_handle_request (flux_t *h,
Expand Down Expand Up @@ -145,7 +148,10 @@ void annotate_handle_request (flux_t *h,
errstr = "guests can only annotate their own jobs";
goto error;
}
annotations_update (ctx->h, job, annotations);
if (annotations_update (ctx->h, job, annotations) < 0) {
flux_log_error (h, "%s: annotations_update", __FUNCTION__);
goto error;
}
if (event_batch_pub_annotations (ctx->event, job) < 0) {
flux_log_error (h, "%s: event_batch_pub_annotations", __FUNCTION__);
goto error;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/job-manager/annotate.h
Expand Up @@ -17,7 +17,7 @@
#include "job-manager.h"

void annotations_clear (struct job *job, bool *cleared);
void annotations_update (flux_t *h, struct job *job, json_t *annotations);
int annotations_update (flux_t *h, struct job *job, json_t *annotations);

struct annotate *annotate_ctx_create (struct job_manager *ctx);
void annotate_ctx_destroy (struct annotate *annotate);
Expand Down

0 comments on commit 9bd4db0

Please sign in to comment.