Skip to content
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

Adds conditions for clusters that do not have Sourcegraph installed. #951

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
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
48 changes: 48 additions & 0 deletions internal/validate/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ func Pods(ctx context.Context, config *Config) ([]validate.Result, error) {

var results []validate.Result

if len(pods.Items) == 0 {
results = append(results, validate.Result{
Status: validate.Warning,
Message: fmt.Sprintf(
"No pods exist on namespace '%s'. check namespace/cluster",
config.namespace,
),
})

return results, nil
}

for _, pod := range pods.Items {
r := validatePod(&pod)
results = append(results, r...)
Expand Down Expand Up @@ -291,6 +303,18 @@ func Services(ctx context.Context, config *Config) ([]validate.Result, error) {

var results []validate.Result

if len(services.Items) <= 1 {
results = append(results, validate.Result{
Status: validate.Warning,
Message: fmt.Sprintf(
"unexpected number of services on namespace '%s'; check namespace/cluster",
config.namespace,
),
})

return results, nil
}

for _, service := range services.Items {
r := validateService(&service)
results = append(results, r...)
Expand Down Expand Up @@ -326,6 +350,18 @@ func PVCs(ctx context.Context, config *Config) ([]validate.Result, error) {

var results []validate.Result

if len(pvcs.Items) == 0 {
results = append(results, validate.Result{
Status: validate.Warning,
Message: fmt.Sprintf(
"no PVCs exist in namespace '%s'; check namespace/cluster",
config.namespace,
),
})

return results, nil
}

for _, pvc := range pvcs.Items {
r := validatePVC(&pvc)
results = append(results, r...)
Expand Down Expand Up @@ -368,6 +404,18 @@ func Connections(ctx context.Context, config *Config) ([]validate.Result, error)
return nil, err
}

if len(pods.Items) == 0 {
results = append(results, validate.Result{
Status: validate.Warning,
Message: fmt.Sprintf(
"cannot check connections: zero pods exist in namespace '%s'",
config.namespace,
),
})

return results, nil
}

// iterate through pods looking for specific pod name prefixes, then construct
// a relationship map between pods that should have connectivity with each other
for _, pod := range pods.Items {
Expand Down