mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(transfer): allow DeleteServer regardless of server state (#2897)
* fix(transfer): allow DeleteServer regardless of server state AWS's DeleteServer API has no state precondition: its error list has no ConflictException, and terraform-provider-aws's resourceServerDelete calls DeleteServer directly without stopping the server first. The OFFLINE-only guard made every terraform destroy of a running aws_transfer_server fail with a 409 that real AWS never returns. CreateServer's ONLINE default is left as is: it matches real AWS, where a new server transitions STARTING -> ONLINE automatically without a StartServer call, and terraform's waitServerCreated treats OFFLINE as an unexpected state that fails apply immediately. Added an integration test locking in both behaviors. Fixes #2802 * fix(transfer): return Domain from DescribeServer and ListServers Real AWS always reports a server's Domain (default S3). Floci dropped the field on CreateServer and never echoed it, so terraform-provider-aws read back "" into its ForceNew domain attribute (default "S3") and every re-plan of an aws_transfer_server proposed a replacement: + domain = "S3" # forces replacement Store Domain on create, defaulting to S3 like AWS, and include it in DescribeServer and ListServers. Needed for the resource to survive the whole-config re-plan assertion in the terraform compat suite. * test(compat): add aws_transfer_server to the terraform and opentofu suites The resource was pulled from both fixtures while #1834 iterated because DeleteServer 409'd on a running server (#2802). With that fixed, put it back: the server is never stopped, so terraform destroy hits DeleteServer while it is ONLINE, and the existing whole-config re-plan test guards the DescribeServer round trip. * docs(transfer): drop the OFFLINE precondition from DeleteServer
This commit is contained in:
1 parent
7a5ae965e5
commit
e7256f5556
9 files changed
+239
-7
No files matched your search
@@ -63,6 +63,7 @@ public class TransferHandler {
|
||||
// ── Server handlers ───────────────────────────────────────────────────────
|
||||
|
||||
private Response createServer(JsonNode req, String region) {
|
||||
String domain = textOrNull(req, "Domain");
|
||||
List<String> protocols = jsonStringList(req.path("Protocols"));
|
||||
String endpointType = textOrNull(req, "EndpointType");
|
||||
Map<String, Object> endpointDetails = jsonObjectMap(req.path("EndpointDetails"));
|
||||
@@ -72,7 +73,7 @@ public class TransferHandler {
|
||||
String securityPolicyName = textOrNull(req, "SecurityPolicyName");
|
||||
Map<String, String> tags = parseTags(req.path("Tags"));
|
||||
|
||||
Server server = service.createServer(region, protocols, endpointType, endpointDetails,
|
||||
Server server = service.createServer(region, domain, protocols, endpointType, endpointDetails,
|
||||
identityProviderType, identityProviderDetails, loggingRole, securityPolicyName, tags);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
@@ -277,6 +278,7 @@ public class TransferHandler {
|
||||
node.put("ServerId", s.getServerId());
|
||||
node.put("Arn", s.getArn());
|
||||
node.put("State", s.getState());
|
||||
node.put("Domain", s.getDomain());
|
||||
node.put("EndpointType", s.getEndpointType());
|
||||
node.put("IdentityProviderType", s.getIdentityProviderType());
|
||||
node.put("SecurityPolicyName", s.getSecurityPolicyName());
|
||||
@@ -304,6 +306,7 @@ public class TransferHandler {
|
||||
private ObjectNode buildServerListEntry(Server s) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("Arn", s.getArn());
|
||||
node.put("Domain", s.getDomain());
|
||||
node.put("EndpointType", s.getEndpointType());
|
||||
node.put("IdentityProviderType", s.getIdentityProviderType());
|
||||
node.put("ServerId", s.getServerId());
|
||||
|
||||
@@ -44,6 +44,7 @@ public class TransferService {
|
||||
// ── Servers ───────────────────────────────────────────────────────────────
|
||||
|
||||
public Server createServer(String region,
|
||||
String domain,
|
||||
List<String> protocols,
|
||||
String endpointType,
|
||||
Map<String, Object> endpointDetails,
|
||||
@@ -59,6 +60,7 @@ public class TransferService {
|
||||
server.setServerId(serverId);
|
||||
server.setArn(arn);
|
||||
server.setState("ONLINE");
|
||||
server.setDomain(domain != null ? domain : "S3");
|
||||
server.setProtocols(protocols != null && !protocols.isEmpty() ? protocols : List.of("SFTP"));
|
||||
server.setEndpointType(endpointType != null ? endpointType : "PUBLIC");
|
||||
server.setEndpointDetails(endpointDetails);
|
||||
@@ -86,11 +88,9 @@ public class TransferService {
|
||||
}
|
||||
|
||||
public synchronized void deleteServer(String serverId) {
|
||||
Server server = getServer(serverId);
|
||||
if (!"OFFLINE".equals(server.getState())) {
|
||||
throw new AwsException("ConflictException",
|
||||
"Server must be in OFFLINE state to be deleted.", 409);
|
||||
}
|
||||
// AWS deletes a server in any state: the DeleteServer API defines no
|
||||
// state precondition (and no ConflictException at all).
|
||||
getServer(serverId);
|
||||
serverStore.delete(serverId);
|
||||
tagStore.delete("server/" + serverId);
|
||||
for (User user : userStore.scan(k -> k.startsWith(serverId + "/"))) {
|
||||
|
||||
@@ -12,6 +12,7 @@ public class Server {
|
||||
private String serverId;
|
||||
private String arn;
|
||||
private String state;
|
||||
private String domain;
|
||||
private List<String> protocols;
|
||||
private String endpointType;
|
||||
private Map<String, Object> endpointDetails;
|
||||
@@ -34,6 +35,9 @@ public class Server {
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
public String getDomain() { return domain; }
|
||||
public void setDomain(String domain) { this.domain = domain; }
|
||||
|
||||
public List<String> getProtocols() { return protocols; }
|
||||
public void setProtocols(List<String> protocols) { this.protocols = protocols; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user