Skip to content

Handle nullable 'Log' field and refresh 'last_comm' in dbFetchNodes#137

Merged
cgalibern merged 2 commits into
opensvc:mainfrom
cgalibern:dev
Apr 30, 2026
Merged

Handle nullable 'Log' field and refresh 'last_comm' in dbFetchNodes#137
cgalibern merged 2 commits into
opensvc:mainfrom
cgalibern:dev

Conversation

@cgalibern
Copy link
Copy Markdown
Contributor

Summary

This pull request addresses two issues:

  1. Nullable Log Field Handling:

    • Modified the resource monitoring query logic to handle scenarios where the Log field is nullable (sql.NullString).
    • Resolved a query scan error caused by attempting to convert a NULL value to a string for the Log field.
  2. Update last_comm in dbFetchNodes:

    • Implemented the NodeUpdateLastComm method for efficient batch updates of the last_comm field.
    • Integrated this update into the daemon ping and status logic to ensure affected nodes have their last_comm fields updated during dbFetchNodes.

…FetchNodes

- Introduced `NodeUpdateLastComm` method in `cdb` for efficient batch updates.
- Added into daemon ping and status `dbFetchNodes` the logic to update `last_comm` field for affected nodes via `NodeUpdateLastComm`.
- Updated `rows.Scan` to account for `Log` being nullable by using `sql.NullString`.
- Ensured `Log` is assigned correctly if the value is valid.

This fixes following error:
    dbFindInstances ResmonLogLastFromObjectIDs: query scan rows: sql: Scan error on column index 4, name \"res_log\": converting NULL to string is unsupported
@cgalibern cgalibern merged commit 2f93032 into opensvc:main Apr 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant