Skip to content

Commit c6097f5

Browse files
test
1 parent 15d3232 commit c6097f5

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

api/v1beta2/awsmachinetemplate_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const (
3535
ArchitectureArm64 Architecture = "arm64"
3636
)
3737

38+
// Operating system constants.
39+
const (
40+
// OperatingSystemLinux represents the Linux operating system.
41+
OperatingSystemLinux = "linux"
42+
// OperatingSystemWindows represents the Windows operating system.
43+
OperatingSystemWindows = "windows"
44+
)
45+
3846
// NodeInfo contains information about the node's architecture and operating system.
3947
type NodeInfo struct {
4048
// Architecture is the CPU architecture of the node.

controllers/awsmachinetemplate_controller.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,22 +225,20 @@ func (r *AWSMachineTemplateReconciler) getNodeInfoFromAMI(ctx context.Context, e
225225
arch = infrav1.ArchitectureArm64
226226
}
227227

228-
// Determine OS - check Platform field first (specifically for Windows identification)
229-
var os string
228+
// Determine OS - default to Linux, change to Windows if detected
229+
// Most AMIs are Linux-based, so we initialize with Linux as the default
230+
os := infrav1.OperatingSystemLinux
230231

231232
// 1. Check Platform field (most reliable for Windows detection)
232233
if image.Platform == ec2types.PlatformValuesWindows {
233-
os = "windows"
234+
os = infrav1.OperatingSystemWindows
234235
}
235236

236-
// 2. Check PlatformDetails field (provides more detailed information)
237-
if os == "" && image.PlatformDetails != nil {
237+
// 2. Check PlatformDetails field for Windows indication
238+
if os != infrav1.OperatingSystemWindows && image.PlatformDetails != nil {
238239
platformDetails := strings.ToLower(*image.PlatformDetails)
239-
switch {
240-
case strings.Contains(platformDetails, "windows"):
241-
os = "windows"
242-
case strings.Contains(platformDetails, "linux"), strings.Contains(platformDetails, "unix"):
243-
os = "linux"
240+
if strings.Contains(platformDetails, infrav1.OperatingSystemWindows) {
241+
os = infrav1.OperatingSystemWindows
244242
}
245243
}
246244

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
337337
configCluster.ControlPlaneMachineCount = ptr.To[int64](1)
338338
configCluster.WorkerMachineCount = ptr.To[int64](1)
339339
configCluster.Flavor = shared.SSMFlavor
340-
_, md, _ := createCluster(ctx, configCluster, result)
340+
cluster, md, _ := createCluster(ctx, configCluster, result)
341341

342342
workerMachines := framework.GetMachinesByMachineDeployments(ctx, framework.GetMachinesByMachineDeploymentsInput{
343343
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
@@ -359,6 +359,17 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
359359
Expect(err).To(BeNil())
360360
Expect(len(awsMachineTemplateList.Items)).To(BeNumerically(">", 0), "Expected at least one AWSMachineTemplate")
361361

362+
ginkgo.By(fmt.Sprintf("Found %d AWSMachineTemplates", len(awsMachineTemplateList.Items)))
363+
ginkgo.By(fmt.Sprintf("Cluster: name=%s, namespace=%s, infrastructureRef=%v",
364+
cluster.Name, cluster.Namespace, cluster.Spec.InfrastructureRef))
365+
366+
// Print each AWSMachineTemplate for debugging
367+
for i, template := range awsMachineTemplateList.Items {
368+
ginkgo.By(fmt.Sprintf("AWSMachineTemplate[%d]: name=%s, instanceType=%s, labels=%v, ownerRefs=%v, capacity=%v, nodeInfo=%v",
369+
i, template.Name, template.Spec.Template.Spec.InstanceType,
370+
template.Labels, template.OwnerReferences, template.Status.Capacity, template.Status.NodeInfo))
371+
}
372+
362373
foundTemplateWithCapacity := false
363374
foundTemplateWithNodeInfo := false
364375
for _, template := range awsMachineTemplateList.Items {

0 commit comments

Comments
 (0)