mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(ecs): apply cluster settings given on CreateCluster (#2845)
handleCreateCluster read clusterName and tags and nothing else, and EcsService.createCluster had no settings parameter, so settings sent at creation were dropped. Real AWS accepts them on CreateCluster itself, not only through UpdateClusterSettings, and handleUpdateClusterSettings two methods away already parses them the right way. The effect was permanent drift for any client that configures a cluster at creation. terraform-provider-aws sends its setting block on create, then reads DescribeClusters back without it and proposes the same change on every plan after apply, forever. Parse settings in the handler the way the update handlers do, and pass them through a new createCluster overload. The existing overloads delegate, so the CloudFormation caller is untouched. Closes #2806
This commit is contained in:
1 parent
90d1a19310
commit
19013b8b63
3 files changed
+106
-1
No files matched your search
@@ -143,7 +143,8 @@ public class EcsJsonHandler {
|
||||
private Response handleCreateCluster(JsonNode req, String region) {
|
||||
String name = req.path("clusterName").asText(null);
|
||||
Map<String, String> tags = parseTagMap(req.path("tags"));
|
||||
EcsCluster cluster = service.createCluster(name, tags, region);
|
||||
List<ClusterSetting> settings = parseClusterSettings(req.path("settings"));
|
||||
EcsCluster cluster = service.createCluster(name, tags, settings, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("cluster", clusterNode(cluster));
|
||||
return Response.ok(resp).build();
|
||||
|
||||
@@ -221,6 +221,20 @@ public class EcsService implements ContainerTeardown, ResourceProvider {
|
||||
}
|
||||
|
||||
public EcsCluster createCluster(String clusterName, Map<String, String> tags, String region) {
|
||||
return createCluster(clusterName, tags, null, region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cluster, applying any {@code settings} the request carried.
|
||||
*
|
||||
* <p>Real AWS accepts {@code settings} (containerInsights and friends) on CreateCluster itself,
|
||||
* not only through UpdateClusterSettings. Dropping them here meant a client that configured the
|
||||
* cluster at creation, such as terraform-provider-aws's {@code setting} block, saw
|
||||
* DescribeClusters come back without them and proposed the same change on every subsequent
|
||||
* plan, forever (issue #2806).
|
||||
*/
|
||||
public EcsCluster createCluster(String clusterName, Map<String, String> tags,
|
||||
List<ClusterSetting> settings, String region) {
|
||||
String name = (clusterName == null || clusterName.isBlank()) ? DEFAULT_CLUSTER : clusterName;
|
||||
String key = clusterKey(region, name);
|
||||
if (clusters.containsKey(key)) {
|
||||
@@ -233,6 +247,9 @@ public class EcsService implements ContainerTeardown, ResourceProvider {
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
cluster.setTags(new LinkedHashMap<>(tags));
|
||||
}
|
||||
if (settings != null && !settings.isEmpty()) {
|
||||
cluster.setSettings(new ArrayList<>(settings));
|
||||
}
|
||||
clusters.put(key, cluster);
|
||||
LOG.infov("Created ECS cluster: {0} in {1}", name, region);
|
||||
return cluster;
|
||||
|
||||
Reference in new issue
Block a user