Skip to content
Merged
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
14 changes: 2 additions & 12 deletions pkg/controllers/internalmembercluster/member_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ const (
eventReasonInternalMemberClusterUnknown = "InternalMemberClusterUnknown"
)

var (
errInvalidClusterState = errors.New("invalid member cluster spec state")
)

// NewReconciler creates a new reconciler for the internal membership CR
func NewReconciler(hubClient client.Client, memberClient client.Client,
internalMemberClusterChan chan<- fleetv1alpha1.ClusterState,
Expand Down Expand Up @@ -80,13 +76,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return r.updateHeartbeat(ctx, &memberCluster)
}

if memberCluster.Spec.State != fleetv1alpha1.ClusterStateLeave {
klog.ErrorS(errInvalidClusterState, "state", memberCluster.Spec.State,
"name", memberCluster.Name, "namespace", memberCluster.Namespace)
return ctrl.Result{}, errInvalidClusterState
}

//TODO: make sure the state is leave, alert otherwise
// Cluster state is Leave.
return r.leave(ctx, &memberCluster)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cluster state is enum, so I don't think this CR can be created with a state different than the 2 I defined. I tried that in controller test.

}

Expand All @@ -100,7 +90,7 @@ func (r *Reconciler) updateHeartbeat(ctx context.Context, memberCluster *fleetv1
if membershipState != fleetv1alpha1.ClusterStateJoin {
r.markInternalMemberClusterUnknown(memberCluster)
err := r.updateInternalMemberClusterWithRetry(ctx, memberCluster)
return ctrl.Result{RequeueAfter: time.Second * time.Duration(memberCluster.Spec.HeartbeatPeriodSeconds)},
return ctrl.Result{RequeueAfter: time.Minute},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing #95

errors.Wrap(err, "error marking internal member cluster as unknown")
}

Expand Down