-
Notifications
You must be signed in to change notification settings - Fork 170
feat(scheduling): backend-driven HCP placement #6657
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -31,8 +31,9 @@ import ( | |
| ) | ||
|
|
||
| type clusterPendingClusterServiceIDAssignSyncer struct { | ||
| clusterLister corelisters.ClusterLister | ||
| resourcesDBClient corecosmosstorage.ResourcesDBClient | ||
| clusterLister corelisters.ClusterLister | ||
| serviceProviderClusterLister corelisters.ServiceProviderClusterLister | ||
| resourcesDBClient corecosmosstorage.ResourcesDBClient | ||
| } | ||
|
|
||
| var _ controllerutils.ClusterSyncer = (*clusterPendingClusterServiceIDAssignSyncer)(nil) | ||
|
|
@@ -41,9 +42,11 @@ const ClusterPendingClusterServiceIDAssignControllerName = "ClusterPendingCluste | |
|
|
||
| func NewClusterPendingClusterServiceIDAssignController(resourcesDBClient corecosmosstorage.ResourcesDBClient, backendInformers coreinformers.BackendInformers) controllerutils.Controller { | ||
| _, clusterLister := backendInformers.Clusters() | ||
| _, serviceProviderClusterLister := backendInformers.ServiceProviderClusters() | ||
| syncer := &clusterPendingClusterServiceIDAssignSyncer{ | ||
| clusterLister: clusterLister, | ||
| resourcesDBClient: resourcesDBClient, | ||
| clusterLister: clusterLister, | ||
| serviceProviderClusterLister: serviceProviderClusterLister, | ||
| resourcesDBClient: resourcesDBClient, | ||
| } | ||
|
|
||
| return controllerutils.NewClusterWatchingController( | ||
|
|
@@ -56,11 +59,19 @@ func NewClusterPendingClusterServiceIDAssignController(resourcesDBClient corecos | |
| ) | ||
| } | ||
|
|
||
| func (c *clusterPendingClusterServiceIDAssignSyncer) needsWork(cluster *coreapi.HCPOpenShiftCluster) bool { | ||
| // needsWork reports whether a PendingClusterServiceID should be assigned. In | ||
| // addition to the cluster not yet having a (pending or resolved) Cluster Service | ||
| // ID and not being deleted, placement must already be resolved: the | ||
| // ServiceProviderCluster must have Spec.ManagementClusterResourceID set by the | ||
| // PlacementController. This gates Cluster Service creation on a management | ||
| // cluster having been chosen first. | ||
| func (c *clusterPendingClusterServiceIDAssignSyncer) needsWork(cluster *coreapi.HCPOpenShiftCluster, serviceProviderCluster *coreapi.ServiceProviderCluster) bool { | ||
| return cluster.ServiceProviderProperties.DeletionTimestamp == nil && | ||
| cluster.ServiceProviderProperties.PendingClusterServiceID == nil && | ||
| (cluster.ServiceProviderProperties.ClusterServiceID == nil || | ||
| len(cluster.ServiceProviderProperties.ClusterServiceID.String()) == 0) | ||
| len(cluster.ServiceProviderProperties.ClusterServiceID.String()) == 0) && | ||
| serviceProviderCluster != nil && | ||
| serviceProviderCluster.Spec.ManagementClusterResourceID != nil | ||
|
Collaborator
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. This is not required here. We can determine the future ID and unleash all sorts of Azure changes before we assign a management cluster.
Collaborator
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. this is me being pesimistic. why would we unleash all sorts of azure changes before we know we get a slot to schedule
Collaborator
Author
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. Leaving this unchanged for now — it's an open design question (gate CS-ID assignment on placement vs. determine the future ID before assigning a management cluster). The design author is currently defending the gating on this thread, so I'll hold any change until that's settled; happy to drop the gating if that's the conclusion. AI-generated. Review for accuracy. AI-generated. Review for accuracy. |
||
| } | ||
|
|
||
| func (c *clusterPendingClusterServiceIDAssignSyncer) SyncOnce(ctx context.Context, key controllerutils.HCPClusterKey) error { | ||
|
|
@@ -74,7 +85,16 @@ func (c *clusterPendingClusterServiceIDAssignSyncer) SyncOnce(ctx context.Contex | |
| return utils.TrackError(err) | ||
| } | ||
|
|
||
| if !c.needsWork(cluster) { | ||
| serviceProviderCluster, err := c.serviceProviderClusterLister.Get(ctx, key.SubscriptionID, key.ResourceGroupName, key.HCPClusterName) | ||
| if cosmosstorageutils.IsNotFoundError(err) { | ||
| // Placement has not produced a ServiceProviderCluster yet; wait. | ||
| return nil | ||
| } | ||
| if err != nil { | ||
| return utils.TrackError(err) | ||
| } | ||
|
|
||
| if !c.needsWork(cluster, serviceProviderCluster) { | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
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.
Before calling createClusterServiceCluster, ensure that
serviceProviderCluster.Spec.ManagementClusterResourceIDis non-nil and print a message if it is nil and then return nil.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.
provisionShardID() handles unplaced clusters but returns an err which in turns add the item back to the queue. as you said we should return nil. the update on the SPC once placement is available, will wake us up again.
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.
Done in
9a34ddd— before creating the CS cluster, ifserviceProviderCluster.Spec.ManagementClusterResourceIDis nil we now log andreturn nil(no error, no requeue); the SPC update when placement lands re-triggers.provisionShardIDno longer errors on an unplaced cluster.AI-generated. Review for accuracy.
AI-generated. Review for accuracy.