Skip to content

Commit

Permalink
orchestrator: purge dependency on controller library
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Jul 25, 2024
1 parent dbe50d0 commit 2c8f99c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions internal/orchestrator/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

v1types "github.com/metal-toolbox/conditionorc/pkg/api/v1/conditions/types"
rctypes "github.com/metal-toolbox/rivets/condition"
rcontroller "github.com/metal-toolbox/rivets/events/controller"
)

var (
Expand Down Expand Up @@ -361,7 +360,7 @@ func filterToReconcile(records []*store.ConditionRecord, updateEvts map[string]*

// condition active with stale updatedAt
return time.Since(createdAt) >= rctypes.StaleThreshold &&
time.Since(updatedAt) >= rcontroller.StatusStaleThreshold
time.Since(updatedAt) >= rctypes.StatusStaleThreshold
}

// updates
Expand Down Expand Up @@ -660,7 +659,7 @@ func (o *Orchestrator) queueFollowingCondition(ctx context.Context, cond *rctype
// This reconciles conditions in the Condition status KV - $condition.$facility
func (o *Orchestrator) eventNeedsReconciliation(evt *v1types.ConditionUpdateEvent) bool {
// the last update should be later than the condition stale threshold
if time.Since(evt.ConditionUpdate.UpdatedAt) < rcontroller.StatusStaleThreshold {
if time.Since(evt.ConditionUpdate.UpdatedAt) < rctypes.StatusStaleThreshold {
return false
}

Expand Down Expand Up @@ -692,7 +691,7 @@ func (o *Orchestrator) eventNeedsReconciliation(evt *v1types.ConditionUpdateEven
}

// controller most likely dead
if time.Since(lastTime) > rcontroller.LivenessStaleThreshold {
if time.Since(lastTime) > rctypes.LivenessStaleThreshold {
le.WithField(
"last.checkin",
time.Since(lastTime),
Expand Down
5 changes: 2 additions & 3 deletions internal/orchestrator/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
v1types "github.com/metal-toolbox/conditionorc/pkg/api/v1/conditions/types"
rctypes "github.com/metal-toolbox/rivets/condition"
eventsm "github.com/metal-toolbox/rivets/events"
rcontroller "github.com/metal-toolbox/rivets/events/controller"
)

var (
Expand Down Expand Up @@ -588,7 +587,7 @@ func TestFilterToReconcile(t *testing.T) {
Target: sid1,
// exceed thresholds
CreatedAt: createdTS.Add(-rctypes.StaleThreshold - 2*time.Minute),
UpdatedAt: updatedTS.Add(-rcontroller.StatusStaleThreshold - 2*time.Minute),
UpdatedAt: updatedTS.Add(-rctypes.StatusStaleThreshold - 2*time.Minute),
},
{
ID: cid1,
Expand Down Expand Up @@ -718,7 +717,7 @@ func TestFilterToReconcile(t *testing.T) {
Target: sid1,
// thresholds on record exceeded
CreatedAt: createdTS.Add(-rctypes.StaleThreshold - 2*time.Minute),
UpdatedAt: updatedTS.Add(-rcontroller.StatusStaleThreshold - 2*time.Minute),
UpdatedAt: updatedTS.Add(-rctypes.StatusStaleThreshold - 2*time.Minute),
},
},
},
Expand Down

0 comments on commit 2c8f99c

Please sign in to comment.