Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions operator/internal/controller/cluster_state_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ func IntrospectSkyhook(skyhook SkyhookNodes, allSkyhooks []SkyhookNodes) bool {
}

skyhook.UpdateCondition()
skyhook.ReportState()
if skyhook.GetSkyhook().Updated {
change = true
}
Expand Down Expand Up @@ -1039,6 +1040,7 @@ func UpdateSkyhookPauseStatus(skyhook SkyhookNodes) bool {
changed = true
}

skyhook.ReportState()
return changed
}

Expand Down
4 changes: 4 additions & 0 deletions operator/internal/controller/cluster_state_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ var _ = Describe("CleanupRemovedNodes", func() {
mockSkyhookNodes.EXPECT().Status().Return(v1alpha1.StatusInProgress)
mockSkyhookNodes.EXPECT().SetStatus(v1alpha1.StatusPaused).Once()
mockSkyhookNodes.EXPECT().GetNodes().Return([]wrapper.SkyhookNode{mockNode1, mockNode2})
mockSkyhookNodes.EXPECT().ReportState().Return()

// Call the function
result := UpdateSkyhookPauseStatus(mockSkyhookNodes)
Expand All @@ -1067,6 +1068,7 @@ var _ = Describe("CleanupRemovedNodes", func() {
// Set up mock expectations
mockSkyhookNodes.EXPECT().IsPaused().Return(true)
mockSkyhookNodes.EXPECT().Status().Return(v1alpha1.StatusPaused)
mockSkyhookNodes.EXPECT().ReportState().Return()

// Call the function
result := UpdateSkyhookPauseStatus(mockSkyhookNodes)
Expand All @@ -1081,6 +1083,7 @@ var _ = Describe("CleanupRemovedNodes", func() {

// Set up mock expectations
mockSkyhookNodes.EXPECT().IsPaused().Return(false)
mockSkyhookNodes.EXPECT().ReportState().Return()

// Call the function
result := UpdateSkyhookPauseStatus(mockSkyhookNodes)
Expand All @@ -1092,6 +1095,7 @@ var _ = Describe("CleanupRemovedNodes", func() {
It("should not change status when skyhook pause annotation is missing", func() {
// Set up mock expectations no pause annotation means not paused
mockSkyhookNodes.EXPECT().IsPaused().Return(false)
mockSkyhookNodes.EXPECT().ReportState().Return()

// Call the function
result := UpdateSkyhookPauseStatus(mockSkyhookNodes)
Expand Down
22 changes: 0 additions & 22 deletions operator/internal/controller/skyhook_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ func (r *SkyhookReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return result, err
}

if yes, result, err := shouldReturn(r.ReportState(ctx, clusterState, skyhook)); yes {
return result, err
}

if skyhook.IsPaused() {
if yes, result, err := shouldReturn(r.UpdatePauseStatus(ctx, clusterState, skyhook)); yes {
return result, err
Expand Down Expand Up @@ -503,24 +499,6 @@ func (r *SkyhookReconciler) HandleMigrations(ctx context.Context, clusterState *
return updates, nil
}

// ReportState computes and puts important information into the skyhook status so that monitoring tools such as k9s
// can see the information at a glance. For example, the number of completed nodes and the list of packages in the skyhook.
func (r *SkyhookReconciler) ReportState(ctx context.Context, clusterState *clusterState, skyhook SkyhookNodes) (bool, error) {

// save updated state to skyhook status
skyhook.ReportState()

if skyhook.GetSkyhook().Updated {
_, errs := r.SaveNodesAndSkyhook(ctx, clusterState, skyhook)
if len(errs) > 0 {
return false, utilerrors.NewAggregate(errs)
}
return true, nil
}

return false, nil
}

func (r *SkyhookReconciler) UpdatePauseStatus(ctx context.Context, clusterState *clusterState, skyhook SkyhookNodes) (bool, error) {
changed := UpdateSkyhookPauseStatus(skyhook)

Expand Down
Loading