Documentation ¶
Overview ¶
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func DiscoverControllerNamespaces(ctx context.Context, kubernetes kubernetes.Interface) []string
- type ClusterDiagnostic
- type Diagnosable
- type DiagnosableFunc
- type Diagnostic
- func (d *Diagnostic) Error(args ...interface{})
- func (d *Diagnostic) Errorf(format string, args ...interface{})
- func (d *Diagnostic) Fail()
- func (d *Diagnostic) FailNow()
- func (d *Diagnostic) Failed() bool
- func (d *Diagnostic) Fatal(args ...interface{})
- func (d *Diagnostic) Fatalf(format string, args ...interface{})
- func (d *Diagnostic) GatedRun(ctx context.Context, name string, f func(ctx context.Context, d *Diagnostic))
- func (d *Diagnostic) Helper()
- func (d *Diagnostic) Log(args ...interface{})
- func (d *Diagnostic) Logf(format string, args ...interface{})
- func (d *Diagnostic) Name() string
- func (d *Diagnostic) Report()
- func (d *Diagnostic) Run(ctx context.Context, name string, f func(ctx context.Context, d *Diagnostic))
- func (d *Diagnostic) Warn(args ...interface{})
- func (d *Diagnostic) Warnf(format string, args ...interface{})
- type IstioDiagnostic
- type OperatorDiagnostic
Examples ¶
Constants ¶
const ( // IstioSidecarWebhookName contains the name of Istio's mutating admission // webhook that injects sidecars. IstioSidecarWebhookName = "sidecar-injector.istio.io" // IstioNamespaceSidecarWebhookNameSuffix contains the common name suffix of // Istio's mutating admission webhook that injects sidecars for namespaces. IstioNamespaceSidecarWebhookNameSuffix = "namespace.sidecar-injector.istio.io" // IstioMutatingWebhookConfigurationPrefix is the prefix of Istio MutatingWebhookConfigurations IstioMutatingWebhookConfigurationPrefix = "istio-sidecar-injector" )
Variables ¶
This section is empty.
Functions ¶
func DiscoverControllerNamespaces ¶
func DiscoverControllerNamespaces(ctx context.Context, kubernetes kubernetes.Interface) []string
DiscoverControllerNamespaces attempts to discover controller namespaces by reading webhooks. The results are best-effort, ignoring errors.
Types ¶
type ClusterDiagnostic ¶
type ClusterDiagnostic struct {
// contains filtered or unexported fields
}
ClusterDiagnostic tests that the cluster's Kubernetes version and components are suitable for kf.
func NewClusterDiagnostic ¶
func NewClusterDiagnostic(kubeClient kubernetes.Interface) *ClusterDiagnostic
NewClusterDiagnostic creates a new ClusterDiagnostic to validate the install pointed at by the client.
func (*ClusterDiagnostic) Diagnose ¶
func (c *ClusterDiagnostic) Diagnose(ctx context.Context, d *Diagnostic)
Diagnose validates the version and components of the current Kubernetes cluster.
type Diagnosable ¶
type Diagnosable interface {
Diagnose(ctx context.Context, d *Diagnostic)
}
Diagnosable provides a high-level way to indicate a resource can be diagnosed.
type DiagnosableFunc ¶
type DiagnosableFunc func(ctx context.Context, d *Diagnostic)
DiagnosableFunc adapts a function to a Diagnosable.
func (DiagnosableFunc) Diagnose ¶
func (df DiagnosableFunc) Diagnose(ctx context.Context, d *Diagnostic)
Diagnose implements Diagnosable.Diagnose.
type Diagnostic ¶
type Diagnostic struct {
// contains filtered or unexported fields
}
Diagnostic is a basic test structure that runs and reports on nested tests. It's modeled after the testing package.
func NewDefaultDiagnostic ¶
func NewDefaultDiagnostic() *Diagnostic
NewDefaultDiagnostic creates a diagnostic with the root name of "doctor" that reports to stdout.
func NewDiagnostic ¶
func NewDiagnostic(name string, w io.Writer) *Diagnostic
NewDiagnostic creates a new diagnostic with the given name that reports to the given writer.
func (*Diagnostic) Error ¶
func (d *Diagnostic) Error(args ...interface{})
Error is equivalent to Log followed by Fail.
func (*Diagnostic) Errorf ¶
func (d *Diagnostic) Errorf(format string, args ...interface{})
Errorf is equivalent to Logf followed by Fail.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "example", func(ctx context.Context, d *Diagnostic) { d.Errorf("%d", 42) d.Log("after") })
Output: === RUN doctor/example === LOG doctor/example 42 after --- FAIL: doctor/example
func (*Diagnostic) FailNow ¶
func (d *Diagnostic) FailNow()
FailNow marks the function as having failed and stops its execution by calling runtime.Goexit (which then runs all deferred calls in the current goroutine). Execution will continue at the parent diagnostic. If FailNow is called on the root Diagnostic, the goroutine is not exited.
func (*Diagnostic) Failed ¶
func (d *Diagnostic) Failed() bool
Failed reports whether the function has failed.
func (*Diagnostic) Fatal ¶
func (d *Diagnostic) Fatal(args ...interface{})
Fatal is equivalent to Log followed by FailNow.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "example", func(ctx context.Context, d *Diagnostic) { d.Log("before") d.Fatal("immediate exit") d.Log("after") })
Output: === RUN doctor/example === LOG doctor/example before immediate exit --- FAIL: doctor/example
func (*Diagnostic) Fatalf ¶
func (d *Diagnostic) Fatalf(format string, args ...interface{})
Fatalf is equivalent to Logf followed by FailNow.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "example", func(ctx context.Context, d *Diagnostic) { d.Fatalf("%d", 42) d.Log("after") })
Output: === RUN doctor/example === LOG doctor/example 42 --- FAIL: doctor/example
func (*Diagnostic) GatedRun ¶
func (d *Diagnostic) GatedRun(ctx context.Context, name string, f func(ctx context.Context, d *Diagnostic))
GatedRun only executes the test function if all prior tests succeeded. This is useful as a way to structure top-level tests into groups with a logical dependence.
Example ¶
d := NewDefaultDiagnostic() d.GatedRun(context.Background(), "validate-db-creds", func(ctx context.Context, d *Diagnostic) { d.Error("bad creds") }) d.GatedRun(context.Background(), "validate-db-version", func(ctx context.Context, d *Diagnostic) { // never reached because the previous run failed })
Output: === RUN doctor/validate-db-creds === LOG doctor/validate-db-creds bad creds --- FAIL: doctor/validate-db-creds
func (*Diagnostic) Helper ¶
func (d *Diagnostic) Helper()
Helper is a no-op function to replicate the interface of testing
func (*Diagnostic) Log ¶
func (d *Diagnostic) Log(args ...interface{})
Log formats its arguments using default formatting, analogous to Println, and records the text in the error log.
func (*Diagnostic) Logf ¶
func (d *Diagnostic) Logf(format string, args ...interface{})
Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "example", func(ctx context.Context, d *Diagnostic) { d.Logf("only printed on failure %d", 42) })
Output: === RUN doctor/example --- PASS: doctor/example
func (*Diagnostic) Name ¶
func (d *Diagnostic) Name() string
Name returns the name of the Diagnostic.
func (*Diagnostic) Report ¶
func (d *Diagnostic) Report()
Report creates a detailed testing style report for the execution.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "good", func(ctx context.Context, d *Diagnostic) { d.Logf("only printed on failure %d", 42) }) d.Run(context.Background(), "bad", func(ctx context.Context, d *Diagnostic) { d.Run(context.Background(), "no-issue", func(ctx context.Context, d *Diagnostic) {}) d.Run(context.Background(), "fails", func(ctx context.Context, d *Diagnostic) { d.Fail() }) }) fmt.Println("Final Report:") d.Report()
Output: === RUN doctor/good --- PASS: doctor/good === RUN doctor/bad === RUN doctor/bad/no-issue === RUN doctor/bad/fails === LOG doctor/bad/fails === LOG doctor/bad --- FAIL: doctor/bad --- PASS: doctor/bad/no-issue --- FAIL: doctor/bad/fails Final Report: --- FAIL: doctor --- PASS: doctor/good --- FAIL: doctor/bad --- PASS: doctor/bad/no-issue --- FAIL: doctor/bad/fails
func (*Diagnostic) Run ¶
func (d *Diagnostic) Run(ctx context.Context, name string, f func(ctx context.Context, d *Diagnostic))
Run creates and executes a sub-test with the given name.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "sub-test-good", func(ctx context.Context, d *Diagnostic) { d.Log("no output") }) d.Run(context.Background(), "sub-test-warn", func(ctx context.Context, d *Diagnostic) { d.Warn("warning output") }) d.Run(context.Background(), "sub-test-bad", func(ctx context.Context, d *Diagnostic) { d.Error("output") })
Output: === RUN doctor/sub-test-good --- PASS: doctor/sub-test-good === RUN doctor/sub-test-warn === LOG doctor/sub-test-warn warning output --- WARN: doctor/sub-test-warn === RUN doctor/sub-test-bad === LOG doctor/sub-test-bad output --- FAIL: doctor/sub-test-bad
func (*Diagnostic) Warn ¶
func (d *Diagnostic) Warn(args ...interface{})
Warn logs the result then sets the status to be warn at minimum.
func (*Diagnostic) Warnf ¶
func (d *Diagnostic) Warnf(format string, args ...interface{})
Warnf logs the formatted result then sets the status to be warn at minimum.
Example ¶
d := NewDefaultDiagnostic() d.Run(context.Background(), "example", func(ctx context.Context, d *Diagnostic) { d.Warnf("%d", 42) d.Log("after") })
Output: === RUN doctor/example === LOG doctor/example 42 after --- WARN: doctor/example
type IstioDiagnostic ¶
type IstioDiagnostic struct {
// contains filtered or unexported fields
}
IstioDiagnostic runs tests against Istio.
func NewIstioDiagnostic ¶
func NewIstioDiagnostic(kubeClient kubernetes.Interface) *IstioDiagnostic
NewIstioDiagnostic creates a new IstioDiagnostic to validate the Istio install pointed at by the client.
func (*IstioDiagnostic) Diagnose ¶
func (u *IstioDiagnostic) Diagnose(ctx context.Context, d *Diagnostic)
Diagnose validates the installed Istio configuration.
type OperatorDiagnostic ¶
type OperatorDiagnostic struct {
// contains filtered or unexported fields
}
OperatorDiagnostic tests whether the Operator is properly installaed.
func NewOperatorDiagnostic ¶
func NewOperatorDiagnostic( kubeClient kubernetes.Interface, ) *OperatorDiagnostic
NewOperatorDiagnostic creates a new OperatorDiagnostic to validate the Operator.
func (*OperatorDiagnostic) Diagnose ¶
func (o *OperatorDiagnostic) Diagnose(ctx context.Context, d *Diagnostic)
Diagnose validates the operator components are properly installead.
Directories ¶
Path | Synopsis |
---|---|
Package troubleshooter holds logic for debugging individual Kubernetes objects.
|
Package troubleshooter holds logic for debugging individual Kubernetes objects. |