diagnose

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2022 License: MPL-2.0 Imports: 31 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AutoLoadedLicenseValidatorError    = "Autoloaded license could not be validated: "
	AutoloadedLicenseValidationError   = "Autoloaded license validation failed due to error: "
	LicenseAutoloadingError            = "License could not be autoloaded: "
	StoredLicenseNoAutoloadingWarning  = "Vault is using a stored license, which is deprecated! Vault should use autoloaded licenses instead."
	NoStoredOrAutoloadedLicenseWarning = "" /* 149-byte string literal not displayed */
	LicenseExpiredError                = "Autoloaded license is expired."
	LicenseExpiryThresholdWarning      = "Autoloaded license will expire "
	LicenseTerminatedError             = "Autoloaded license is terminated."
	LicenseTerminationThresholdWarning = "Autoloaded license will be terminated "
)
View Source
const (
	FileIsSymlinkWarning          = "raft storage backend file is a symlink"
	FileTooPermissiveWarning      = "too many permissions"
	FilePermissionsMissingWarning = "owner or group needs read and write permissions"
)
View Source
const (
	ErrorStatus   = 2
	WarningStatus = 1
	OkStatus      = 0
	SkippedStatus = -1
)
View Source
const (
	LatencyWarning  string = "Latency above 100 ms: "
	DirAccessErr    string = "Vault storage is directly connected to a Consul server."
	DirAccessAdvice string = "We recommend connecting to a local agent."
	AddrDNExistErr  string = "Storage config address does not exist: 127.0.0.1:8500 will be used."
)
View Source
const DatabaseFilename = "vault.db"

Variables

View Source
var MainSection = trace.WithAttributes(attribute.Key("diagnose").String("main-section"))

Functions

func Advice

func Advice(message string) trace.EventOption

Advice builds an EventOption containing advice message. Use to add to spot results.

func Advise

func Advise(ctx context.Context, message string)

Advise adds advice to the current diagnose span

func CapitalizeFirstLetter

func CapitalizeFirstLetter(msg string) string

CapitalizeFirstLetter returns a string with the first letter capitalized

func CheckFilePerms

func CheckFilePerms(info fs.FileInfo) (bool, []string)

CheckFilePerms checks if the specified file does not have other permissions, and whether the specified file just has owner rw permissions.

func ConsulDirectAccess

func ConsulDirectAccess(config map[string]string) string

ConsulDirectAccess verifies that consul is connecting to local agent, versus directly to a remote server. We can only assume that the local address is a server, not a client.

func Context

func Context(ctx context.Context, sess *Session) context.Context

Context returns a new context with a defined diagnose session

func EndToEndLatencyCheckDelete

func EndToEndLatencyCheckDelete(ctx context.Context, uuid string, b physical.Backend) (time.Duration, error)

func EndToEndLatencyCheckRead

func EndToEndLatencyCheckRead(ctx context.Context, uuid string, b physical.Backend) (time.Duration, error)

func EndToEndLatencyCheckWrite

func EndToEndLatencyCheckWrite(ctx context.Context, uuid string, b physical.Backend) (time.Duration, error)

func Error

func Error(ctx context.Context, err error, options ...trace.EventOption) error

