mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
Merge pull request #8469 from satnam6502/heapster
Add explicit version to name of monitoring RCs
This commit is contained in:
@@ -63,10 +63,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
expectedRcs = map[string]bool{
|
||||
"monitoring-heapster-controller": false,
|
||||
"monitoring-influx-grafana-controller": false,
|
||||
}
|
||||
rcLabels = []string{"heapster", "influxGrafana"}
|
||||
expectedServices = map[string]bool{
|
||||
influxdbService: false,
|
||||
"monitoring-grafana": false,
|
||||
@@ -74,17 +71,25 @@ var (
|
||||
)
|
||||
|
||||
func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error) {
|
||||
rcList, err := c.ReplicationControllers(api.NamespaceDefault).List(labels.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expectedPods := []string{}
|
||||
for _, rc := range rcList.Items {
|
||||
if _, ok := expectedRcs[rc.Name]; ok {
|
||||
if rc.Status.Replicas != 1 {
|
||||
return nil, fmt.Errorf("expected to find only one replica for rc %q, found %d", rc.Name, rc.Status.Replicas)
|
||||
}
|
||||
expectedRcs[rc.Name] = true
|
||||
// Iterate over the labels that identify the replication controllers that we
|
||||
// want to check. The rcLabels contains the value values for the k8s-app key
|
||||
// that identify the replication controllers that we want to check. Using a label
|
||||
// rather than an explicit name is preferred because the names will typically have
|
||||
// a version suffix e.g. heapster-monitoring-v1 and this will change after a rolling
|
||||
// update e.g. to heapster-monitoring-v2. By using a label query we can check for the
|
||||
// situaiton when a heapster-monitoring-v1 and heapster-monitoring-v2 replication controller
|
||||
// is running (which would be an error except during a rolling update).
|
||||
for _, rcLabel := range rcLabels {
|
||||
rcList, err := c.ReplicationControllers(api.NamespaceDefault).List(labels.Set{"k8s-app": rcLabel}.AsSelector())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(rcList.Items) != 1 {
|
||||
return nil, fmt.Errorf("expected to find one replicat for RC with label %s but got %d",
|
||||
rcLabel, len(rcList.Items))
|
||||
}
|
||||
for _, rc := range rcList.Items {
|
||||
podList, err := c.Pods(api.NamespaceDefault).List(labels.Set(rc.Spec.Selector).AsSelector(), fields.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -94,11 +99,6 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
|
||||
}
|
||||
}
|
||||
}
|
||||
for rc, found := range expectedRcs {
|
||||
if !found {
|
||||
return nil, fmt.Errorf("Replication Controller %q not found.", rc)
|
||||
}
|
||||
}
|
||||
return expectedPods, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user