Skip to content

Commit

Permalink
daemons/cookd: most of api code
Browse files Browse the repository at this point in the history
  • Loading branch information
Meulengracht committed Nov 6, 2024
1 parent 0614886 commit 7f1f086
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion daemons/cookd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char** argv)
}

// load config
status = cookd_config_load(chef_dirs_root());
status = cookd_config_load(chef_dirs_config());
if (status) {
fprintf(stderr, "cookd: failed to load configuration\n");
return -1;
Expand Down
21 changes: 18 additions & 3 deletions daemons/cookd/server/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,24 @@ void chef_waiterd_cook_event_update_request_invocation(gracht_client_t* client,
struct gracht_message_context msg;
struct cookd_status info;
int status;
VLOG_DEBUG("api", "chef_waiterd_cook_event_update_request_invocation()\n");

cookd_server_status(&info);

status = chef_waiterd_cook_update(client, &msg, &(struct chef_cook_update_event) {
.queue_size = info.queue_size
});
if (status) {

VLOG_ERROR("api", "failed to update the waiterd daemon about current status\n");
}
}

void chef_waiterd_cook_event_build_request_invocation(gracht_client_t* client, const char* id, const struct chef_waiter_build_request* request)
{
int status;
struct gracht_message_context msg;
int status;
enum chef_build_status buildStatus;
VLOG_DEBUG("api", "chef_waiterd_cook_event_build_request_invocation(id=%s)\n", id);

status = cookd_server_queue_build(id, &(struct cookd_build_options) {
.architecture = __architecture(request->arch),
Expand All @@ -65,6 +69,17 @@ void chef_waiterd_cook_event_build_request_invocation(gracht_client_t* client, c
.recipe_path = request->recipe
});
if (status) {

VLOG_ERROR("api", "failed to queue build id %s\n", id);
buildStatus = CHEF_BUILD_STATUS_FAILED;
} else {
buildStatus = CHEF_BUILD_STATUS_QUEUED;
}

status = chef_waiterd_cook_status(client, &msg, &(struct chef_cook_build_event) {
.id = id,
.status = buildStatus
});
if (status) {

}
}

0 comments on commit 7f1f086

Please sign in to comment.