Skip to content

Commit

Permalink
Merge pull request #99 from jwcesign/fix-flannel
Browse files Browse the repository at this point in the history
fix: report error if image not found
  • Loading branch information
helen-frank authored Nov 7, 2024
2 parents ff05685 + 2e5631c commit 449c836
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ func (p *DefaultProvider) getProvisioningGroup(ctx context.Context, nodeClass *v
systemDisk = imagefamily.DefaultSystemDisk.DeepCopy()
}

imageID, ok := mappedImages[instanceTypes[0].Name]
if !ok {
return nil, errors.New("matching image not found")
}

createAutoProvisioningGroupRequest := &ecsclient.CreateAutoProvisioningGroupRequest{
RegionId: tea.String(p.region),
TotalTargetCapacity: tea.String("1"),
Expand All @@ -472,7 +477,7 @@ func (p *DefaultProvider) getProvisioningGroup(ctx context.Context, nodeClass *v
AutoProvisioningGroupType: tea.String("instant"),
LaunchConfiguration: &ecsclient.CreateAutoProvisioningGroupRequestLaunchConfiguration{
// TODO: we should set image id for each instance types after alibabacloud supports
ImageId: tea.String(mappedImages[instanceTypes[0].Name]),
ImageId: tea.String(imageID),
SecurityGroupIds: securityGroupIDs,
UserData: tea.String(userData),

Expand Down
7 changes: 4 additions & 3 deletions pkg/providers/instancetype/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const (
MemoryAvailable = "memory.available"
NodeFSAvailable = "nodefs.available"

GiBMiBRatio = 1024 * 1024
GiBMiBRatio = 1024
MiBByteRatio = 1024 * 1024
TerwayMinENIRequirements = 11
BaseHostNetworkPods = 3
FlannelDefaultPods = 256
Expand Down Expand Up @@ -116,7 +117,7 @@ func computeRequirements(info *ecsclient.DescribeInstanceTypesResponseBodyInstan
// Well Known to AlibabaCloud
scheduling.NewRequirement(v1alpha1.LabelInstanceCPU, corev1.NodeSelectorOpIn, fmt.Sprint(*info.CpuCoreCount)),
scheduling.NewRequirement(v1alpha1.LabelInstanceCPUModel, corev1.NodeSelectorOpDoesNotExist),
scheduling.NewRequirement(v1alpha1.LabelInstanceMemory, corev1.NodeSelectorOpIn, fmt.Sprint(*info.MemorySize)),
scheduling.NewRequirement(v1alpha1.LabelInstanceMemory, corev1.NodeSelectorOpIn, fmt.Sprint(*info.MemorySize*GiBMiBRatio)),
scheduling.NewRequirement(v1alpha1.LabelInstanceCategory, corev1.NodeSelectorOpDoesNotExist),
scheduling.NewRequirement(v1alpha1.LabelInstanceFamily, corev1.NodeSelectorOpDoesNotExist),
scheduling.NewRequirement(v1alpha1.LabelInstanceGeneration, corev1.NodeSelectorOpDoesNotExist),
Expand Down Expand Up @@ -272,7 +273,7 @@ func memory(ctx context.Context, info *ecsclient.DescribeInstanceTypesResponseBo
return mem
}
// Account for VM overhead in calculation
mem.Sub(resource.MustParse(fmt.Sprintf("%dMi", int64(math.Ceil(float64(mem.Value())*options.FromContext(ctx).VMMemoryOverheadPercent/GiBMiBRatio)))))
mem.Sub(resource.MustParse(fmt.Sprintf("%dMi", int64(math.Ceil(float64(mem.Value())*options.FromContext(ctx).VMMemoryOverheadPercent/MiBByteRatio)))))
return mem
}

Expand Down

0 comments on commit 449c836

Please sign in to comment.