Skip to content

feat: add database support for dismissed healthchecks #10845

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

Merged
merged 9 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
db: dismissed healthchecks
  • Loading branch information
mtojek committed Nov 23, 2023
commit 78e6c4d7bff51a61053ed9f8bf4ed2e59eb58ecc
8 changes: 8 additions & 0 deletions coderd/database/dbauthz/dbauthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,10 @@ func (q *querier) GetDeploymentWorkspaceStats(ctx context.Context) (database.Get
return q.db.GetDeploymentWorkspaceStats(ctx)
}

func (q *querier) GetDismissedHealthchecks(ctx context.Context) (string, error) {
panic("not implemented")
}

func (q *querier) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) {
return fetch(q.log, q.auth, q.db.GetExternalAuthLink)(ctx, arg)
}
Expand Down Expand Up @@ -2958,6 +2962,10 @@ func (q *querier) UpsertDefaultProxy(ctx context.Context, arg database.UpsertDef
return q.db.UpsertDefaultProxy(ctx, arg)
}

func (q *querier) UpsertDismissedHealthchecks(ctx context.Context, value string) error {
panic("not implemented")
}

func (q *querier) UpsertLastUpdateCheck(ctx context.Context, value string) error {
if err := q.authorizeContext(ctx, rbac.ActionUpdate, rbac.ResourceSystem); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,10 @@ func (q *FakeQuerier) GetDeploymentWorkspaceStats(ctx context.Context) (database
return stat, nil
}

func (q *FakeQuerier) GetDismissedHealthchecks(ctx context.Context) (string, error) {
panic("not implemented")
}

func (q *FakeQuerier) GetExternalAuthLink(_ context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) {
if err := validateDatabaseType(arg); err != nil {
return database.ExternalAuthLink{}, err
Expand Down Expand Up @@ -6790,6 +6794,10 @@ func (q *FakeQuerier) UpsertDefaultProxy(_ context.Context, arg database.UpsertD
return nil
}

func (q *FakeQuerier) UpsertDismissedHealthchecks(ctx context.Context, value string) error {
panic("not implemented")
}

func (q *FakeQuerier) UpsertLastUpdateCheck(_ context.Context, data string) error {
q.mutex.Lock()
defer q.mutex.Unlock()
Expand Down
14 changes: 14 additions & 0 deletions coderd/database/dbmetrics/dbmetrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions coderd/database/dbmock/dbmock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions coderd/database/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions coderd/database/queries/siteconfig.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ SELECT value FROM site_configs WHERE key = 'oauth_signing_key';
-- name: UpsertOAuthSigningKey :exec
INSERT INTO site_configs (key, value) VALUES ('oauth_signing_key', $1)
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'oauth_signing_key';

-- name: GetDismissedHealthchecks :one
SELECT value FROM site_configs WHERE key = 'dismissed_healthchecks';
Copy link
Member

Choose a reason for hiding this comment

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

Should we coalesce this to []?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it. There is one drawback of this approach: with [] we will close the structure for extra properties since it will accept only array items. I'm happy to change it to [] if you think that it is fair.

Copy link
Member

Choose a reason for hiding this comment

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

I mean, we could also coalesce it to {} and then start off with {"dismissed": [...]} if you want to keep it open. My main point here was to avoid downstream consumers having to deal with a potential nil.

Copy link
Member Author

@mtojek mtojek Nov 23, 2023

Choose a reason for hiding this comment

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

Yes, this will be open. Should I rename it to health_settings instead? (or healthpage_settings, healthcheck_settings)

Copy link
Member

Choose a reason for hiding this comment

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

👍 Sounds good, I could imagine other persistent health-related site configs going in there.

Copy link
Member Author

@mtojek mtojek Nov 23, 2023

Choose a reason for hiding this comment

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

Alright, converted it into health_settings with default value {}. The API implementation will be similar to the ServiceBanner


-- name: UpsertDismissedHealthchecks :exec
INSERT INTO site_configs (key, value) VALUES ('dismissed_healthchecks', $1)
ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'dismissed_healthchecks';