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

Refactor Ceilometer services' status objects #561

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 16 additions & 1 deletion api/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ spec:
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
ksmStatus:
description: KSMStatus defines the observed state of kube-state-metrics
description: |-
NOTE(mmagr): remove with API version increment
Deprecated
properties:
conditions:
description: Conditions
Expand Down Expand Up @@ -136,6 +138,10 @@ spec:
type: object
ipmiImage:
type: string
ksmEnabled:
default: true
description: Whether kube-state-metrics should be deployed
type: boolean
ksmImage:
type: string
ksmTls:
Expand Down Expand Up @@ -295,6 +301,15 @@ spec:
type: string
description: Map of hashes to track e.g. job status
type: object
ksmHash:
additionalProperties:
type: string
description: Map of hashes to track e.g. job status
type: object
ksmReadyCount:
description: ReadyCount of kube-state-metrics instances
format: int32
type: integer
mysqldExporterExportedGaleras:
description: List of galera CRs, which are being exported with mysqld_exporter
items:
Expand Down
4 changes: 4 additions & 0 deletions api/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ spec:
type: boolean
ipmiImage:
type: string
ksmEnabled:
default: true
description: Whether kube-state-metrics should be deployed
type: boolean
ksmImage:
type: string
ksmTls:
Expand Down
25 changes: 18 additions & 7 deletions api/v1beta1/ceilometer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ type CeilometerSpecCore struct {
// NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to
NetworkAttachmentDefinitions []string `json:"networkAttachmentDefinitions,omitempty"`

// Whether kube-state-metrics should be deployed
// +kubebuilder:validation:optional
// +kubebuilder:default=true
KSMEnabled *bool `json:"ksmEnabled,omitempty"`

// Whether mysqld_exporter should be deployed
// +kubebuilder:validation:optional
MysqldExporterEnabled *bool `json:"mysqldExporterEnabled,omitempty"`
Expand Down Expand Up @@ -177,9 +182,16 @@ type CeilometerStatus struct {
// List of galera CRs, which are being exported with mysqld_exporter
// +listType=atomic
MysqldExporterExportedGaleras []string `json:"mysqldExporterExportedGaleras,omitempty"`

// ReadyCount of kube-state-metrics instances
KSMReadyCount int32 `json:"ksmReadyCount,omitempty"`

// Map of hashes to track e.g. job status
KSMHash map[string]string `json:"ksmHash,omitempty"`
}

// KSMStatus defines the observed state of kube-state-metrics
// NOTE(mmagr): remove with API version increment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment will show in a description of the ksmStatus. For example when executingoc explain ceilometer. Not sure if that was intentional. An empty line between the 2 comments sholud hide the top line from users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. That is certainly not the intention. Will fix.

// Deprecated
type KSMStatus struct {
// ReadyCount of ksm instances
ReadyCount int32 `json:"readyCount,omitempty"`
Expand Down Expand Up @@ -207,9 +219,9 @@ type Ceilometer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CeilometerSpec `json:"spec,omitempty"`
CeilometerStatus CeilometerStatus `json:"status,omitempty"`
KSMStatus KSMStatus `json:"ksmStatus,omitempty"`
Spec CeilometerSpec `json:"spec,omitempty"`
Status CeilometerStatus `json:"status,omitempty"`
KSMStatus KSMStatus `json:"ksmStatus,omitempty"`
}

//+kubebuilder:object:root=true
Expand All @@ -223,8 +235,7 @@ type CeilometerList struct {

// IsReady - returns true if Ceilometer is reconciled successfully
func (instance Ceilometer) IsReady() bool {
return instance.CeilometerStatus.Conditions.IsTrue(condition.ReadyCondition) &&
instance.KSMStatus.Conditions.IsTrue(condition.ReadyCondition)
return instance.Status.Conditions.IsTrue(condition.ReadyCondition)
}

func init() {
Expand All @@ -233,7 +244,7 @@ func init() {

// RbacConditionsSet - set the conditions for the rbac object
func (instance Ceilometer) RbacConditionsSet(c *condition.Condition) {
instance.CeilometerStatus.Conditions.Set(c)
instance.Status.Conditions.Set(c)
}

// RbacNamespace - return the namespace
Expand Down
26 changes: 13 additions & 13 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,17 @@ const (

DashboardDefinitionReadyCondition condition.Type = "DashboardDefinitionReady"

// KSMReadyCondition Status=True condition which indicates if the KSM is configured and operational
KSMReadyCondition condition.Type = "KSMReady"
// KSMTLSInputReadyCondition Status=True condition when required TLS sources are ready for KSM
KSMTLSInputReadyCondition condition.Type = "KSMTLSInputReady"

// KSMDeploymentReadyCondition Status=True condition when KSM statefulset created ok
KSMDeploymentReadyCondition condition.Type = "KSMDeploymentReady"

// KSMServiceConfigReadyCondition Status=True Condition which indicates that all service config got rendered ok
KSMServiceConfigReadyCondition condition.Type = "KSMServiceConfigReady"

// KSMCreateServiceReadyCondition Status=True condition when k8s service for the KSM created ok
KSMCreateServiceReadyCondition condition.Type = "KSMCreateServiceReady"

// MysqldExporter conditions
MysqldExporterDBReadyCondition condition.Type = "MysqldExporterDBReady"
Expand Down Expand Up @@ -207,17 +216,8 @@ const (
//
// KSMReady condition messages
//
// KSMReadyInitMessage
KSMReadyInitMessage = "KSM not started"

// KSMReadyMessage
KSMReadyMessage = "KSM completed"

// KSMReadyErrorMessage
KSMReadyErrorMessage = "KSM error occured %s"

// KSMReadyRunningMessage
KSMReadyRunningMessage = "KSM in progress"
// KSMDisabledMessage
KSMDisabledMessage = "kube-state-metrics is disabled"

//
// mysqld_exporter condition messages
Expand Down
14 changes: 13 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

17 changes: 16 additions & 1 deletion config/crd/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ spec:
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
ksmStatus:
description: KSMStatus defines the observed state of kube-state-metrics
description: |-
NOTE(mmagr): remove with API version increment
Deprecated
properties:
conditions:
description: Conditions
Expand Down Expand Up @@ -136,6 +138,10 @@ spec:
type: object
ipmiImage:
type: string
ksmEnabled:
default: true
description: Whether kube-state-metrics should be deployed
type: boolean
ksmImage:
type: string
ksmTls:
Expand Down Expand Up @@ -295,6 +301,15 @@ spec:
type: string
description: Map of hashes to track e.g. job status
type: object
ksmHash:
additionalProperties:
type: string
description: Map of hashes to track e.g. job status
type: object
ksmReadyCount:
description: ReadyCount of kube-state-metrics instances
format: int32
type: integer
mysqldExporterExportedGaleras:
description: List of galera CRs, which are being exported with mysqld_exporter
items:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ spec:
type: boolean
ipmiImage:
type: string
ksmEnabled:
default: true
description: Whether kube-state-metrics should be deployed
type: boolean
ksmImage:
type: string
ksmTls:
Expand Down
Loading