Skip to content

Commit 2caf94c

Browse files
committed
controller: apply application.yaml and reconcile
1 parent 0aa2f10 commit 2caf94c

7 files changed

Lines changed: 587 additions & 165 deletions

File tree

apis/v1/types.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ type ComponentRef struct {
4646
VirtualMachineSpec string `json:"virtualMachineSpec" yaml:"virtualMachineSpec"` // Reusable VM spec name
4747
Replicas int `json:"replicas" yaml:"replicas"` // Number of VM replicas
4848
HealthChecks []HealthCheck `json:"healthChecks,omitempty" yaml:"healthChecks,omitempty" gorm:"serializer:json"`
49+
// DependsOn lists component names this component depends on. If set,
50+
// the reconciler will wait for the named components to be healthy
51+
// before creating or reconciling this component. Values may be a
52+
// comma-separated string when provided in YAML/JSON.
53+
DependsOn string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"`
4954
}
5055

5156
// HealthCheck defines a simple health check configuration for VMs
@@ -65,6 +70,8 @@ type Component struct {
6570
Metadata Metadata `json:"metadata" yaml:"metadata" gorm:"embedded"`
6671
Spec ComponentSpec `json:"spec" yaml:"spec" gorm:"embedded"`
6772
Status Status `json:"status,omitempty" gorm:"embedded"`
73+
// Application links this Component to a parent Application (store application name or id)
74+
Application string `json:"application,omitempty" yaml:"application,omitempty" gorm:"column:application"`
6875
// EffectiveSpec stores the resolved VM spec after merging overrides (persisted for visibility)
6976
EffectiveSpec VirtualMachineSpec `json:"effectiveSpec,omitempty" yaml:"effectiveSpec,omitempty" gorm:"serializer:json"`
7077
// ObservedReplicas tracks how many VMs are currently observed for this component
@@ -73,10 +80,13 @@ type Component struct {
7380

7481
// ComponentSpec defines the desired state of a Component
7582
type ComponentSpec struct {
76-
VirtualMachineSpec string `json:"virtualMachineSpec" yaml:"virtualMachineSpec"` // Reusable VM spec name
77-
Replicas int `json:"replicas" yaml:"replicas"` // Number of VM replicas
78-
Overrides ComponentOverrides `json:"overrides,omitempty" yaml:"overrides,omitempty" gorm:"serializer:json"`
79-
HealthChecks []HealthCheck `json:"healthChecks,omitempty" yaml:"healthChecks,omitempty" gorm:"serializer:json"`
83+
VirtualMachineSpec string `json:"virtualMachineSpec" yaml:"virtualMachineSpec"` // Reusable VM spec name
84+
Replicas int `json:"replicas" yaml:"replicas"` // Number of VM replicas
85+
// MinHealthy defines the minimum number of healthy VMs required for the
86+
// component to be considered healthy. If zero, defaults to `Replicas`.
87+
MinHealthy int `json:"minHealthy,omitempty" yaml:"minHealthy,omitempty"`
88+
Overrides ComponentOverrides `json:"overrides,omitempty" yaml:"overrides,omitempty" gorm:"serializer:json"`
89+
HealthChecks []HealthCheck `json:"healthChecks,omitempty" yaml:"healthChecks,omitempty" gorm:"serializer:json"`
8090
}
8191

8292
// ComponentOverrides allows limited, safe overrides to a reused VM spec
@@ -100,10 +110,10 @@ type VirtualMachine struct {
100110
Status Status `json:"status,omitempty" gorm:"embedded"`
101111
// ObservedSpec stores the configuration fetched from CloudStack (observed state)
102112
ObservedSpec VirtualMachineSpec `json:"observedSpec,omitempty" yaml:"observedSpec,omitempty" gorm:"serializer:json"`
103-
// ApplicationID links this VM to a parent Application (store application name or id)
104-
ApplicationID string `json:"applicationId,omitempty" yaml:"applicationId,omitempty" gorm:"column:application_id"`
105-
// ComponentID links this VM to a parent Component (store component name or id)
106-
ComponentID string `json:"componentId,omitempty" yaml:"componentId,omitempty" gorm:"column:component_id"`
113+
// Application links this VM to a parent Application (store application name or id)
114+
Application string `json:"application,omitempty" yaml:"application,omitempty" gorm:"column:application"`
115+
// Component links this VM to a parent Component (store component name or id)
116+
Component string `json:"component,omitempty" yaml:"component,omitempty" gorm:"column:component"`
107117
// CloudStackID is the external provider ID for this VM in CloudStack
108118
CloudStackID string `json:"cloudStackId,omitempty" yaml:"cloudStackId,omitempty" gorm:"column:cloudstack_id"`
109119
}

0 commit comments

Comments
 (0)