Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling and logging framework #96

Closed
alexlarsson opened this issue Jan 30, 2023 · 2 comments · Fixed by #112 or #116
Closed

Better error handling and logging framework #96

alexlarsson opened this issue Jan 30, 2023 · 2 comments · Fixed by #112 or #116
Assignees
Labels
jira Issues that are synced to Jira

Comments

@alexlarsson
Copy link
Contributor

Our current handling of errors is rather naive. All we do is print stuff on stderr and return false. Once hirte is in production I think we want something more manageable. For example, we should probably have some minimal helpers for logging issues that have a log level which can be tweaked during testing via the configuration. And, it should probably go to the systemd journal at least when in production (although during testing, being able to get it to stderr is probably nice too).

We also shoud probably pick up the systemd error reporting mechanism of returning -errno style integers instead of just true/false for "success"/"error". That way callers can get at least some more nformation on exactly what failed. In many cases we already call into systemd APIs which can give this info. For example:

bool node_export(Node *node) {
        Manager *manager = node->manager;

        int r = sd_bus_add_object_vtable(
                        manager->user_dbus,
                        &node->export_slot,
                        node->object_path,
                        NODE_INTERFACE,
                        node_vtable,
                        node);
        if (r < 0) {
                fprintf(stderr, "Failed to add node vtable: %s\n", strerror(-r));
                return false;
        }

        return true;
}

This would probably be nicer if it was something like:

int node_export(Node *node) {
        Manager *manager = node->manager;

        int r = sd_bus_add_object_vtable(
                        manager->user_dbus,
                        &node->export_slot,
                        node->object_path,
                        NODE_INTERFACE,
                        node_vtable,
                        node);
        if (r < 0) {
                hirte_log(HIRTE_LOG_WARNING, "Failed to add node vtable: %s\n", strerror(-r));
        }

        return r;
}
@engelmi engelmi self-assigned this Feb 3, 2023
@engelmi engelmi linked a pull request Feb 6, 2023 that will close this issue
@engelmi engelmi reopened this Feb 7, 2023
@engelmi engelmi linked a pull request Feb 8, 2023 that will close this issue
@engelmi
Copy link
Member

engelmi commented Feb 9, 2023

Reopening as the refactoring for the systemd error reporting mechanism is still an open task.

@engelmi engelmi reopened this Feb 9, 2023
@mwperina mwperina added the jira Issues that are synced to Jira label Mar 7, 2023
@engelmi engelmi added the v0.1 label Mar 10, 2023
@engelmi
Copy link
Member

engelmi commented Mar 10, 2023

Logging functionality has been implemented. Split out the refactoring to systemd error reporting mechanism to #191.

@engelmi engelmi closed this as completed Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira Issues that are synced to Jira
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants