mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(eks): persist explicit version flag across restarts (#4101)
* fix(eks): persist explicit version flag across restarts * fix(eks): omit explicit version flag from API responses
This commit is contained in:
1 parent
1542c641a6
commit
b4f4b386da
5 files changed
+160
-4
No files matched your search
@@ -61,7 +61,7 @@ public class EksController {
|
||||
@Path("/clusters")
|
||||
public Response createCluster(CreateClusterRequest request) {
|
||||
Cluster cluster = eksService.createCluster(request);
|
||||
return Response.ok(Map.of("cluster", cluster)).build();
|
||||
return Response.ok(Map.of("cluster", toClusterResponse(cluster))).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -75,14 +75,29 @@ public class EksController {
|
||||
@Path("/clusters/{name}")
|
||||
public Response describeCluster(@PathParam("name") String name) {
|
||||
Cluster cluster = eksService.describeCluster(name);
|
||||
return Response.ok(Map.of("cluster", cluster)).build();
|
||||
return Response.ok(Map.of("cluster", toClusterResponse(cluster))).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/clusters/{name}")
|
||||
public Response deleteCluster(@PathParam("name") String name) {
|
||||
Cluster cluster = eksService.deleteCluster(name);
|
||||
return Response.ok(Map.of("cluster", cluster)).build();
|
||||
return Response.ok(Map.of("cluster", toClusterResponse(cluster))).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the cluster model before emitting it as an AWS API response.
|
||||
* explicitVersion is internal Floci metadata used for container image resolution
|
||||
* across restarts and must not be included on the wire. Clearing it on a copy
|
||||
* causes Jackson to omit the property due to @JsonInclude(NON_DEFAULT).
|
||||
*/
|
||||
private Cluster toClusterResponse(Cluster cluster) {
|
||||
if (cluster == null || !cluster.isExplicitVersion()) {
|
||||
return cluster;
|
||||
}
|
||||
Cluster response = cluster.copy();
|
||||
response.setExplicitVersion(false);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Keep these concrete EKS resource paths declared explicitly so they outrank
|
||||
|
||||
@@ -77,7 +77,15 @@ public class Cluster {
|
||||
@JsonIgnore
|
||||
private String podCidr;
|
||||
|
||||
@JsonIgnore
|
||||
/**
|
||||
* Internal flag indicating whether the Kubernetes version was explicitly requested by
|
||||
* the caller (true) or defaulted (false). Persisted to storage so that clusters explicitly
|
||||
* pinned to the default version (e.g. 1.29) resolve to their pinned image across restarts
|
||||
* rather than falling back to the unversioned default image. Omitted from AWS API responses
|
||||
* by toClusterResponse in EksController.
|
||||
*/
|
||||
@JsonProperty("explicitVersion")
|
||||
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
|
||||
private boolean explicitVersion;
|
||||
|
||||
/**
|
||||
@@ -160,4 +168,32 @@ public class Cluster {
|
||||
|
||||
public boolean isExplicitVersion() { return explicitVersion; }
|
||||
public void setExplicitVersion(boolean explicitVersion) { this.explicitVersion = explicitVersion; }
|
||||
|
||||
public Cluster copy() {
|
||||
Cluster c = new Cluster();
|
||||
c.name = this.name;
|
||||
c.arn = this.arn;
|
||||
c.createdAt = this.createdAt;
|
||||
c.version = this.version;
|
||||
c.endpoint = this.endpoint;
|
||||
c.roleArn = this.roleArn;
|
||||
c.resourcesVpcConfig = this.resourcesVpcConfig;
|
||||
c.kubernetesNetworkConfig = this.kubernetesNetworkConfig;
|
||||
c.logging = this.logging;
|
||||
c.encryptionConfig = this.encryptionConfig;
|
||||
c.status = this.status;
|
||||
c.certificateAuthority = this.certificateAuthority;
|
||||
c.identity = this.identity;
|
||||
c.platformVersion = this.platformVersion;
|
||||
c.tags = this.tags;
|
||||
c.containerId = this.containerId;
|
||||
c.accountId = this.accountId;
|
||||
c.internalEndpoint = this.internalEndpoint;
|
||||
c.hostPort = this.hostPort;
|
||||
c.podCidr = this.podCidr;
|
||||
c.explicitVersion = this.explicitVersion;
|
||||
c.dockerName = this.dockerName;
|
||||
c.accessConfig = this.accessConfig;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user