Skip to content

Commit e68bfb6

Browse files
committed
Refine logic for determining if an instance needs to be updated, added a
location field to instances so the information does not need to be looked up in the controller. Also introduced scheduling gates, and a field to store a hash for the instance template last applied to the instance.
1 parent dc6049e commit e68bfb6

11 files changed

+378
-44
lines changed

api/v1alpha/instance_types.go

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,37 @@ type InstanceSpec struct {
2626
// +kubebuilder:validation:Optional
2727
// +listType=map
2828
// +listMapKey=name
29-
3029
Volumes []InstanceVolume `json:"volumes,omitempty"`
30+
31+
// The location which the instance has been scheduled to
32+
//
33+
// +kubebuilder:validation:Optional
34+
Location *networkingv1alpha.LocationReference `json:"location,omitempty"`
35+
36+
// Controller contains settings driven by the controller managing the instance.
37+
//
38+
// +kubebuilder:validation:Optional
39+
Controller *InstanceController `json:"controller,omitempty"`
40+
}
41+
42+
type InstanceController struct {
43+
// TemplateHash is the hash of the instance template applied for this instance.
44+
//
45+
// +kubebuilder:validation:Required
46+
TemplateHash string `json:"templateHash"`
47+
48+
// SchedulingGates is a list of gates that must be satisfied before the
49+
// instance can be scheduled.
50+
//
51+
// +kubebuilder:validation:Optional
52+
// +listType=map
53+
// +listMapKey=name
54+
SchedulingGates []SchedulingGate `json:"schedulingGates,omitempty"`
55+
}
56+
57+
type SchedulingGate struct {
58+
// The name of the gate.
59+
Name string `json:"name"`
3160
}
3261

