Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions pkg/cloudprovider/provider/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ const (
awsMetadataHTTPPutResponseHopLimit = 3
)

var (
metricInstancesForMachines = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "machine_controller_aws_instances_for_machine",
Help: "The number of instances at aws for a given machine"}, []string{"machine"})
)
var metricInstancesForMachines = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "machine_controller_aws_instances_for_machine",
Help: "The number of instances at aws for a given machine",
}, []string{"machine"})

func init() {
metrics.Registry.MustRegister(metricInstancesForMachines)
Expand Down Expand Up @@ -115,18 +114,6 @@ var (
owner: "792107900819",
},
},
providerconfig.OperatingSystemAmazonLinux2: {
awstypes.CPUArchitectureX86_64: {
description: "Amazon Linux 2 AMI * x86_64 HVM gp2",
// The AWS marketplace ID from Amazon
owner: "137112412989",
},
awstypes.CPUArchitectureARM64: {
description: "Amazon Linux 2 LTS Arm64 AMI * arm64 HVM gp2",
// The AWS marketplace ID from Amazon
owner: "137112412989",
},
},
providerconfig.OperatingSystemUbuntu: {
awstypes.CPUArchitectureX86_64: {
// Be as precise as possible - otherwise we might get a nightly dev build
Expand Down Expand Up @@ -290,7 +277,6 @@ func getCPUArchitecture(ctx context.Context, client *ec2.Client, instanceType ec
instanceTypes, err := client.DescribeInstanceTypes(ctx, &ec2.DescribeInstanceTypesInput{
InstanceTypes: []ec2types.InstanceType{instanceType},
})

if err != nil {
return "", err
}
Expand Down Expand Up @@ -328,8 +314,6 @@ func getDefaultRootDevicePath(os providerconfig.OperatingSystem) (string, error)
return rootDevicePathSDA, nil
case providerconfig.OperatingSystemFlatcar:
return rootDevicePathXVDA, nil
case providerconfig.OperatingSystemAmazonLinux2:
return rootDevicePathXVDA, nil
}

return "", fmt.Errorf("no default root path found for %s operating system", os)
Expand Down Expand Up @@ -474,7 +458,6 @@ func getAwsConfig(ctx context.Context, id, secret, token, region, assumeRoleARN,
awsconfig.WithCredentialsProvider(awscredentials.NewStaticCredentialsProvider(id, secret, token)),
awsconfig.WithRetryMaxAttempts(maxRetries),
)

if err != nil {
return aws.Config{}, err
}
Expand Down Expand Up @@ -624,7 +607,6 @@ func getVpc(ctx context.Context, client *ec2.Client, id string) (*ec2types.Vpc,
{Name: aws.String("vpc-id"), Values: []string{id}},
},
})

if err != nil {
return nil, awsErrorToTerminalError(err, "failed to list vpc's")
}
Expand All @@ -641,7 +623,6 @@ func areVpcDNSHostnamesEnabled(ctx context.Context, client *ec2.Client, id strin
VpcId: &id,
Attribute: ec2types.VpcAttributeNameEnableDnsHostnames,
})

