Skip to content

Commit 83f84c3

Browse files
committed
wip: testing, refactoring
1 parent 217f6eb commit 83f84c3

11 files changed

+45
-94
lines changed

api/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awsmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ type AWSMachineSpec struct {
228228
// +optional
229229
HostID *string `json:"hostID,omitempty"`
230230

231-
// Affinity specifies the dedicated host affinity setting for the instance.
232-
// When affinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
231+
// HostAffinity specifies the dedicated host affinity setting for the instance.
232+
// When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
233233
// +optional
234234
// +kubebuilder:validation:Enum:=Default;Host
235235
HostAffinity *string `json:"hostAffinity,omitempty"`

api/v1beta2/types.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,16 @@ type Instance struct {
274274
// +optional
275275
MarketType MarketType `json:"marketType,omitempty"`
276276

277-
// HostID specifies the dedicated host on which the instance should be started
277+
// HostAffinity specifies the dedicated host affinity setting for the instance.
278+
// When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
279+
// When HostAffinity is defined, HostID is required.
278280
// +optional
279-
HostID *string `json:"hostID,omitempty"`
281+
// +kubebuilder:validation:Enum:=Default;Host
282+
HostAffinity *string `json:"hostAffinity,omitempty"`
280283

281-
// Affinity specifies the dedicated host affinity setting for the instance.
284+
// HostID specifies the dedicated host on which the instance should be started
282285
// +optional
283-
HostAffinity *string `json:"hostAffinity,omitempty"`
286+
HostID *string `json:"hostID,omitempty"`
284287
}
285288

286289
// MarketType describes the market type of an Instance

api/v1beta2/zz_generated.deepcopy.go

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

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,13 @@ spec:
12141214
enabled.
12151215
type: boolean
12161216
hostAffinity:
1217-
description: Affinity specifies the dedicated host affinity setting
1218-
for the instance.
1217+
description: |-
1218+
HostAffinity specifies the dedicated host affinity setting for the instance.
1219+
When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
1220+
When HostAffinity is defined, HostID is required.
1221+
enum:
1222+
- Default
1223+
- Host
12191224
type: string
12201225
hostID:
12211226
description: HostID specifies the dedicated host on which the
@@ -3387,8 +3392,13 @@ spec:
33873392
enabled.
33883393
type: boolean
33893394
hostAffinity:
3390-
description: Affinity specifies the dedicated host affinity setting
3391-
for the instance.
3395+
description: |-
3396+
HostAffinity specifies the dedicated host affinity setting for the instance.
3397+
When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
3398+
When HostAffinity is defined, HostID is required.
3399+
enum:
3400+
- Default
3401+
- Host
33923402
type: string
33933403
hostID:
33943404
description: HostID specifies the dedicated host on which the

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,8 +2181,13 @@ spec:
21812181
enabled.
21822182
type: boolean
21832183
hostAffinity:
2184-
description: Affinity specifies the dedicated host affinity setting
2185-
for the instance.
2184+
description: |-
2185+
HostAffinity specifies the dedicated host affinity setting for the instance.
2186+
When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
2187+
When HostAffinity is defined, HostID is required.
2188+
enum:
2189+
- Default
2190+
- Host
21862191
type: string
21872192
hostID:
21882193
description: HostID specifies the dedicated host on which the

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ spec:
688688
type: object
689689
hostAffinity:
690690
description: |-
691-
Affinity specifies the dedicated host affinity setting for the instance.
692-
When affinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
691+
HostAffinity specifies the dedicated host affinity setting for the instance.
692+
When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
693693
enum:
694694
- Default
695695
- Host

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ spec:
622622
type: object
623623
hostAffinity:
624624
description: |-
625-
Affinity specifies the dedicated host affinity setting for the instance.
626-
When affinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
625+
HostAffinity specifies the dedicated host affinity setting for the instance.
626+
When hostAffinity is set to Host, an instance started onto a specific host always restarts on the same host if stopped.
627627
enum:
628628
- Default
629629
- Host

pkg/cloud/services/ec2/instances.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,10 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan
686686
"hostId", i.HostID,
687687
"affinity", i.HostAffinity)
688688
if input.Placement != nil {
689-
placementStr := input.Placement.GoString()
690689
s.scope.Warn("Placement already set for instance, overwriting with dedicated host placement",
691690
"hostId", i.HostID,
692691
"affinity", i.HostAffinity,
693-
"placement", placementStr)
692+
"placement", input.Placement.GoString())
694693
}
695694

696695
input.Placement = &ec2.Placement{

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,7 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
986986

987987
ginkgo.By("Creating cluster")
988988
clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6))
989-
vars := map[string]string{
990-
"HOST_ID": hostID,
991-
"HOST_AFFINITY": "Default",
992-
}
989+
993990
// Create a cluster with a dedicated host
994991
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
995992
ClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
@@ -1004,7 +1001,10 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
10041001
KubernetesVersion: e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion),
10051002
ControlPlaneMachineCount: ptr.To[int64](1),
10061003
WorkerMachineCount: ptr.To[int64](0),
1007-
ClusterctlVariables: vars,
1004+
ClusterctlVariables: map[string]string{
1005+
"HOST_ID": hostID,
1006+
"HOST_AFFINITY": "Default",
1007+
},
10081008
},
10091009
WaitForClusterIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-cluster"),
10101010
WaitForControlPlaneIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-control-plane"),

0 commit comments

Comments
 (0)