Skip to content

Commit 64caa88

Browse files
Use 'Ready' status conditions & remove 'Took' fields
1 parent fc9839c commit 64caa88

File tree

64 files changed

+678
-660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+678
-660
lines changed

api/v1alpha1/datasource_types.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88

99
corev1 "k8s.io/api/core/v1"
10-
"k8s.io/apimachinery/pkg/api/meta"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211
)
1312

@@ -225,19 +224,15 @@ type DatasourceSpec struct {
225224
}
226225

227226
const (
228-
// Something went wrong during the syncing of the datasource.
229-
DatasourceConditionError = "Error"
230-
// The datasource is waiting for a dependency datasource to become available.
231-
DatasourceConditionWaiting = "Waiting"
227+
// The datasource is ready to be used.
228+
DatasourceConditionReady = "Ready"
232229
)
233230

234231
type DatasourceStatus struct {
235232
// When the datasource was last successfully synced.
236233
LastSynced metav1.Time `json:"lastSynced,omitempty"`
237234
// The number of objects currently stored for this datasource.
238235
NumberOfObjects int64 `json:"numberOfObjects,omitempty"`
239-
// The time it took to perform the last sync.
240-
Took metav1.Duration `json:"took"`
241236
// Planned time for the next sync.
242237
NextSyncTime metav1.Time `json:"nextSyncTime,omitempty"`
243238

@@ -246,27 +241,16 @@ type DatasourceStatus struct {
246241
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
247242
}
248243

249-
// Helper function to check if the datasource is ready.
250-
func (s *DatasourceStatus) IsReady() bool {
251-
if meta.IsStatusConditionTrue(s.Conditions, DatasourceConditionError) {
252-
return false
253-
}
254-
if meta.IsStatusConditionTrue(s.Conditions, DatasourceConditionWaiting) {
255-
return false
256-
}
257-
return s.NumberOfObjects > 0
258-
}
259-
260244
// +kubebuilder:object:root=true
261245
// +kubebuilder:subresource:status
262246
// +kubebuilder:resource:scope=Cluster
263247
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type"
264248
// +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.schedulingDomain"
265249
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".metadata.creationTimestamp"
266250
// +kubebuilder:printcolumn:name="Synced",type="date",JSONPath=".status.lastSynced"
267-
// +kubebuilder:printcolumn:name="Took",type="string",JSONPath=".status.took"
268251
// +kubebuilder:printcolumn:name="Next",type="string",JSONPath=".status.nextSyncTime"
269252
// +kubebuilder:printcolumn:name="Objects",type="integer",JSONPath=".status.numberOfObjects"
253+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
270254

271255
// Datasource is the Schema for the datasources API
272256
type Datasource struct {

api/v1alpha1/decision_types.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,11 @@ type DecisionResult struct {
7171
}
7272

7373
const (
74-
// Something went wrong during the calculation of the decision.
75-
DecisionConditionError = "Error"
74+
// The decision was successfully processed.
75+
DecisionConditionReady = "Ready"
7676
)
7777

7878
type DecisionStatus struct {
79-
// The time it took to schedule.
80-
// +kubebuilder:validation:Optional
81-
Took metav1.Duration `json:"took"`
82-
8379
// The result of this decision.
8480
// +kubebuilder:validation:Optional
8581
Result *DecisionResult `json:"result,omitempty"`
@@ -113,6 +109,7 @@ type DecisionStatus struct {
113109
// +kubebuilder:printcolumn:name="Took",type="string",JSONPath=".status.took"
114110
// +kubebuilder:printcolumn:name="Pipeline",type="string",JSONPath=".spec.pipelineRef.name"
115111
// +kubebuilder:printcolumn:name="TargetHost",type="string",JSONPath=".status.result.targetHost"
112+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
116113
// +kubebuilder:selectablefield:JSONPath=".spec.resourceID"
117114

118115
// Decision is the Schema for the decisions API

api/v1alpha1/descheduling_types.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,14 @@ type DeschedulingSpec struct {
3636
Reason string `json:"reason,omitempty"`
3737
}
3838

39-
// The phase in which the descheduling is.
40-
type DeschedulingStatusPhase string
41-
4239
const (
43-
// The descheduling was queued and is waiting to be processed.
44-
DeschedulingStatusPhaseQueued DeschedulingStatusPhase = "queued"
40+
// The descheduling was successfully processed.
41+
DeschedulingConditionReady = "Ready"
4542
// The descheduling is currently being processed.
46-
DeschedulingStatusPhaseInProgress DeschedulingStatusPhase = "inProgress"
47-
// The descheduling was completed successfully.
48-
DeschedulingStatusPhaseCompleted DeschedulingStatusPhase = "completed"
49-
// The descheduling failed.
50-
DeschedulingStatusPhaseFailed DeschedulingStatusPhase = "failed"
51-
)
52-
53-
const (
54-
// Something went wrong during the descheduling process.
55-
DeschedulingConditionError = "Error"
43+
DeschedulingConditionInProgress = "InProgress"
5644
)
5745

5846
type DeschedulingStatus struct {
59-
// The current phase of the descheduling.
60-
Phase DeschedulingStatusPhase `json:"phase"`
6147
// The current status conditions of the descheduling.
6248
// +kubebuilder:validation:Optional
6349
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
@@ -70,11 +56,11 @@ type DeschedulingStatus struct {
7056
// +kubebuilder:object:root=true
7157
// +kubebuilder:subresource:status
7258
// +kubebuilder:resource:scope=Cluster
73-
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
7459
// +kubebuilder:printcolumn:name="Previous Host",type="string",JSONPath=".spec.prevHost"
7560
// +kubebuilder:printcolumn:name="New Host",type="string",JSONPath=".status.newHost"
7661
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".metadata.creationTimestamp"
7762
// +kubebuilder:printcolumn:name="Reason(s)",type="string",JSONPath=".spec.reason"
63+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
7864

7965
// Descheduling is the Schema for the deschedulings API
8066
type Descheduling struct {

api/v1alpha1/knowledge_types.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"encoding/json"
88

99
corev1 "k8s.io/api/core/v1"
10-
"k8s.io/apimachinery/pkg/api/meta"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211
runtime "k8s.io/apimachinery/pkg/runtime"
1312
)
@@ -85,17 +84,14 @@ func BoxFeatureList[T any](features []T) (runtime.RawExtension, error) {
8584
}
8685

8786
const (
88-
// Something went wrong during the extraction of the knowledge.
89-
KnowledgeConditionError = "Error"
87+
// The knowledge is ready to be used.
88+
KnowledgeConditionReady = "Ready"
9089
)
9190

9291
type KnowledgeStatus struct {
9392
// When the knowledge was last successfully extracted.
9493
// +kubebuilder:validation:Optional
9594
LastExtracted metav1.Time `json:"lastExtracted"`
96-
// The time it took to perform the last extraction.
97-
// +kubebuilder:validation:Optional
98-
Took metav1.Duration `json:"took"`
9995

10096
// The raw data behind the extracted knowledge, e.g. a list of features.
10197
// +kubebuilder:validation:Optional
@@ -109,23 +105,15 @@ type KnowledgeStatus struct {
109105
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
110106
}
111107

112-
// Helper function to check if the knowledge is ready.
113-
func (s *KnowledgeStatus) IsReady() bool {
114-
if meta.IsStatusConditionTrue(s.Conditions, KnowledgeConditionError) {
115-
return false
116-
}
117-
return s.RawLength > 0
118-
}
119-
120108
// +kubebuilder:object:root=true
121109
// +kubebuilder:subresource:status
122110
// +kubebuilder:resource:scope=Cluster
123111
// +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.schedulingDomain"
124112
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".metadata.creationTimestamp"
125113
// +kubebuilder:printcolumn:name="Extracted",type="date",JSONPath=".status.lastExtracted"
126-
// +kubebuilder:printcolumn:name="Took",type="string",JSONPath=".status.took"
127114
// +kubebuilder:printcolumn:name="Recency",type="string",JSONPath=".spec.recency"
128115
// +kubebuilder:printcolumn:name="Features",type="integer",JSONPath=".status.rawLength"
116+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
129117

130118
// Knowledge is the Schema for the knowledges API
131119
type Knowledge struct {

api/v1alpha1/kpi_types.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@ type KPISpec struct {
4343
}
4444

4545
const (
46-
// Something went wrong during the kpi reconciliation.
47-
KPIConditionError = "Error"
46+
// If the kpi was successfully processed.
47+
KPIConditionReady = "Ready"
4848
)
4949

5050
type KPIStatus struct {
51-
// If the kpi is ready to be executed.
52-
Ready bool `json:"ready"`
53-
5451
// How many dependencies have been reconciled.
5552
ReadyDependencies int `json:"readyDependencies"`
5653
// Total number of dependencies configured.
@@ -71,6 +68,7 @@ type KPIStatus struct {
7168
// +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.schedulingDomain"
7269
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
7370
// +kubebuilder:printcolumn:name="Dependencies",type="string",JSONPath=".status.dependenciesReadyFrac"
71+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
7472

7573
// KPI is the Schema for the deschedulings API
7674
type KPI struct {

api/v1alpha1/pipeline_types.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,11 @@ type PipelineSpec struct {
9292
}
9393

9494
const (
95-
// Something went wrong during the pipeline reconciliation.
96-
PipelineConditionError = "Error"
95+
// The pipeline is ready to be used.
96+
PipelineConditionReady = "Ready"
9797
)
9898

9999
type PipelineStatus struct {
100-
// Whether the pipeline is ready to be used.
101-
Ready bool `json:"ready"`
102100
// The total number of steps configured in the pipeline.
103101
TotalSteps int `json:"totalSteps"`
104102
// The number of steps that are ready.
@@ -117,8 +115,8 @@ type PipelineStatus struct {
117115
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".metadata.creationTimestamp"
118116
// +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.schedulingDomain"
119117
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type"
120-
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
121118
// +kubebuilder:printcolumn:name="Steps",type="string",JSONPath=".status.stepsReadyFrac"
119+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
122120

123121
// Pipeline is the Schema for the decisions API
124122
type Pipeline struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cortex.cloud_datasources.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ spec:
2727
- jsonPath: .status.lastSynced
2828
name: Synced
2929
type: date
30-
- jsonPath: .status.took
31-
name: Took
32-
type: string
3330
- jsonPath: .status.nextSyncTime
3431
name: Next
3532
type: string
3633
- jsonPath: .status.numberOfObjects
3734
name: Objects
3835
type: integer
36+
- jsonPath: .status.conditions[?(@.type=='Ready')].status
37+
name: Ready
38+
type: string
3939
name: v1alpha1
4040
schema:
4141
openAPIV3Schema:
@@ -347,11 +347,6 @@ spec:
347347
description: The number of objects currently stored for this datasource.
348348
format: int64
349349
type: integer
350-
took:
351-
description: The time it took to perform the last sync.
352-
type: string
353-
required:
354-
- took
355350
type: object
356351
required:
357352
- spec

config/crd/bases/cortex.cloud_decisions.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ spec:
3939
- jsonPath: .status.result.targetHost
4040
name: TargetHost
4141
type: string
42+
- jsonPath: .status.conditions[?(@.type=='Ready')].status
43+
name: Ready
44+
type: string
4245
name: v1alpha1
4346
schema:
4447
openAPIV3Schema:
@@ -392,9 +395,6 @@ spec:
392395
the target host.
393396
type: string
394397
type: object
395-
took:
396-
description: The time it took to schedule.
397-
type: string
398398
type: object
399399
required:
400400
- spec

config/crd/bases/cortex.cloud_deschedulings.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ spec:
1515
scope: Cluster
1616
versions:
1717
- additionalPrinterColumns:
18-
- jsonPath: .status.phase
19-
name: Phase
20-
type: string
2118
- jsonPath: .spec.prevHost
2219
name: Previous Host
2320
type: string
@@ -30,6 +27,9 @@ spec:
3027
- jsonPath: .spec.reason
3128
name: Reason(s)
3229
type: string
30+
- jsonPath: .status.conditions[?(@.type=='Ready')].status
31+
name: Ready
32+
type: string
3333
name: v1alpha1
3434
schema:
3535
openAPIV3Schema:
@@ -140,11 +140,6 @@ spec:
140140
newHostType:
141141
description: The type of host where the VM was rescheduled to.
142142
type: string
143-
phase:
144-
description: The current phase of the descheduling.
145-
type: string
146-
required:
147-
- phase
148143
type: object
149144
required:
150145
- spec

0 commit comments

Comments
 (0)