Skip to content

Commit

Permalink
VCDA-3502: Add parentUid and useAsManagementCluster support for v1bet…
Browse files Browse the repository at this point in the history
…a1 VCDCluster (vmware#98)

* Add 2 new fields to vcdcluster, renamed duplicate field in types

Signed-off-by: lzichong <[email protected]>

* Read new specs into RDE.Capvcd.Status, update new fields RDE reconcilation

Signed-off-by: lzichong <[email protected]>

* add default values from v1alpha1 to v1beta1, regenerated conversion gen

Signed-off-by: lzichong <[email protected]>

* Revert back to IsManagementCluster in types.go to match RDE schema

Signed-off-by: lzichong <[email protected]>

* Merged recent changes from main to resolve merge conflicts

Signed-off-by: lzichong <[email protected]>

* Addressed comments and added TODO to conversion

Signed-off-by: lzichong <[email protected]>

* Updated Status params with Spec, update RDE to match Status instead of Spec

Signed-off-by: lzichong <[email protected]>
  • Loading branch information
lzichong authored Apr 21, 2022
1 parent 6f041a9 commit 5e333c5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
5 changes: 4 additions & 1 deletion api/v1alpha4/vcdcluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ func (src *VCDCluster) ConvertTo(dstRaw conversion.Hub) error {
return err
}
dst.Spec.DefaultStorageClassOptions = &v1beta1.DefaultStorageClassOptions{}
dst.Spec.RDEId = ""
// TODO: Update the new params to match previous release's Status; ex) dst.Spec.* = src.Status.*, maybe RDE.Status
dst.Spec.RDEId = src.Status.InfraId
dst.Spec.ParentUID = ""
dst.Spec.UseAsManagementCluster = false // defaults to false
return nil
}

Expand Down
7 changes: 5 additions & 2 deletions api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/v1beta1/vcdcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ type VCDClusterSpec struct {
DefaultComputePolicy string `json:"defaultComputePolicy,omitempty"`
// + optional
RDEId string `json:"rdeId,omitempty"`
// +optional
ParentUID string `json:"parentUid,omitempty"`
// +optional
UseAsManagementCluster bool `json:"useAsManagementCluster,omitempty"`
}

// VCDClusterStatus defines the observed state of VCDCluster
Expand All @@ -93,6 +97,10 @@ type VCDClusterStatus struct {
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
// +optional
InfraId string `json:"infraId,omitempty"`
// +optional
ParentUID string `json:"parentUid,omitempty"`
// +optional
UseAsManagementCluster bool `json:"useAsManagementCluster,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
16 changes: 12 additions & 4 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_vcdclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ spec:
type: string
ovdcNetwork:
type: string
parentUid:
type: string
rdeId:
type: string
site:
type: string
useAsManagementCluster:
type: boolean
userContext:
properties:
password:
Expand Down Expand Up @@ -264,14 +268,18 @@ spec:
type: array
infraId:
type: string
VAppMetadataUpdated:
description: MetadataUpdated denotes that the metadata of Vapp is
updated.
type: boolean
parentUid:
type: string
ready:
description: Ready denotes that the vcd cluster (infrastructure) is
ready.
type: boolean
useAsManagementCluster:
type: boolean
vappmetadataUpdated:
description: MetadataUpdated denotes that the metadata of Vapp is
updated.
type: boolean
required:
- ready
type: object
Expand Down
17 changes: 15 additions & 2 deletions controllers/vcdcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ func (r *VCDClusterReconciler) constructCapvcdRDE(ctx context.Context, cluster *
ApiEndpoints: []vcdtypes.ApiEndpoints{},
},
NodeStatus: make(map[string]string),
IsManagementCluster: false,
IsManagementCluster: vcdCluster.Spec.UseAsManagementCluster,
CapvcdVersion: r.Config.ClusterResources.CapvcdVersion,
ParentUID: r.Config.ManagementClusterRDEId,
ParentUID: vcdCluster.Spec.ParentUID,
Csi: vcdtypes.VersionedAddon{
Name: VcdCsiName,
Version: r.Config.ClusterResources.CsiVersion, // TODO: get CPI, CNI, CSI versions from the CLusterResourceSet objects
Expand Down Expand Up @@ -394,6 +394,15 @@ func (r *VCDClusterReconciler) reconcileRDE(ctx context.Context, cluster *cluste
if capvcdEntity.Status.Phase != cluster.Status.Phase {
updatePatch["Status.Phase"] = cluster.Status.Phase
}

if capvcdEntity.Status.ParentUID != vcdCluster.Status.ParentUID {
updatePatch["Status.ParentUID"] = vcdCluster.Status.ParentUID
}

if capvcdEntity.Status.IsManagementCluster != vcdCluster.Status.UseAsManagementCluster {
updatePatch["Status.IsManagementCluster"] = vcdCluster.Status.UseAsManagementCluster
}

clusterApiStatusPhase := ClusterApiStatusPhaseNotReady
if cluster.Status.ControlPlaneReady {
clusterApiStatusPhase = ClusterApiStatusPhaseReady
Expand Down Expand Up @@ -551,6 +560,10 @@ func (r *VCDClusterReconciler) reconcileNormal(ctx context.Context, cluster *clu
workloadVCDClient.ClusterID = infraID
}

// After InfraId has been set, we can update parentUid, useAsMgmtCluster status
vcdCluster.Status.UseAsManagementCluster = vcdCluster.Spec.UseAsManagementCluster
vcdCluster.Status.ParentUID = vcdCluster.Spec.ParentUID

// create load balancer for the cluster. Only one-arm load balancer is fully tested.
virtualServiceNamePrefix := vcdCluster.Name + "-" + vcdCluster.Status.InfraId
lbPoolNamePrefix := vcdCluster.Name + "-" + vcdCluster.Status.InfraId
Expand Down

0 comments on commit 5e333c5

Please sign in to comment.