mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
Merge pull request #94 from brancz/status-pointer
pkg/client/monitoring/v1alpha1: use pointer for status
This commit is contained in:
commit
9001d9e780
3 changed files with 8 additions and 5 deletions
pkg
|
@ -104,11 +104,10 @@ func (api *API) prometheusStatus(w http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
status, _, err := prometheus.PrometheusStatus(api.kclient, p)
|
||||
p.Status, _, err = prometheus.PrometheusStatus(api.kclient, p)
|
||||
if err != nil {
|
||||
api.logger.Log("error", err)
|
||||
}
|
||||
p.Status = *status
|
||||
|
||||
b, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
|
|
|
@ -24,8 +24,8 @@ import (
|
|||
type Prometheus struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
v1.ObjectMeta `json:"metadata,omitempty"`
|
||||
Spec PrometheusSpec `json:"spec"`
|
||||
Status PrometheusStatus `json:"status,omitempty"`
|
||||
Spec PrometheusSpec `json:"spec"`
|
||||
Status *PrometheusStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// PrometheusList is a list of Prometheuses.
|
||||
|
@ -54,6 +54,10 @@ type PrometheusSpec struct {
|
|||
}
|
||||
|
||||
type PrometheusStatus struct {
|
||||
// Represents whether any actions on the underlaying managed objects are
|
||||
// being performed. Only delete actions will be performed.
|
||||
Paused bool `json:"paused"`
|
||||
|
||||
// Total number of non-terminated pods targeted by this Prometheus deployment
|
||||
// (their labels match the selector).
|
||||
Replicas int32 `json:"replicas"`
|
||||
|
|
|
@ -491,7 +491,7 @@ func (c *Operator) syncVersion(key string, p *v1alpha1.Prometheus) error {
|
|||
}
|
||||
|
||||
func PrometheusStatus(kclient *kubernetes.Clientset, p *v1alpha1.Prometheus) (*v1alpha1.PrometheusStatus, []*v1.Pod, error) {
|
||||
res := &v1alpha1.PrometheusStatus{}
|
||||
res := &v1alpha1.PrometheusStatus{Paused: p.Spec.Paused}
|
||||
|
||||
pods, err := kclient.Core().Pods(p.Namespace).List(ListOptions(p.Name))
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue