forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.go
61 lines (55 loc) · 2.54 KB
/
services.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package aggregated_logging
import (
"fmt"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
)
var loggingServices = sets.NewString("logging-es", "logging-es-cluster", "logging-es-ops", "logging-es-ops-cluster", "logging-kibana", "logging-kibana-ops")
const serviceNotFound = `
Expected to find '%s' among the logging services for the project but did not.
`
const serviceOpsNotFound = `
Expected to find '%s' among the logging services for the project but did not. This
may not matter if you chose not to install a separate logging stack to support operations.
`
// checkServices looks to see if the aggregated logging services exist
func checkServices(r diagnosticReporter, adapter servicesAdapter, project string) {
r.Debug("AGL0200", fmt.Sprintf("Checking for services in project '%s' with selector '%s'", project, loggingSelector.AsSelector()))
serviceList, err := adapter.services(project, metav1.ListOptions{LabelSelector: loggingSelector.AsSelector().String()})
if err != nil {
r.Error("AGL0205", err, fmt.Sprintf("There was an error while trying to retrieve the logging services: %s", err))
return
}
foundServices := sets.NewString()
for _, service := range serviceList.Items {
foundServices.Insert(service.ObjectMeta.Name)
r.Debug("AGL0210", fmt.Sprintf("Retrieved service '%s'", service.ObjectMeta.Name))
}
for _, service := range loggingServices.List() {
if foundServices.Has(service) {
checkServiceEndpoints(r, adapter, project, service)
} else {
if strings.Contains(service, "-ops") {
r.Warn("AGL0215", nil, fmt.Sprintf(serviceOpsNotFound, service))
} else {
r.Error("AGL0217", nil, fmt.Sprintf(serviceNotFound, service))
}
}
}
}
// checkServiceEndpoints validates if there is an available endpoint for the service.
func checkServiceEndpoints(r diagnosticReporter, adapter servicesAdapter, project string, service string) {
endpoints, err := adapter.endpointsForService(project, service)
if err != nil {
r.Warn("AGL0220", err, fmt.Sprintf("Unable to retrieve endpoints for service '%s': %s", service, err))
return
}
if len(endpoints.Subsets) == 0 {
if strings.Contains(service, "-ops") {
r.Info("AGL0223", fmt.Sprintf("There are no endpoints found for service '%s'. This could mean you choose not to install a separate operations cluster during installation.", service))
} else {
r.Warn("AGL0225", nil, fmt.Sprintf("There are no endpoints found for service '%s'. This means there are no pods serviced by this service and this component is not functioning", service))
}
}
}