Skip to content

Commit 31ef8e5

Browse files
committed
ASOAPI: report status on managed ASO resources
1 parent 2c9ecd7 commit 31ef8e5

15 files changed

+740
-12
lines changed

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclusters.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ spec:
5151
status:
5252
description: AzureASOManagedClusterStatus defines the observed state of
5353
AzureASOManagedCluster.
54+
properties:
55+
resources:
56+
items:
57+
description: ResourceStatus represents the status of a resource.
58+
properties:
59+
ready:
60+
type: boolean
61+
resource:
62+
description: StatusResource is a handle to a resource.
63+
properties:
64+
group:
65+
type: string
66+
kind:
67+
type: string
68+
name:
69+
type: string
70+
version:
71+
type: string
72+
required:
73+
- group
74+
- kind
75+
- name
76+
- version
77+
type: object
78+
required:
79+
- ready
80+
- resource
81+
type: object
82+
type: array
5483
type: object
5584
type: object
5685
served: true

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ spec:
5252
status:
5353
description: AzureASOManagedControlPlaneStatus defines the observed state
5454
of AzureASOManagedControlPlane.
55+
properties:
56+
resources:
57+
items:
58+
description: ResourceStatus represents the status of a resource.
59+
properties:
60+
ready:
61+
type: boolean
62+
resource:
63+
description: StatusResource is a handle to a resource.
64+
properties:
65+
group:
66+
type: string
67+
kind:
68+
type: string
69+
name:
70+
type: string
71+
version:
72+
type: string
73+
required:
74+
- group
75+
- kind
76+
- name
77+
- version
78+
type: object
79+
required:
80+
- ready
81+
- resource
82+
type: object
83+
type: array
5584
type: object
5685
type: object
5786
served: true

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepools.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ spec:
5252
status:
5353
description: AzureASOManagedMachinePoolStatus defines the observed state
5454
of AzureASOManagedMachinePool.
55+
properties:
56+
resources:
57+
items:
58+
description: ResourceStatus represents the status of a resource.
59+
properties:
60+
ready:
61+
type: boolean
62+
resource:
63+
description: StatusResource is a handle to a resource.
64+
properties:
65+
group:
66+
type: string
67+
kind:
68+
type: string
69+
name:
70+
type: string
71+
version:
72+
type: string
73+
required:
74+
- group
75+
- kind
76+
- name
77+
- version
78+
type: object
79+
required:
80+
- ready
81+
- resource
82+
type: object
83+
type: array
5584
type: object
5685
type: object
5786
served: true

exp/api/v1alpha1/azureasomanagedcluster_types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ type AzureASOManagedClusterSpec struct {
3535

3636
// AzureASOManagedClusterStatus defines the observed state of AzureASOManagedCluster.
3737
type AzureASOManagedClusterStatus struct {
38+
//+optional
39+
Resources []ResourceStatus `json:"resources,omitempty"`
40+
}
41+
42+
// ResourceStatus represents the status of a resource.
43+
type ResourceStatus struct {
44+
Resource StatusResource `json:"resource"`
45+
Ready bool `json:"ready"`
46+
}
47+
48+
// StatusResource is a handle to a resource.
49+
type StatusResource struct {
50+
Group string `json:"group"`
51+
Version string `json:"version"`
52+
Kind string `json:"kind"`
53+
Name string `json:"name"`
3854
}
3955

4056
//+kubebuilder:object:root=true
@@ -49,6 +65,11 @@ type AzureASOManagedCluster struct {
4965
Status AzureASOManagedClusterStatus `json:"status,omitempty"`
5066
}
5167

68+
// SetResourceStatuses returns the status of resources.
69+
func (a *AzureASOManagedCluster) SetResourceStatuses(r []ResourceStatus) {
70+
a.Status.Resources = r
71+
}
72+
5273
//+kubebuilder:object:root=true
5374

5475
// AzureASOManagedClusterList contains a list of AzureASOManagedCluster.

exp/api/v1alpha1/azureasomanagedcontrolplane_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type AzureASOManagedControlPlaneSpec struct {
3030

3131
// AzureASOManagedControlPlaneStatus defines the observed state of AzureASOManagedControlPlane.
3232
type AzureASOManagedControlPlaneStatus struct {
33+
//+optional
34+
Resources []ResourceStatus `json:"resources,omitempty"`
3335
}
3436

3537
//+kubebuilder:object:root=true
@@ -44,6 +46,11 @@ type AzureASOManagedControlPlane struct {
4446
Status AzureASOManagedControlPlaneStatus `json:"status,omitempty"`
4547
}
4648

49+
// SetResourceStatuses returns the status of resources.
50+
func (a *AzureASOManagedControlPlane) SetResourceStatuses(r []ResourceStatus) {
51+
a.Status.Resources = r
52+
}
53+
4754
//+kubebuilder:object:root=true
4855

4956
// AzureASOManagedControlPlaneList contains a list of AzureASOManagedControlPlane.

exp/api/v1alpha1/azureasomanagedmachinepool_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type AzureASOManagedMachinePoolSpec struct {
3030

3131
// AzureASOManagedMachinePoolStatus defines the observed state of AzureASOManagedMachinePool.
3232
type AzureASOManagedMachinePoolStatus struct {
33+
//+optional
34+
Resources []ResourceStatus `json:"resources,omitempty"`
3335
}
3436

3537
//+kubebuilder:object:root=true
@@ -44,6 +46,11 @@ type AzureASOManagedMachinePool struct {
4446
Status AzureASOManagedMachinePoolStatus `json:"status,omitempty"`
4547
}
4648

49+
// SetResourceStatuses returns the status of resources.
50+
func (a *AzureASOManagedMachinePool) SetResourceStatuses(r []ResourceStatus) {
51+
a.Status.Resources = r
52+
}
53+
4754
//+kubebuilder:object:root=true
4855

4956
// AzureASOManagedMachinePoolList contains a list of AzureASOManagedMachinePool.

exp/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 49 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/controllers/azureasomanagedcluster_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context,
185185
if err != nil {
186186
return ctrl.Result{}, fmt.Errorf("failed to reconcile resources: %w", err)
187187
}
188+
for _, status := range asoManagedCluster.Status.Resources {
189+
if !status.Ready {
190+
return ctrl.Result{}, nil
191+
}
192+
}
188193

189194
return ctrl.Result{}, nil
190195
}
@@ -218,6 +223,9 @@ func (r *AzureASOManagedClusterReconciler) reconcileDelete(ctx context.Context,
218223
if err != nil {
219224
return ctrl.Result{}, fmt.Errorf("failed to reconcile resources: %w", err)
220225
}
226+
if len(asoManagedCluster.Status.Resources) > 0 {
227+
return ctrl.Result{}, nil
228+
}
221229

222230
controllerutil.RemoveFinalizer(asoManagedCluster, clusterv1.ClusterFinalizer)
223231
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)