if err != nil {
return false, awsErrorToTerminalError(err, "failed to describe vpc attributes")
}
Expand Down Expand Up @@ -676,7 +657,6 @@ func (p *provider) Create(ctx context.Context, log *zap.SugaredLogger, machine *
if amiID == "" {
// read the instance type to know which cpu architecture is needed in the AMI
cpuArchitecture, err := getCPUArchitecture(ctx, ec2Client, config.InstanceType)

if err != nil {
return nil, cloudprovidererrors.TerminalError{
Reason: common.InvalidConfigurationMachineError,
Expand Down Expand Up @@ -819,7 +799,6 @@ func (p *provider) Cleanup(ctx context.Context, log *zap.SugaredLogger, machine

// (*Config, *providerconfig.Config, *awstypes.RawConfig, error)
config, _, _, err := p.getConfig(machine.Spec.ProviderSpec)

if err != nil {
return false, cloudprovidererrors.TerminalError{
Reason: common.InvalidConfigurationMachineError,
Expand All @@ -837,7 +816,6 @@ func (p *provider) Cleanup(ctx context.Context, log *zap.SugaredLogger, machine
cOut, err := ec2Client.CancelSpotInstanceRequests(ctx, &ec2.CancelSpotInstanceRequestsInput{
SpotInstanceRequestIds: []string{*ec2instance.instance.SpotInstanceRequestId},
})

if err != nil {
return false, awsErrorToTerminalError(err, "failed to cancel spot instance request")
}
Expand Down Expand Up @@ -946,7 +924,8 @@ func (p *provider) MigrateUID(ctx context.Context, _ *zap.SugaredLogger, machine

_, err = ec2Client.CreateTags(ctx, &ec2.CreateTagsInput{
Resources: []string{machineInstance.ID()},
Tags: []ec2types.Tag{{Key: aws.String(machineUIDTag), Value: aws.String(string(newUID))}}})
Tags: []ec2types.Tag{{Key: aws.String(machineUIDTag), Value: aws.String(string(newUID))}},
})
if err != nil {
return fmt.Errorf("failed to update instance with new machineUIDTag: %w", err)
}
Expand Down
16 changes: 8 additions & 8 deletions sdk/providerconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ import (
type OperatingSystem string

const (
OperatingSystemUbuntu OperatingSystem = "ubuntu"
OperatingSystemAmazonLinux2 OperatingSystem = "amzn2"
OperatingSystemRHEL OperatingSystem = "rhel"
OperatingSystemFlatcar OperatingSystem = "flatcar"
OperatingSystemRockyLinux OperatingSystem = "rockylinux"
OperatingSystemUbuntu OperatingSystem = "ubuntu"
OperatingSystemRHEL OperatingSystem = "rhel"
OperatingSystemFlatcar OperatingSystem = "flatcar"
OperatingSystemRockyLinux OperatingSystem = "rockylinux"
)

func (os OperatingSystem) Validate() error {
Expand Down Expand Up @@ -84,7 +83,6 @@ var (
// AllOperatingSystems is a slice containing all supported operating system identifiers.
AllOperatingSystems = []OperatingSystem{
OperatingSystemUbuntu,
OperatingSystemAmazonLinux2,
OperatingSystemRHEL,
OperatingSystemFlatcar,
OperatingSystemRockyLinux,
Expand Down Expand Up @@ -177,8 +175,10 @@ type GlobalObjectKeySelector struct {
Key string `json:"key,omitempty"`
}

type GlobalSecretKeySelector GlobalObjectKeySelector
type GlobalConfigMapKeySelector GlobalObjectKeySelector
type (
GlobalSecretKeySelector GlobalObjectKeySelector
GlobalConfigMapKeySelector GlobalObjectKeySelector
)

type ConfigVarString struct {
Value string `json:"value,omitempty"`
Expand Down
59 changes: 0 additions & 59 deletions sdk/userdata/amzn2/config.go

This file was deleted.

3 changes: 0 additions & 3 deletions sdk/userdata/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"

"k8c.io/machine-controller/sdk/providerconfig"
"k8c.io/machine-controller/sdk/userdata/amzn2"
"k8c.io/machine-controller/sdk/userdata/flatcar"
"k8c.io/machine-controller/sdk/userdata/rhel"
"k8c.io/machine-controller/sdk/userdata/rockylinux"
Expand All @@ -31,8 +30,6 @@ import (

func DefaultOperatingSystemSpec(os providerconfig.OperatingSystem, operatingSystemSpec runtime.RawExtension) (runtime.RawExtension, error) {
switch os {
case providerconfig.OperatingSystemAmazonLinux2:
return amzn2.DefaultConfig(operatingSystemSpec), nil
case providerconfig.OperatingSystemFlatcar:
return flatcar.DefaultConfig(operatingSystemSpec), nil
case providerconfig.OperatingSystemRHEL:
Expand Down
1 change: 0 additions & 1 deletion test/e2e/provisioning/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ var (

operatingSystems = []providerconfigtypes.OperatingSystem{
providerconfigtypes.OperatingSystemUbuntu,
providerconfigtypes.OperatingSystemAmazonLinux2,
providerconfigtypes.OperatingSystemRHEL,
providerconfigtypes.OperatingSystemFlatcar,
providerconfigtypes.OperatingSystemRockyLinux,
Expand Down