From: Michael Tremer Date: Fri, 5 Jun 2026 14:39:08 +0000 (+0000) Subject: graphs: Catch ENOENT when sources don't exist X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc847356d33c8c3402cfd1f97d632ac3a0158d49;p=telemetry.git graphs: Catch ENOENT when sources don't exist This catches another case where a source is not active and has never created an RRD file. Signed-off-by: Michael Tremer --- diff --git a/src/daemon/graph.c b/src/daemon/graph.c index 1f8720e..fb9470d 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -485,8 +485,17 @@ int td_graph_render(td_graph* self, const char* object, // Call the implementation to add some arguments r = self->impl->render(self->ctx, self, options, args, object); - if (r < 0) - goto ERROR; + if (r < 0) { + switch (-r) { + // Fall through if we could not find any of the sources, we will + // then create an empty graph instead. + case ENOENT: + break; + + default: + goto ERROR; + } + } // We cannot render the graph if there are no sources if (!td_args_has_sources(args)) { diff --git a/src/daemon/source.c b/src/daemon/source.c index 62b177f..3565120 100644 --- a/src/daemon/source.c +++ b/src/daemon/source.c @@ -1206,6 +1206,16 @@ int td_source_render(td_source* self, td_args* args, const char* object) { if (r < 0) return r; + // Commit any buffered data right now + r = td_daemon_flush_source(self->daemon, self, object); + if (r < 0) + return r; + + // Fail if the path does not exist + r = access(path, R_OK); + if (r < 0) + return -errno; + // Add all data sources for (const td_rrd_ds* ds = self->impl->rrd_dss; ds->field; ds++) { r = td_source_render_add_DEF(self, args, path, ds, object); @@ -1213,6 +1223,5 @@ int td_source_render(td_source* self, td_args* args, const char* object) { return r; } - // Commit any buffered data right now - return td_daemon_flush_source(self->daemon, self, object); + return 0; }