From 179dea6865fcc23365e8d92bfa1f6e2e72d6a6f9 Mon Sep 17 00:00:00 2001 From: Moath Qasim Date: Fri, 25 Feb 2022 16:24:57 +0100 Subject: [PATCH] validate max price in spot instance request Signed-off-by: Moath Qasim --- pkg/cloudprovider/provider/aws/provider.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cloudprovider/provider/aws/provider.go b/pkg/cloudprovider/provider/aws/provider.go index 00bad52ca..c9e243043 100644 --- a/pkg/cloudprovider/provider/aws/provider.go +++ b/pkg/cloudprovider/provider/aws/provider.go @@ -633,6 +633,12 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error { return fmt.Errorf("failed to validate instance profile: %v", err) } + if config.IsSpotInstance != nil && *config.IsSpotInstance { + if config.SpotMaxPrice == nil { + return errors.New("failed to validate max price for the spot instance: max price cannot be empty when spot instance ") + } + } + return nil }