3362
type InstanceRuntimeSpec struct {
@@ -337,6 +366,18 @@ type InstanceStatus struct {
337366

338367
// Network interface information
339368
NetworkInterfaces []InstanceNetworkInterfaceStatus `json:"networkInterfaces,omitempty"`
369+
370+
// Controller contains status information about the controller managing the instance.
371+
//
372+
// +kubebuilder:validation:Optional
373+
Controller *InstanceControllerStatus `json:"controller,omitempty"`
374+
}
375+
376+
type InstanceControllerStatus struct {
377+
// ObservedTemplateHash is the hash of the instance template applied for this instance.
378+
//
379+
// +kubebuilder:validation:Required
380+
ObservedTemplateHash string `json:"observedTemplateHash"`
340381
}
341382

342383
const (
@@ -368,7 +409,12 @@ type Instance struct {
368409
metav1.TypeMeta `json:",inline"`
369410
metav1.ObjectMeta `json:"metadata,omitempty"`
370411

371-
Spec InstanceSpec `json:"spec,omitempty"`
412+
// Spec defines the desired state of an Instance.
413+
Spec InstanceSpec `json:"spec,omitempty"`
414+
415+
// Status defines the current state of an Instance.
416+
//
417+
// +kubebuilder:default={conditions:{{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
372418
Status InstanceStatus `json:"status,omitempty"`
373419
}
374420

api/v1alpha/workload_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ type HorizontalScaleSettings struct {
167167
// See https://github.com/kubernetes/kubernetes/blob/dd87bc064631354885193fc1a97d0e7b603e77b4/staging/src/k8s.io/api/autoscaling/v2/types.go#L84
168168
// Defines the policy for managing instances.
169169

170+
// TODO(jreese) Add instance update policy? RollingUpdate vs OrderedReady
171+
170172
// Controls how instances are managed during scale up and down, as well as
171173
// during maintenance events.
172174
//

api/v1alpha/zz_generated.deepcopy.go

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

config/crd/bases/compute.datumapis.com_instances.yaml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,48 @@ spec:
5555
metadata:
5656
type: object
5757
spec:
58-
description: InstanceSpec defines the desired state of Instance
58+
description: Spec defines the desired state of an Instance.
5959
properties:
60+
controller:
61+
description: Controller contains settings driven by the controller
62+
managing the instance.
63+
properties:
64+
schedulingGates:
65+
description: |-
66+
SchedulingGates is a list of gates that must be satisfied before the
67+
instance can be scheduled.
68+
items:
69+
properties:
70+
name:
71+
description: The name of the gate.
72+
type: string
73+
required:
74+
- name
75+
type: object
76+
type: array
77+
x-kubernetes-list-map-keys:
78+
- name
79+
x-kubernetes-list-type: map
80+
templateHash:
81+
description: TemplateHash is the hash of the instance template
82+
applied for this instance.
83+
type: string
84+
required:
85+
- templateHash
86+
type: object
87+
location:
88+
description: The location which the instance has been scheduled to
89+
properties:
90+
name:
91+
description: Name of a datum location
92+
type: string
93+
namespace:
94+
description: Namespace for the datum location
95+
type: string
96+
required:
97+
- name
98+
- namespace
99+
type: object
60100
networkInterfaces:
61101
description: Network interface configuration.
62102
items:
@@ -519,6 +559,9 @@ spec:
519559
- resources
520560
type: object
521561
volumes:
562+
description: |-
563+
Volumes that must be available to attach to an instance's containers or
564+
Virtual Machine.
522565
items:
523566
properties:
524567
configMap:
@@ -766,7 +809,14 @@ spec:
766809
- runtime
767810
type: object
768811
status:
769-
description: InstanceStatus defines the observed state of Instance
812+
default:
813+
conditions:
814+
- lastTransitionTime: "1970-01-01T00:00:00Z"
815+
message: Waiting for controller
816+
reason: Pending
817+
status: Unknown
818+
type: Ready
819+
description: Status defines the current state of an Instance.
770820
properties:
771821
conditions:
772822
description: |-
@@ -827,6 +877,17 @@ spec:
827877
- type
828878
type: object
829879
type: array
880+
controller:
881+
description: Controller contains status information about the controller
882+
managing the instance.
883+
properties:
884+
observedTemplateHash:
885+
description: ObservedTemplateHash is the hash of the instance
886+
template applied for this instance.
887+
type: string
888+
required:
889+
- observedTemplateHash
890+
type: object
830891
networkInterfaces:
831892
description: Network interface information
832893
items:

config/crd/bases/compute.datumapis.com_workloaddeployments.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,47 @@ spec:
155155
spec:
156156
description: Describes the desired configuration of an instance
157157
properties:
158+
controller:
159+
description: Controller contains settings driven by the controller
160+
managing the instance.
161+
properties:
162+
schedulingGates:
163+
description: |-
164+
SchedulingGates is a list of gates that must be satisfied before the
165+
instance can be scheduled.
166+
items:
167+
properties:
168+
name:
169+
description: The name of the gate.
170+
type: string
171+
required:
172+
- name
173+
type: object
174+
type: array
175+
x-kubernetes-list-map-keys:
176+
- name
177+
x-kubernetes-list-type: map
178+
templateHash:
179+
description: TemplateHash is the hash of the instance
180+
template applied for this instance.
181+
type: string
182+
required:
183+
- templateHash
184+
type: object
185+
location:
186+
description: The location which the instance has been scheduled
187+
to
188+
properties:
189+
name:
190+
description: Name of a datum location
191+
type: string
192+
namespace:
193+
description: Namespace for the datum location
194+
type: string
195+
required:
196+
- name
197+
- namespace
198+
type: object
158199
networkInterfaces:
159200
description: Network interface configuration.
160201
items:
@@ -628,6 +669,9 @@ spec:
628669
- resources
629670
type: object
630671
volumes:
672+
description: |-
673+
Volumes that must be available to attach to an instance's containers or
674+
Virtual Machine.
631675
items:
632676
properties:
633677
configMap:

config/crd/bases/compute.datumapis.com_workloads.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,47 @@ spec:
164164
spec:
165165
description: Describes the desired configuration of an instance
166166
properties:
167+
controller:
168+
description: Controller contains settings driven by the controller
169+
managing the instance.
170+
properties:
171+
schedulingGates:
172+
description: |-
173+
SchedulingGates is a list of gates that must be satisfied before the
174+
instance can be scheduled.
175+
items:
176+
properties:
177+
name:
178+
description: The name of the gate.
179+
type: string
180+
required:
181+
- name
182+
type: object
183+
type: array
184+
x-kubernetes-list-map-keys:
185+
- name
186+
x-kubernetes-list-type: map
187+
templateHash:
188+
description: TemplateHash is the hash of the instance
189+
template applied for this instance.
190+
type: string
191+
required:
192+
- templateHash
193+
type: object
194+
location:
195+
description: The location which the instance has been scheduled
196+
to
197+
properties:
198+
name:
199+
description: Name of a datum location
200+
type: string
201+
namespace:
202+
description: Namespace for the datum location
203+
type: string
204+
required:
205+
- name
206+
- namespace
207+
type: object
167208
networkInterfaces:
168209
description: Network interface configuration.
169210
items:
@@ -637,6 +678,9 @@ spec:
637678
- resources
638679
type: object
639680
volumes:
681+
description: |-
682+
Volumes that must be available to attach to an instance's containers or
683+
Virtual Machine.
640684
items:
641685
properties:
642686
configMap:

0 commit comments

Comments
 (0)