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
Changes from 1 commit
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
Next Next commit
Deprecate non-working KSMStatus
This patch moves status data about kube-state-metrics
to CeilometerStatus, because currently KSMStatus does not update
properly and if helper.PatchInstance is made to update KSMStatus
then Ceilometer objects ends in never ending reconciliation loop.
paramite committed Jan 15, 2025
commit 8cf8a0cf342f048ccc48424dcfd8b8fd99e07e79
17 changes: 16 additions & 1 deletion api/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
@@ -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
@@ -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:
@@ -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:
4 changes: 4 additions & 0 deletions api/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
@@ -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:
17 changes: 14 additions & 3 deletions api/v1beta1/ceilometer_types.go
Original file line number Diff line number Diff line change
@@ -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"`
@@ -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"`
@@ -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.CeilometerStatus.Conditions.IsTrue(condition.ReadyCondition)
}

func init() {
26 changes: 13 additions & 13 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
@@ -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"
@@ -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
12 changes: 12 additions & 0 deletions 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
@@ -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
@@ -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:
@@ -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:
4 changes: 4 additions & 0 deletions config/crd/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
@@ -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:
215 changes: 130 additions & 85 deletions controllers/ceilometer_controller.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions hack/crd-schema-checker.sh
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ for crd in config/crd/bases/*.yaml; do
mkdir -p "$(dirname "$TMP_DIR/$crd")"
if git show "$BASE_REF:$crd" > "$TMP_DIR/$crd"; then
$CHECKER check-manifests \
--disabled-validators="NoMaps" \
--disabled-validators="NoBools" \
--existing-crd-filename="$TMP_DIR/$crd" \
--new-crd-filename="$crd"
fi