Error records an error in the current span (but unlike Fail, doesn't set the overall span status to Error)

func Fail

func Fail(ctx context.Context, message string)

Fail records a failure in the current span

func HasDB

func HasDB(path string) bool

func IsDir

func IsDir(info fs.FileInfo) bool

func IsOwnedByRoot

func IsOwnedByRoot(info fs.FileInfo) bool

IsOwnedByRoot checks if a file is owned by root

func ListenerChecks

func ListenerChecks(ctx context.Context, listeners []*configutil.Listener) ([]string, []error)

ListenerChecks diagnoses warnings and the first encountered error for the listener configuration stanzas.

func NearExpiration

func NearExpiration(c *x509.Certificate) (bool, time.Duration)

NearExpiration returns a true if a certficate will expire in a month and false otherwise

func OSChecks

func OSChecks(ctx context.Context)

func ParseTLSInformation

func ParseTLSInformation(certFilePath string) ([]*x509.Certificate, []*x509.Certificate, []*x509.Certificate, error)

ParseTLSInformation parses certficate information and returns it from a cert path.

func RaftFileChecks

func RaftFileChecks(ctx context.Context, path string)

func RaftStorageQuorum

func RaftStorageQuorum(ctx context.Context, b RaftConfigurableStorageBackend) string

RaftStorageQuorum checks that there is an odd number of voters present It returns the status message for testing purposes

func Skipped

func Skipped(ctx context.Context, message string)

Skipped marks the current span skipped

func SpotCheck

func SpotCheck(ctx context.Context, checkName string, f func() error) error

func SpotError

func SpotError(ctx context.Context, checkName string, err error, options ...trace.EventOption) error

SpotError adds an Error result without adding a new Span. This should be used for instantaneous checks with no possible sub-spans

func SpotOk

func SpotOk(ctx context.Context, checkName, message string, options ...trace.EventOption)

SpotOk adds an Ok result without adding a new Span. This should be used for instantaneous checks with no possible sub-spans

func SpotSkipped

func SpotSkipped(ctx context.Context, checkName, message string, options ...trace.EventOption)

SpotSkipped adds a Skipped result without adding a new Span.

func SpotWarn

func SpotWarn(ctx context.Context, checkName, message string, options ...trace.EventOption)

SpotWarn adds a Warning result without adding a new Span. This should be used for instantaneous checks with no possible sub-spans

func StartSpan

func StartSpan(ctx context.Context, spanName string, options ...trace.SpanOption) (context.Context, trace.Span)

StartSpan starts a "diagnose" span, which is really just an OpenTelemetry Tracing span.

func Success

func Success(ctx context.Context, message string)

Success sets the span to Successful (overriding any previous status) and sets the message to the input.

func TLSCAFileCheck

func TLSCAFileCheck(CAFilePath string) ([]string, error)

TLSCAFileCheck checks the validity of a TLS CA file

func TLSCertCheck

func TLSCertCheck(certpath string) ([]string, error)

TLSCertCheck returns an error and warning after checking TLS information on the given cert

func TLSClientCAFileCheck

func TLSClientCAFileCheck(l *configutil.Listener) ([]string, error)

TLSClientCAFileCheck Checks the validity of a client CA file

func TLSErrorChecks

func TLSErrorChecks(leafCerts, interCerts, rootCerts []*x509.Certificate) error

TLSErrorChecks contains manual error checks against the TLS configuration

func TLSFileChecks

func TLSFileChecks(certpath, keypath string) ([]string, error)

TLSFileChecks returns an error and warnings after checking TLS information

func TLSFileWarningChecks

func TLSFileWarningChecks(leafCerts, interCerts, rootCerts []*x509.Certificate) ([]string, error)

TLSFileWarningChecks returns warnings based on the leaf certificates, intermediate certificates, and root certificates provided.

func TLSMutualExclusionCertCheck

func TLSMutualExclusionCertCheck(l *configutil.Listener) (int, string)

TLSMutualExclusionCertCheck returns error if both TLSDisableClientCerts and TLSRequireAndVerifyClientCert are set

func Test

func Test(ctx context.Context, spanName string, function testFunction, options ...trace.SpanOption) error

Test creates a new named span, and executes the provided function within it. If the function returns an error, the span is considered to have failed.

func Warn

func Warn(ctx context.Context, msg string)

Warn records a warning on the current span

func WithTimeout

func WithTimeout(d time.Duration, f testFunction) testFunction

WithTimeout wraps a context consuming function, and when called, returns an error if the sub-function does not complete within the timeout, e.g.

diagnose.Test(ctx, "my-span", diagnose.WithTimeout(5 * time.Second, myTestFunc))

Types

type RaftConfigurableStorageBackend

type RaftConfigurableStorageBackend interface {
	GetConfigurationOffline() (*raft.RaftConfigurationResponse, error)
}

Don't have this in test file

type Result

type Result struct {
	Time     time.Time `json:"time"`
	Name     string    `json:"name"`
	Status   status    `json:"status"`
	Warnings []string  `json:"warnings,omitempty"`
	Message  string    `json:"message,omitempty"`
	Advice   string
	Children []*Result `json:"children,omitempty"`
}

func (*Result) String

func (r *Result) String() string

func (*Result) StringWrapped

func (r *Result) StringWrapped(wrapLimit int) string

func (*Result) Write

func (r *Result) Write(writer io.Writer, wrapLimit int) error

Write outputs a human readable version of the results tree

func (*Result) ZeroTimes

func (r *Result) ZeroTimes()

type Session

type Session struct {
	SkipFilters []string
	// contains filtered or unexported fields
}

func CurrentSession

func CurrentSession(ctx context.Context) *Session

CurrentSession retrieves the active diagnose session from the context, or nil if none.

func New

func New(w io.Writer) *Session

New initializes a Diagnose tracing session. In particular this wires a TelemetryCollector, which synchronously receives and tracks OpenTelemetry spans in order to provide a tree structure of results when the outermost span ends.

func (*Session) Finalize

func (s *Session) Finalize(ctx context.Context) *Result

Finalize ends the Diagnose session, returning the root of the result tree. This will be empty until the outermost span ends.

func (*Session) IsSkipped

func (s *Session) IsSkipped(spanName string) bool

IsSkipped returns true if skipName is present in the SkipFilters list. Can be used in combination with Skip to mark a span skipped and conditionally skips some logic.

type TelemetryCollector

type TelemetryCollector struct {
	RootResult *Result
	// contains filtered or unexported fields
}

TelemetryCollector is an otel SpanProcessor that gathers spans and once the outermost span ends, walks the otel traces in order to produce a top-down tree of Diagnose results.

func NewTelemetryCollector

func NewTelemetryCollector(w io.Writer) *TelemetryCollector

NewTelemetryCollector creates a SpanProcessor that collects OpenTelemetry spans and aggregates them into a tree structure for use by Diagnose. It also outputs the status of main sections to that writer.

func (*TelemetryCollector) ForceFlush

func (t *TelemetryCollector) ForceFlush(_ context.Context) error

required to implement SpanProcessor, but noops for our purposes

func (*TelemetryCollector) OnEnd

func (*TelemetryCollector) OnStart

OnStart tracks spans by id for later retrieval

func (*TelemetryCollector) Shutdown

func (t *TelemetryCollector) Shutdown(_ context.Context) error

required to implement SpanProcessor, but noops for our purposes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL