Skip to content

Commit

Permalink
feat: don't make collectors group not ready once set as ready (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored May 5, 2024
1 parent 95fc543 commit 0d1eb91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
16 changes: 9 additions & 7 deletions autoscaler/controllers/datacollection/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package datacollection

import (
"context"
"fmt"

odigosv1 "github.com/keyval-dev/odigos/api/odigos/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -72,12 +71,15 @@ func syncDataCollection(instApps *odigosv1.InstrumentedApplicationList, dests *o
return err
}

if err := c.Status().Patch(ctx, dataCollection, client.RawPatch(
types.MergePatchType,
[]byte(fmt.Sprintf(`{"status": { "ready": %t }}`, calcDataCollectionReadyStatus(ds))),
)); err != nil {
logger.Error(err, "Failed to update data collection status")
return err
isNowReady := calcDataCollectionReadyStatus(ds)
if !dataCollection.Status.Ready && isNowReady {
if err := c.Status().Patch(ctx, dataCollection, client.RawPatch(
types.MergePatchType,
[]byte(`{"status": { "ready": true }}`),
)); err != nil {
logger.Error(err, "Failed to update data collection status")
return err
}
}

return nil
Expand Down
17 changes: 12 additions & 5 deletions autoscaler/controllers/gateway/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gateway

import (
"context"
"fmt"

odigosv1 "github.com/keyval-dev/odigos/api/odigos/v1alpha1"
"github.com/keyval-dev/odigos/common/consts"
Expand Down Expand Up @@ -93,8 +92,16 @@ func syncGateway(dests *odigosv1.DestinationList, processors *odigosv1.Processor
return err
}

return c.Status().Patch(ctx, gateway, client.RawPatch(
types.MergePatchType,
[]byte(fmt.Sprintf(`{"status": { "ready": %t }}`, dep.Status.ReadyReplicas > 0)),
))
isReady := dep.Status.ReadyReplicas > 0
if !gateway.Status.Ready && isReady {
err := c.Status().Patch(ctx, gateway, client.RawPatch(
types.MergePatchType,
[]byte(`{"status": { "ready": true }}`),
))
if err != nil {
return err
}
}

return nil
}

0 comments on commit 0d1eb91

Please sign in to comment.