diff options
author | John Cai <jcai@gitlab.com> | 2021-10-22 17:28:42 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2021-10-25 16:06:10 +0300 |
commit | fdecc5f4f36fa5f5bf593e61d59aea3cd1afc17c (patch) | |
tree | b879bc66113310b942efc42bd8a2a9b247025c3c | |
parent | 36833c3c74e68c6ee6d35f9e599d232c8c2dda1d (diff) |
Praefect: add basic framework for adding praefect startup checks
This commit provides a simple framework for praefect cluster checks that
can warn the user if there is a problem with their setup. These checks
will be consumed by a subcommand.
Changelog: added
-rw-r--r-- | internal/praefect/checks.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/praefect/checks.go b/internal/praefect/checks.go new file mode 100644 index 000000000..2da522ad9 --- /dev/null +++ b/internal/praefect/checks.go @@ -0,0 +1,34 @@ +package praefect + +import ( + "fmt" + + migrate "github.com/rubenv/sql-migrate" + "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/config" + "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/datastore/glsql" + "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/datastore/migrations" +) + +// Severity is a type that indicates the severity of a check +type Severity string + +const ( + // Warning indicates a severity level of warning + Warning Severity = "warning" + // Fatal indicates a severity level of fatal + // any checks that are Fatal will prevent Praefect from starting up + Fatal = "fatal" +) + +// Check is a struct representing a check on the health of a Gitaly cluster's setup. These are separate from the "healthcheck" +// concept which is more concerned with the health of the praefect service. These checks are meant to diagnose any issues with +// the praefect cluster setup itself and will be run on startup/restarts. +type Check struct { + Run func() error + Name string + Description string + Severity Severity +} + +// CheckFunc is a function type that takes a praefect config and returns a Check +type CheckFunc func(conf config.Config) *Check |