Skip to content

Commit

Permalink
Report the lowest running version in the status of each resource (#3489)
Browse files Browse the repository at this point in the history
* Report the lowest running version in the status of each resource

Report the currently running version in the `status.version` field of
each resource. In case a version upgrade is in progress for that
resource, report the lowest running version.

For Elasticsearch, we check both the Pods and the StatefulSets to report
the lowest version. A StatefulSet might report a higher version whereas
the Pods haven't been upgraded yet. It may also report a lower version
and no Pods are running any more with that version.
For other resources, we just check the Pods.

Parts of the Status is refactored into a common `DeploymentStatus` for
Kibana, ApmServer and EnterpriseSearch. Elasticsearch and Beat have
different requirements which cannot fit this common place.

This is a pre-req for strict stack version upgrade ordering
(#2600).
  • Loading branch information
sebgl authored Jul 22, 2020
1 parent 2940553 commit 2e06a7c
Show file tree
Hide file tree
Showing 50 changed files with 933 additions and 306 deletions.
40 changes: 35 additions & 5 deletions config/crds/all-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,16 @@ spec:
description: ApmServerStatus defines the observed state of ApmServer
properties:
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
elasticsearchAssociationStatus:
description: ElasticsearchAssociationStatus is the status of any auto-linking
to Elasticsearch clusters.
type: string
health:
description: ApmServerHealth expresses the status of the Apm Server
instances.
description: Health of the deployment.
type: string
kibanaAssociationStatus:
description: KibanaAssociationStatus is the status of any auto-linking
Expand All @@ -445,6 +446,11 @@ spec:
description: ExternalService is the name of the service the agents should
connect to.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
versions:
Expand Down Expand Up @@ -665,6 +671,11 @@ spec:
kibanaAssociationStatus:
description: AssociationStatus is the status of an association resource.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1beta1
versions:
Expand Down Expand Up @@ -1718,6 +1729,7 @@ spec:
description: ElasticsearchStatus defines the observed state of Elasticsearch
properties:
availableNodes:
description: AvailableNodes is the number of available instances.
format: int32
type: integer
health:
Expand All @@ -1728,6 +1740,11 @@ spec:
description: ElasticsearchOrchestrationPhase is the phase Elasticsearch
is in from the controller point of view.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
versions:
Expand Down Expand Up @@ -2135,16 +2152,22 @@ spec:
clusters.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
health:
description: EnterpriseSearchHealth expresses the health of the Enterprise
Search instances.
description: Health of the deployment.
type: string
service:
description: ExternalService is the name of the service associated to
the Enterprise Search Pods.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1beta1
versions:
Expand Down Expand Up @@ -2570,10 +2593,17 @@ spec:
description: AssociationStatus is the status of an association resource.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
health:
description: KibanaHealth expresses the status of the Kibana instances.
description: Health of the deployment.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
Expand Down
10 changes: 8 additions & 2 deletions config/crds/bases/apm.k8s.elastic.co_apmservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6319,15 +6319,16 @@ spec:
description: ApmServerStatus defines the observed state of ApmServer
properties:
availableNodes:
description: AvailableNodes is the number of available replicas in
the deployment.
format: int32
type: integer
elasticsearchAssociationStatus:
description: ElasticsearchAssociationStatus is the status of any auto-linking
to Elasticsearch clusters.
type: string
health:
description: ApmServerHealth expresses the status of the Apm Server
instances.
description: Health of the deployment.
type: string
kibanaAssociationStatus:
description: KibanaAssociationStatus is the status of any auto-linking
Expand All @@ -6341,6 +6342,11 @@ spec:
description: ExternalService is the name of the service the agents
should connect to.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
type: object
served: true
Expand Down
5 changes: 5 additions & 0 deletions config/crds/bases/beat.k8s.elastic.co_beats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12227,6 +12227,11 @@ spec:
kibanaAssociationStatus:
description: AssociationStatus is the status of an association resource.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
type: object
version: v1beta1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7365,6 +7365,7 @@ spec:
description: ElasticsearchStatus defines the observed state of Elasticsearch
properties:
availableNodes:
description: AvailableNodes is the number of available instances.
format: int32
type: integer
health:
Expand All @@ -7375,6 +7376,11 @@ spec:
description: ElasticsearchOrchestrationPhase is the phase Elasticsearch
is in from the controller point of view.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6149,16 +6149,22 @@ spec:
clusters.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
health:
description: EnterpriseSearchHealth expresses the health of the Enterprise
Search instances.
description: Health of the deployment.
type: string
service:
description: ExternalService is the name of the service associated to
the Enterprise Search Pods.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
type: object
version: v1beta1
Expand Down
9 changes: 8 additions & 1 deletion config/crds/bases/kibana.k8s.elastic.co_kibanas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6305,10 +6305,17 @@ spec:
description: AssociationStatus is the status of an association resource.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in
the deployment.
format: int32
type: integer
health:
description: KibanaHealth expresses the status of the Kibana instances.
description: Health of the deployment.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
type: object
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/api-docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ ConfigSource references configuration settings.
|===




[id="{anchor_prefix}-github-com-elastic-cloud-on-k8s-pkg-apis-common-v1-httpconfig"]
=== HTTPConfig

Expand Down
40 changes: 35 additions & 5 deletions hack/manifest-gen/assets/charts/eck/crds/all-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,16 @@ spec:
description: ApmServerStatus defines the observed state of ApmServer
properties:
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
elasticsearchAssociationStatus:
description: ElasticsearchAssociationStatus is the status of any auto-linking
to Elasticsearch clusters.
type: string
health:
description: ApmServerHealth expresses the status of the Apm Server
instances.
description: Health of the deployment.
type: string
kibanaAssociationStatus:
description: KibanaAssociationStatus is the status of any auto-linking
Expand All @@ -445,6 +446,11 @@ spec:
description: ExternalService is the name of the service the agents should
connect to.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
versions:
Expand Down Expand Up @@ -665,6 +671,11 @@ spec:
kibanaAssociationStatus:
description: AssociationStatus is the status of an association resource.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1beta1
versions:
Expand Down Expand Up @@ -1718,6 +1729,7 @@ spec:
description: ElasticsearchStatus defines the observed state of Elasticsearch
properties:
availableNodes:
description: AvailableNodes is the number of available instances.
format: int32
type: integer
health:
Expand All @@ -1728,6 +1740,11 @@ spec:
description: ElasticsearchOrchestrationPhase is the phase Elasticsearch
is in from the controller point of view.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
versions:
Expand Down Expand Up @@ -2135,16 +2152,22 @@ spec:
clusters.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
health:
description: EnterpriseSearchHealth expresses the health of the Enterprise
Search instances.
description: Health of the deployment.
type: string
service:
description: ExternalService is the name of the service associated to
the Enterprise Search Pods.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1beta1
versions:
Expand Down Expand Up @@ -2570,10 +2593,17 @@ spec:
description: AssociationStatus is the status of an association resource.
type: string
availableNodes:
description: AvailableNodes is the number of available replicas in the
deployment.
format: int32
type: integer
health:
description: KibanaHealth expresses the status of the Kibana instances.
description: Health of the deployment.
type: string
version:
description: 'Version of the stack resource currently running. During
version upgrades, multiple versions may run in parallel: this value
specifies the lowest version currently running.'
type: string
type: object
version: v1
Expand Down
18 changes: 1 addition & 17 deletions pkg/apis/apm/v1/apmserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,9 @@ type ApmServerSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

// ApmServerHealth expresses the status of the Apm Server instances.
type ApmServerHealth string

const (
// ApmServerRed means no instance is currently available.
ApmServerRed ApmServerHealth = "red"
// ApmServerGreen means at least one instance is available.
ApmServerGreen ApmServerHealth = "green"
)

// ApmServerStatus defines the observed state of ApmServer
type ApmServerStatus struct {
commonv1.ReconcilerStatus `json:",inline"`
Health ApmServerHealth `json:"health,omitempty"`
commonv1.DeploymentStatus `json:",inline"`
// ExternalService is the name of the service the agents should connect to.
ExternalService string `json:"service,omitempty"`
// SecretTokenSecretName is the name of the Secret that contains the secret token
Expand All @@ -76,11 +65,6 @@ type ApmServerStatus struct {
KibanaAssociationStatus commonv1.AssociationStatus `json:"kibanaAssociationStatus,omitempty"`
}

// IsDegraded returns true if the current status is worse than the previous.
func (as ApmServerStatus) IsDegraded(prev ApmServerStatus) bool {
return prev.Health == ApmServerGreen && as.Health != ApmServerGreen
}

// +kubebuilder:object:root=true

// ApmServer represents an APM Server resource in a Kubernetes cluster.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/apm/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pkg/apis/beat/v1beta1/beat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ type DeploymentSpec struct {

// BeatStatus defines the observed state of a Beat.
type BeatStatus struct {
// +kubebuilder:validation:Optional
commonv1.ReconcilerStatus `json:",inline"`
// Version of the stack resource currently running. During version upgrades, multiple versions may run
// in parallel: this value specifies the lowest version currently running.
Version string `json:"version,omitempty"`

// +kubebuilder:validation:Optional
ExpectedNodes int32 `json:"expectedNodes,omitempty"`
// +kubebuilder:validation:Optional
AvailableNodes int32 `json:"availableNodes,omitempty"`

// +kubebuilder:validation:Optional
Health BeatHealth `json:"health,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/beat/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e06a7c

Please sign in to comment.