-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove finalizer when leave #183
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package controller | ||
|
||
import "context" | ||
|
||
type MemberController interface { | ||
Join(ctx context.Context) error | ||
|
||
Leave(ctx context.Context) error | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package internalmembercluster | ||
|
||
import ( | ||
"k8s.io/klog/v2" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
|
||
clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1" | ||
"go.goms.io/fleet/pkg/utils/condition" | ||
) | ||
|
||
// Reconciler reconciles the distribution of EndpointSlices across the fleet. | ||
type Reconciler struct { | ||
HubClient client.Client | ||
} | ||
|
||
func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
imcKRef := klog.KRef(req.Namespace, req.Name) | ||
startTime := time.Now() | ||
klog.V(2).InfoS("Reconciliation starts", "internalMemberCluster", imcKRef) | ||
defer func() { | ||
latency := time.Since(startTime).Milliseconds() | ||
klog.V(2).InfoS("Reconciliation ends", "internalMemberCluster", imcKRef, "latency", latency) | ||
}() | ||
|
||
var imc clusterv1beta1.InternalMemberCluster | ||
if err := r.HubClient.Get(ctx, req.NamespacedName, &imc); err != nil { | ||
if apierrors.IsNotFound(err) { | ||
klog.V(4).InfoS("Internal member cluster object is not found", "internalMemberCluster", imcKRef) | ||
return ctrl.Result{}, nil | ||
} | ||
klog.ErrorS(err, "Failed to get internal member cluster object", "internalMemberCluster", imcKRef) | ||
return ctrl.Result{}, err | ||
} | ||
|
||
if imc.Spec.state != clusterv1beta1.ClusterStateLeave { | ||
klog.V(2).Info("Skipping handling the internalMemberCluster non leave state", "internalMemberCluster", imcKRef, "clusterState", imc.Spec.State) | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
if condition.IsConditionStatusTrue(imc.GetConditionWithType(clusterv1beta1.MultiClusterServiceAgent, clusterv1beta1.AgentJoined)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean IsConditionStatusFalse? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, should be false |
||
&& condition.IsConditionStatusTrue(imc.GetConditionWithType(clusterv1beta1.ServiceExportImportAgent, clusterv1beta1.AgentJoined)) { | ||
// remove finalizer for internal member cluster if any in the reserved member namespace | ||
} | ||
return ctrl.Result{}, nil | ||
Check failure on line 44 in pkg/controllers/hub/internalmembercluster/controller.go GitHub Actions / unit-integration-tests
|
||
} | ||
|
||
func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { | ||
Check failure on line 47 in pkg/controllers/hub/internalmembercluster/controller.go GitHub Actions / unit-integration-tests
|
||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&fleetnetv1alpha1.InternalMemberCluster{}). | ||
Complete(r) | ||
} | ||
Check failure on line 51 in pkg/controllers/hub/internalmembercluster/controller.go GitHub Actions / unit-integration-tests
Check failure on line 51 in pkg/controllers/hub/internalmembercluster/controller.go GitHub Actions / unit-integration-tests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would like to declare this interface in the fleet repo instead