Skip to content

Commit 817435f

Browse files
committed
controller: create components with Overrides and MinHealthy when create an application with components
1 parent 0ff67e7 commit 817435f

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

apis/v1/types.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ type ApplicationSpec struct {
4242

4343
// ComponentRef references a Component within an Application
4444
type ComponentRef struct {
45-
Name string `json:"name" yaml:"name"` // Component name
46-
VirtualMachineSpec string `json:"virtualMachineSpec" yaml:"virtualMachineSpec"` // Reusable VM spec name
47-
Replicas int `json:"replicas" yaml:"replicas"` // Number of VM replicas
48-
HealthChecks []HealthCheck `json:"healthChecks,omitempty" yaml:"healthChecks,omitempty" gorm:"serializer:json"`
45+
Name string `json:"name" yaml:"name"` // Component name
46+
VirtualMachineSpec string `json:"virtualMachineSpec" yaml:"virtualMachineSpec"` // Reusable VM spec name
47+
Replicas int `json:"replicas" yaml:"replicas"` // Number of VM replicas
48+
// MinHealthy defines the minimum number of healthy VMs required for the component to be
49+
// considered healthy. If zero, defaults to Replicas. Propagated to the Component record.
50+
MinHealthy int `json:"minHealthy,omitempty" yaml:"minHealthy,omitempty"`
51+
HealthChecks []HealthCheck `json:"healthChecks,omitempty" yaml:"healthChecks,omitempty" gorm:"serializer:json"`
52+
// Overrides allows per-component overrides (e.g. serviceOffering, userDataRefs) defined
53+
// inline inside the Application spec, propagated to the Component record on creation.
54+
Overrides ComponentOverrides `json:"overrides,omitempty" yaml:"overrides,omitempty" gorm:"serializer:json"`
4955
// DependsOn lists component names this component depends on. If set,
5056
// the reconciler will wait for the named components to be healthy
5157
// before creating or reconciling this component. Values may be a

controller/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ func ensureComponentsForApplication(app *v1.Application) error {
889889
Spec: v1.ComponentSpec{
890890
VirtualMachineSpec: cref.VirtualMachineSpec,
891891
Replicas: cref.Replicas,
892+
MinHealthy: cref.MinHealthy,
892893
HealthChecks: cref.HealthChecks,
894+
Overrides: cref.Overrides,
893895
},
894896
Status: v1.Status{ObservedState: "Starting", Ready: false, LastChecked: time.Now()},
895897
Application: app.Metadata.Name,

0 commit comments

Comments
 (0)