Skip to content

Commit

Permalink
Fixed issue with running mac nodes on AWS (#56)
Browse files Browse the repository at this point in the history
* Fixed a small issue during running an actual mac machine using AWS provider.
* Also btw fixed sed command during the build on mac, because was incompatible with BSD sed.
  • Loading branch information
sparshev committed Nov 10, 2023
1 parent 169c4ac commit bd3dd05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ PATH="$gopath/bin:$PATH" go generate -v ./lib/...
# Making LabelDefinitions an actual type to attach GORM-needed Scanner/Valuer functions to it to
# make the array a json document and store in the DB row as one item
# TODO: https://github.com/deepmap/oapi-codegen/issues/859
sed -i 's/^type LabelDefinitions = /type LabelDefinitions /' lib/openapi/types/types.gen.go
sed -i.bak 's/^type LabelDefinitions = /type LabelDefinitions /' lib/openapi/types/types.gen.go
rm -f lib/openapi/types/types.gen.go.bak

# Prepare version number as overrides during link
mod_name=$(grep '^module' "${root_dir}/go.mod" | cut -d' ' -f 2)
Expand Down
11 changes: 9 additions & 2 deletions lib/drivers/aws/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (d *Driver) AvailableCapacity(node_usage types.Resources, def types.LabelDe

// Dedicated hosts
// For now operated only on pre-created dedicated machines pool
if opts.InstanceType == "mac1" || opts.InstanceType == "mac2" {
if awsInstTypeAny(opts.InstanceType, "mac") {
// Ensure we have the available (not busy) dedicated hosts to use as base for resource.
// For now we're not creating new dedicated hosts dynamically because they can be
// terminated only after 24h which costs a pretty penny.
Expand All @@ -127,7 +127,7 @@ func (d *Driver) AvailableCapacity(node_usage types.Resources, def types.LabelDe
Filter: []ec2_types.Filter{
ec2_types.Filter{
Name: aws.String("instance-type"),
Values: []string{fmt.Sprintf("%s.metal", opts.InstanceType)},
Values: []string{opts.InstanceType},
},
ec2_types.Filter{
Name: aws.String("state"),
Expand Down Expand Up @@ -274,6 +274,13 @@ func (d *Driver) Allocate(def types.LabelDefinition, metadata map[string]any) (*
MaxCount: aws.Int32(1),
}

// For mac machines only dedicated hosts are working, so set the tenancy
if awsInstTypeAny(opts.InstanceType, "mac") {
input.Placement = &ec2_types.Placement{
Tenancy: ec2_types.TenancyHost,
}
}

if opts.UserDataFormat != "" {
// Set UserData field
userdata, err := util.SerializeMetadata(opts.UserDataFormat, opts.UserDataPrefix, metadata)
Expand Down

0 comments on commit bd3dd05

Please sign in to comment.