mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(appconfig): list deployments with the settings they started with (#6759)
ListDeployments built each deployment's summary from the deployment strategy as it is now: once a strategy that one of an environment's deployments used was deleted, ListDeployments on that environment answered 404 "Deployment strategy not found", while GetDeployment still returned the deployment. The summary also took the profile's current name over the one the deployment recorded. AWS documents these values as the deployment's own (GetDeployment's DeploymentDurationInMinutes is "Total amount of time the deployment lasted"), and DeleteDeploymentStrategy, unlike DeleteEnvironment and DeleteConfigurationProfile, has no ConflictException for a resource in use. - StartDeployment records the strategy's DeploymentDurationInMinutes, FinalBakeTimeInMinutes, GrowthFactor and GrowthType on the deployment, and StartDeployment and GetDeployment return them, as AWS documents for both. - ListDeployments reports the recorded profile name and strategy settings, so deleting the strategy leaves earlier deployments as they started. Floci serves no UpdateDeploymentStrategy or UpdateConfigurationProfile yet; the recorded values also keep earlier deployments as they were once anything changes a strategy or renames a profile in place. - Deployments stored by earlier builds load unchanged: GetDeployment still omits the settings they never recorded, and ListDeployments reads them from the strategy while it exists and reports them as null once it is gone, instead of failing. Type is unchanged: it is still read from the profile. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
1 parent
0332b5cc24
commit
c2482e2844
7 files changed
+379
-11
No files matched your search
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -308,10 +309,14 @@ public class AppConfigService {
|
||||
}
|
||||
|
||||
public DeploymentStrategy getDeploymentStrategy(String id) {
|
||||
// AWS predefined built-in strategies
|
||||
return findDeploymentStrategy(id)
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment strategy not found", 404));
|
||||
}
|
||||
|
||||
/** The predefined or stored deployment strategy whose ID is {@code id}. */
|
||||
private Optional<DeploymentStrategy> findDeploymentStrategy(String id) {
|
||||
DeploymentStrategy builtin = builtinStrategy(id);
|
||||
if (builtin != null) return builtin;
|
||||
return strategyStore.get(id).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment strategy not found", 404));
|
||||
return builtin != null ? Optional.of(builtin) : strategyStore.get(id);
|
||||
}
|
||||
|
||||
public List<DeploymentStrategy> listDeploymentStrategies() {
|
||||
@@ -384,7 +389,7 @@ public class AppConfigService {
|
||||
String version = (String) request.get("ConfigurationVersion");
|
||||
String strategyId = (String) request.get("DeploymentStrategyId");
|
||||
|
||||
getDeploymentStrategy(strategyId);
|
||||
DeploymentStrategy strategy = getDeploymentStrategy(strategyId);
|
||||
|
||||
Deployment deployment = new Deployment();
|
||||
deployment.setApplicationId(appId);
|
||||
@@ -394,6 +399,10 @@ public class AppConfigService {
|
||||
deployment.setConfigurationLocationUri(profile.getLocationUri());
|
||||
deployment.setConfigurationVersion(version);
|
||||
deployment.setDeploymentStrategyId(strategyId);
|
||||
deployment.setDeploymentDurationInMinutes(strategy.getDeploymentDurationInMinutes());
|
||||
deployment.setFinalBakeTimeInMinutes(strategy.getFinalBakeTimeInMinutes());
|
||||
deployment.setGrowthFactor(strategy.getGrowthFactor());
|
||||
deployment.setGrowthType(strategy.getGrowthType());
|
||||
int nextDeploymentNumber = deploymentStore.scan(key -> true).stream()
|
||||
.mapToInt(Deployment::getDeploymentNumber)
|
||||
.max()
|
||||
@@ -469,6 +478,12 @@ public class AppConfigService {
|
||||
return new DeploymentPage(items, resultToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* The deployment with the profile name and strategy settings it recorded when it started, so changing
|
||||
* the profile or the strategy, or deleting the strategy, leaves them as they were. A deployment stored
|
||||
* before Floci recorded them reads them from the profile and the strategy while those exist. The type
|
||||
* is read from the profile.
|
||||
*/
|
||||
private DeploymentSummary toDeploymentSummary(Deployment deployment) {
|
||||
DeploymentSummary summary = new DeploymentSummary();
|
||||
summary.setConfigurationProfileId(deployment.getConfigurationProfileId());
|
||||
@@ -478,14 +493,24 @@ public class AppConfigService {
|
||||
summary.setConfigurationName(deployment.getConfigurationName());
|
||||
ConfigurationProfile profile = profileStore.get(deployment.getConfigurationProfileId()).orElse(null);
|
||||
if (profile != null) {
|
||||
summary.setConfigurationName(profile.getName());
|
||||
if (deployment.getConfigurationName() == null) {
|
||||
summary.setConfigurationName(profile.getName());
|
||||
}
|
||||
summary.setType(profile.getType());
|
||||
}
|
||||
DeploymentStrategy strategy = getDeploymentStrategy(deployment.getDeploymentStrategyId());
|
||||
summary.setDeploymentDurationInMinutes(strategy.getDeploymentDurationInMinutes());
|
||||
summary.setFinalBakeTimeInMinutes(strategy.getFinalBakeTimeInMinutes());
|
||||
summary.setGrowthFactor(strategy.getGrowthFactor());
|
||||
summary.setGrowthType(strategy.getGrowthType());
|
||||
if (deployment.getDeploymentDurationInMinutes() != null) {
|
||||
summary.setDeploymentDurationInMinutes(deployment.getDeploymentDurationInMinutes());
|
||||
summary.setFinalBakeTimeInMinutes(deployment.getFinalBakeTimeInMinutes());
|
||||
summary.setGrowthFactor(deployment.getGrowthFactor());
|
||||
summary.setGrowthType(deployment.getGrowthType());
|
||||
} else {
|
||||
findDeploymentStrategy(deployment.getDeploymentStrategyId()).ifPresent(strategy -> {
|
||||
summary.setDeploymentDurationInMinutes(strategy.getDeploymentDurationInMinutes());
|
||||
summary.setFinalBakeTimeInMinutes(strategy.getFinalBakeTimeInMinutes());
|
||||
summary.setGrowthFactor(strategy.getGrowthFactor());
|
||||
summary.setGrowthType(strategy.getGrowthType());
|
||||
});
|
||||
}
|
||||
summary.setPercentageComplete("COMPLETE".equals(deployment.getState()) ? 100.0f : 0.0f);
|
||||
return summary;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,20 @@ public class Deployment {
|
||||
private String configurationVersion;
|
||||
@JsonProperty("DeploymentStrategyId")
|
||||
private String deploymentStrategyId;
|
||||
// The strategy's settings as the deployment started with them, so changing or deleting the strategy
|
||||
// leaves them as they were. Omitted on deployments stored before they were recorded.
|
||||
@JsonProperty("DeploymentDurationInMinutes")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer deploymentDurationInMinutes;
|
||||
@JsonProperty("FinalBakeTimeInMinutes")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer finalBakeTimeInMinutes;
|
||||
@JsonProperty("GrowthFactor")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Float growthFactor;
|
||||
@JsonProperty("GrowthType")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String growthType;
|
||||
@JsonProperty("State")
|
||||
private String state; // BAKING, VALIDATING, DEPLOYING, COMPLETE, ROLLING_BACK, ROLLED_BACK
|
||||
@JsonProperty("Description")
|
||||
@@ -57,6 +71,18 @@ public class Deployment {
|
||||
public String getDeploymentStrategyId() { return deploymentStrategyId; }
|
||||
public void setDeploymentStrategyId(String deploymentStrategyId) { this.deploymentStrategyId = deploymentStrategyId; }
|
||||
|
||||
public Integer getDeploymentDurationInMinutes() { return deploymentDurationInMinutes; }
|
||||
public void setDeploymentDurationInMinutes(Integer deploymentDurationInMinutes) { this.deploymentDurationInMinutes = deploymentDurationInMinutes; }
|
||||
|
||||
public Integer getFinalBakeTimeInMinutes() { return finalBakeTimeInMinutes; }
|
||||
public void setFinalBakeTimeInMinutes(Integer finalBakeTimeInMinutes) { this.finalBakeTimeInMinutes = finalBakeTimeInMinutes; }
|
||||
|
||||
public Float getGrowthFactor() { return growthFactor; }
|
||||
public void setGrowthFactor(Float growthFactor) { this.growthFactor = growthFactor; }
|
||||
|
||||
public String getGrowthType() { return growthType; }
|
||||
public void setGrowthType(String growthType) { this.growthType = growthType; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user