Skip to content

Add custom checks stores & storage checks - #5668

Open
rbev wants to merge 8 commits into
masterfrom
rhys/sql-customchecks2
Open

Add custom checks stores & storage checks#5668
rbev wants to merge 8 commits into
masterfrom
rhys/sql-customchecks2

Conversation

@rbev

@rbev rbev commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This pull request adds support for storing custom check data in both PostgreSQL and SQL Server EF Core persistence layers. It introduces new migration files and updates the database model snapshots to include a new CustomChecks table. Additionally, there are minor updates to the .NET SDK version and some code organization improvements.

Database schema changes:

  • Added a new custom_checks table for PostgreSQL and a CustomChecks table for SQL Server, including columns for IDs, category, status, timestamps, failure reasons, and endpoint information. [1] [2]
  • Updated model snapshot files (PostgreSqlServiceControlDbContextModelSnapshot.cs, SqlServerServiceControlDbContextModelSnapshot.cs) to reflect the addition of the CustomCheckEntity and its mapping to the new tables. [1] [2]
  • Added EF Core migration designer file for SQL Server to support the new CustomChecks table.

Build and configuration updates:

  • Updated the .NET SDK version in global.json from 10.0.100 to 10.0.302 and changed the rollForward policy to disable.

Code and dependency improvements:

  • Added missing using CustomChecks; directives to relevant files for clarity and to ensure correct namespace usage. [1] [2]
  • Refactored the persistence configuration to clarify variable usage when creating the SqlServerPersistence instance.

@rbev
rbev marked this pull request as ready for review July 30, 2026 08:03
@johnsimons

Copy link
Copy Markdown
Member

@rbev just wondering if this is doing the same as #5658

@johnsimons

Copy link
Copy Markdown
Member

@rbev I think there is a misunderstanding here.
The reason we have a custom check for disk space for RavenDB Embedded is because we are in total control of the raven instance, we are hosting it ourselves. We do not monitor disk space for external RavenDB servers!
So, in our case both PostgreSQL and SqlServer are external resources so there is no need for us to do that. We assume that the database administrator would do those things or on the cloud the size automatically scales or they have other mechanisms to monitor these.

@rbev
rbev force-pushed the rhys/sql-customchecks2 branch from 4c78340 to f9804f5 Compare July 31, 2026 05:42
Status = c.Status,
ReportedAt = c.ReportedAt,
FailureReason = c.FailureReason
}).ToList(), new QueryStatsInfo("", page.Count, false));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Etag left blank, it will be revisited as part of other work.

@@ -1,5 +1,6 @@
namespace ServiceControl.Persistence.EFCore.SqlServer;

using CustomChecks;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

Comment thread src/ServiceControl.Persistence.EFCore/Entities/CustomCheckEntity.cs
Comment on lines +17 to +19
if (customCheck == null ||
(customCheck.Status == Status.Fail && !detail.HasFailed) ||
(customCheck.Status == Status.Pass && detail.HasFailed))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is confusing!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a direct cut & paste from the raven implementation

customCheck.CustomCheckId = detail.CustomCheckId;
customCheck.Category = detail.Category;
customCheck.Status = detail.HasFailed ? Status.Fail : Status.Pass;
customCheck.ReportedAt = detail.ReportedAt;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be updated everytime it changes or should it be the first time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raven updates everything every time, but actually it should use the upsert utility that exists now

Comment on lines +79 to +84
var customCheck = await context.CustomChecks.FindAsync(id);
if (customCheck != null)
{
context.CustomChecks.Remove(customCheck);
await context.SaveChangesAsync();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this in one query using the ExecuteDeleteAsync

Comment thread global.json
"version": "10.0.302",
"allowPrerelease": false,
"rollForward": "latestFeature"
"rollForward": "disable"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do this without talking to Brandon!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or at least do it in a different PR so we can bring him in for a review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry, had just done it on this branch to test and forgot to revert it

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.

2 participants