Skip to content

Commit 1224281

Browse files
authored
fix: fix auto cluster creation failure (#229)
1 parent 34058c6 commit 1224281

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.1
1+
1.3.2

deployment/charts/intel-infra-provider-crds/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ apiVersion: v2
55
name: intel-infra-provider-crds
66
description: Custom Resource Definitions for Intel Cluster API Provider
77
type: application
8-
version: 1.3.1
8+
version: 1.3.2
99
annotations:
10-
revision: 45825ac8d246455282c07fef4b1943d0828615a5
11-
created: "2025-11-25T04:50:31Z"
12-
appVersion: 1.3.1
10+
revision: 34058c65b59cd6f16dc4f45836105c007b786946
11+
created: "2025-11-25T23:18:25Z"
12+
appVersion: 1.3.2

deployment/charts/intel-infra-provider/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ apiVersion: v2
55
name: intel-infra-provider
66
description: The Intel Cluster API Provider
77
type: application
8-
version: 1.3.1
8+
version: 1.3.2
99
annotations:
10-
revision: 45825ac8d246455282c07fef4b1943d0828615a5
11-
created: "2025-11-25T04:50:31Z"
12-
appVersion: 1.3.1
10+
revision: 34058c65b59cd6f16dc4f45836105c007b786946
11+
created: "2025-11-25T23:18:25Z"
12+
appVersion: 1.3.2

internal/southboundhandler/handler.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ func (h *Handler) UpdateStatus(ctx context.Context, nodeGUID string, status pb.U
259259
// IntelMachine for the node doesn't exist yet
260260
if intelmachine == nil {
261261
// unpause the cluster if paused
262-
cluster, err := getCluster(ctx, h.client, projectId, nodeGUID)
262+
cluster, err := h.getCluster(ctx, projectId, nodeGUID)
263263
if cluster != nil && cluster.Spec.Paused {
264+
log.Debug().Msgf("Unpausing cluster %s/%s", cluster.Namespace, cluster.Name)
264265
err = unpauseCluster(ctx, h.client, cluster)
266+
log.Debug().Msgf("Cluster unpause result: %v", err)
265267
}
266268
return pb.UpdateClusterStatusResponse_NONE, err
267269
}
@@ -393,16 +395,31 @@ func (h *Handler) getIntelMachine(ctx context.Context, client ctrlclient.Client,
393395
return intelMachine, nil
394396
}
395397

396-
func getCluster(ctx context.Context, client ctrlclient.Client, projectId string, nodeID string) (*clusterv1.Cluster, error) {
398+
func (h *Handler) getCluster(ctx context.Context, projectId string, nodeID string) (*clusterv1.Cluster, error) {
397399
// see if there is machine binding for this node
398400
var machineBindingList infrastructurev1alpha1.IntelMachineBindingList
399401

400-
if err := client.List(ctx, &machineBindingList,
401-
ctrlclient.InNamespace(projectId),
402-
ctrlclient.MatchingFields{nodeGUIDKey: nodeID}); err != nil {
402+
// TODO: always convert nodeID(GUID format) to hostID before search the cluster once host
403+
// unification from cluster-manager is done. For 3.2 release, try to get
404+
// hostID by UUID if no machine binding is found.
405+
if err := h.client.List(ctx, &machineBindingList, ctrlclient.InNamespace(projectId), ctrlclient.MatchingFields{nodeGUIDKey: nodeID}); err != nil {
403406
return nil, fmt.Errorf("failed to get intel machine binding list: %w", err)
404407
}
405408

409+
if len(machineBindingList.Items) == 0 && h.inventoryClient != nil {
410+
log.Debug().Msgf("No IntelMachineBinding found for node %s in project %s, attempt to get hostID by UUID", nodeID, projectId)
411+
host, err := h.inventoryClient.Client.GetHostByUUID(ctx, projectId, nodeID)
412+
if err != nil {
413+
return nil, fmt.Errorf("failed to get host resource by UUID: %w", err)
414+
}
415+
416+
if err := h.client.List(ctx, &machineBindingList,
417+
ctrlclient.InNamespace(projectId),
418+
ctrlclient.MatchingFields{nodeGUIDKey: host.GetResourceId()}); err != nil {
419+
return nil, fmt.Errorf("failed to get intel machine binding list: %w", err)
420+
}
421+
}
422+
406423
if len(machineBindingList.Items) == 0 {
407424
// no cluster is available for this node
408425
return nil, nil
@@ -412,9 +429,10 @@ func getCluster(ctx context.Context, client ctrlclient.Client, projectId string,
412429
}
413430

414431
// one cluster is found for the node
432+
log.Debug().Msgf("Found cluster for node %s %s/%s", nodeID, projectId, machineBindingList.Items[0].Spec.ClusterName)
415433
cluster := &clusterv1.Cluster{}
416434
key := types.NamespacedName{Namespace: projectId, Name: machineBindingList.Items[0].Spec.ClusterName}
417-
if err := client.Get(ctx, key, cluster); err != nil {
435+
if err := h.client.Get(ctx, key, cluster); err != nil {
418436
return nil, err
419437
}
420438

0 commit comments

Comments
 (0)