Skip to content

Commit

Permalink
fix(aws): Fixing bugs related to clone CX when instance types are inc…
Browse files Browse the repository at this point in the history
…ompatible with image/region (spinnaker#9901)

* fix(aws): Fixing bugs related to clone UX when instance types are incompatible with image/region

Displaying warnings when incompatible instance types are removed

spinnaker/spinnaker#6734

* fix(aws): PR feedback

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and Cameron Motevasselani committed Apr 17, 2023
1 parent 6890cfc commit c59aa39
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,28 @@ export class AwsServerGroupConfigurationService {
command.amiArchitecture,
);
}

const filteredTypes: string[] = map(filteredTypesInfo, 'name');

// handle incompatibility for single instance type case
if (command.instanceType && !filteredTypes.includes(command.instanceType)) {
result.dirty.instanceType = command.instanceType;
command.instanceType = null;
}

// handle incompatibility for multiple instance types case
const multipleInstanceTypes: string[] = map(command.launchTemplateOverridesForInstanceType, 'instanceType');
const validInstanceTypes: string[] = intersection(multipleInstanceTypes, filteredTypes);
const invalidInstanceTypes: string[] = difference(multipleInstanceTypes, validInstanceTypes);

if (command.launchTemplateOverridesForInstanceType && invalidInstanceTypes.length > 0) {
result.dirty.launchTemplateOverridesForInstanceType = command.launchTemplateOverridesForInstanceType.filter(
(it) => invalidInstanceTypes.includes(it.instanceType),
);
command.launchTemplateOverridesForInstanceType = command.launchTemplateOverridesForInstanceType.filter((it) =>
validInstanceTypes.includes(it.instanceType),
);
}

command.backingData.filtered.instanceTypes = filteredTypes;
command.backingData.filtered.instanceTypesInfo = filteredTypesInfo;
} else {
Expand Down

0 comments on commit c59aa39

Please sign in to comment.