Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Fixed
- Fixed a bug where the scheduler would not re-try updating podgroup status after failure
- Fixed a bug where ray workloads gang scheduling would ignore `minReplicas` if autoscaling was not set
- KAI Config wrong statuses when prometheus operand is enabled

## [v0.9.1] - 20250-09-15

Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kai/v1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
ConditionTypeDeployed ConditionType = "Deployed"
ConditionTypeAvailable ConditionType = "Available"
ConditionDependenciesFulfilled ConditionType = "DependenciesFulfilled"
ConditionDependenciesMissing ConditionType = "DependenciesMissing"
)

type ConditionReason string
Expand All @@ -37,6 +38,7 @@ const (
Available ConditionReason = "available"
Reconciled ConditionReason = "reconciled"
DependenciesFulfilled ConditionReason = "dependencies_fulfilled"
DependenciesMissing ConditionReason = "dependencies_missing"
PrometheusConnected ConditionReason = "prometheus_connected"
PrometheusConnectionFailed ConditionReason = "prometheus_connection_failed"
)
Expand Down
29 changes: 26 additions & 3 deletions pkg/operator/controller/status_reconciler/status_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *StatusReconciler) ReconcileStatus(ctx context.Context, object objectWit
if err := r.reconcileCondition(ctx, object, r.getAvailableCondition(ctx, object.GetGeneration())); err != nil {
return err
}
return r.reconcileCondition(ctx, object, r.getDependenciesFulfilledCondition(object.GetGeneration()))
return r.reconcileCondition(ctx, object, r.getDependenciesFulfilledCondition(ctx, object))
}

func (r *StatusReconciler) reconcileCondition(ctx context.Context, object objectWithConditions, condition metav1.Condition) error {
Expand Down Expand Up @@ -155,13 +155,36 @@ func (r *StatusReconciler) getAvailableCondition(ctx context.Context, gen int64)
}
}

func (r *StatusReconciler) getDependenciesFulfilledCondition(gen int64) metav1.Condition {
func (r *StatusReconciler) getDependenciesFulfilledCondition(ctx context.Context, object objectWithConditions) metav1.Condition {
missingDependencies, err := r.deployable.HasMissingDependencies(ctx, r.Client, object.GetInternalObject())
if err != nil {
return metav1.Condition{
Type: string(kaiv1.ConditionDependenciesFulfilled),
Status: metav1.ConditionFalse,
Reason: string(kaiv1.DependenciesMissing),
Message: err.Error(),
ObservedGeneration: object.GetGeneration(),
LastTransitionTime: metav1.Now(),
}
}

if len(missingDependencies) > 0 {
return metav1.Condition{
Type: string(kaiv1.ConditionDependenciesFulfilled),
Status: metav1.ConditionFalse,
Reason: string(kaiv1.DependenciesMissing),
Message: missingDependencies,
ObservedGeneration: object.GetGeneration(),
LastTransitionTime: metav1.Now(),
}
}

return metav1.Condition{
Type: string(kaiv1.ConditionDependenciesFulfilled),
Status: metav1.ConditionTrue,
Reason: string(kaiv1.DependenciesFulfilled),
Message: "Dependencies are fulfilled",
ObservedGeneration: gen,
ObservedGeneration: object.GetGeneration(),
LastTransitionTime: metav1.Now(),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ func (f *fakeDeployable) IsAvailable(ctx context.Context, runtimeClient client.R
return f.isAvailable, nil
}

func (f *fakeDeployable) Monitor(ctx context.Context, runtimeReader client.Reader, kaiConfig *kaiv1.Config) error {
return nil
}

func (f *fakeDeployable) HasMissingDependencies(ctx context.Context, readerClient client.Reader, obj client.Object) (string, error) {
return "", nil
}

func (f *fakeDeployable) Name() string {
return "fakeDeployable"
}
4 changes: 4 additions & 0 deletions pkg/operator/operands/admission/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ func (a *Admission) Name() string {
func (a *Admission) Monitor(ctx context.Context, runtimeReader client.Reader, kaiConfig *kaiv1.Config) error {
return nil
}

func (a *Admission) HasMissingDependencies(context.Context, client.Reader, *kaiv1.Config) (string, error) {
return "", nil
}
4 changes: 4 additions & 0 deletions pkg/operator/operands/binder/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ func (b *Binder) Name() string {
func (b *Binder) Monitor(ctx context.Context, runtimeReader client.Reader, kaiConfig *kaiv1.Config) error {
return nil
}

func (b *Binder) HasMissingDependencies(context.Context, client.Reader, *kaiv1.Config) (string, error) {
return "", nil
}
29 changes: 26 additions & 3 deletions pkg/operator/operands/deployable/deployable.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func (d *DeployableOperands) Deploy(
Controller: ptr.To(true),
}

if createObjectsInCluster(ctx, runtimeClient, reconcilerAsOwnerReference, objectsToCreate) != nil {
if err := createObjectsInCluster(ctx, runtimeClient, reconcilerAsOwnerReference, objectsToCreate); err != nil {
return err
}

if deleteObjectsInCluster(ctx, runtimeClient, objectsToDelete) != nil {
if err := deleteObjectsInCluster(ctx, runtimeClient, objectsToDelete); err != nil {
return err
}

if updateObjectsInCluster(ctx, runtimeClient, reconcilerAsOwnerReference, objectsToUpdate) != nil {
if err := updateObjectsInCluster(ctx, runtimeClient, reconcilerAsOwnerReference, objectsToUpdate); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -301,3 +301,26 @@ func (d *DeployableOperands) Monitor(ctx context.Context, runtimeReader client.R
}
return nil
}

func (d *DeployableOperands) HasMissingDependencies(ctx context.Context, readerClient client.Reader, object client.Object) (string, error) {
var missingDependencies string
var err error

kaiConfig, checkForKAIConfig := object.(*kaiv1.Config)
if !checkForKAIConfig {
return "", nil
}

for _, operand := range d.operands {
// Assuming each operand has a HasDependencies method
missing, e := operand.HasMissingDependencies(ctx, readerClient, kaiConfig)
if e != nil {
err = errors.Join(err, e)
}
if len(missing) > 0 {
missingDependencies = missingDependencies + fmt.Sprintf("\n%s is missing %s", operand.Name(), missing)
}
}

return missingDependencies, err
}
Loading
Loading