mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 07:11:11 -05:00
fix(kinesis): accept same-value Increase/DecreaseStreamRetentionPeriod (#352)
Real AWS treats same-value retention updates as no-ops, which is required for Terraform idempotency: terraform-provider-aws calls IncreaseStreamRetentionPeriod unconditionally on stream creation with the configured retention_period, so every default-retention (24h) TF stream would fail on first apply if the emulator rejected same-value. Change the strict <= / >= checks to < / > and return early when the requested value already matches. Adds integration coverage for both no-op paths. Fixes #342.
This commit is contained in:
2 files changed
+75
-4
No files matched your search
@@ -147,12 +147,19 @@ public class KinesisService {
|
||||
throw new AwsException("InvalidArgumentException",
|
||||
"Retention period must not exceed 8760 hours (365 days)", 400);
|
||||
}
|
||||
if (retentionPeriodHours <= stream.getRetentionPeriodHours()) {
|
||||
if (retentionPeriodHours < stream.getRetentionPeriodHours()) {
|
||||
throw new AwsException("InvalidArgumentException",
|
||||
"Requested retention period (" + retentionPeriodHours +
|
||||
" hours) must be greater than current retention period (" +
|
||||
" hours) must not be less than current retention period (" +
|
||||
stream.getRetentionPeriodHours() + " hours)", 400);
|
||||
}
|
||||
// Same value is a no-op on real AWS despite the API doc wording ("must be more than
|
||||
// current"). Proof: terraform-provider-aws calls IncreaseStreamRetentionPeriod on
|
||||
// stream creation unconditionally when retention_period is set (stream.go Create path),
|
||||
// so every default-retention TF stream would fail if AWS rejected same-value. See #342.
|
||||
if (retentionPeriodHours == stream.getRetentionPeriodHours()) {
|
||||
return;
|
||||
}
|
||||
stream.setRetentionPeriodHours(retentionPeriodHours);
|
||||
store.put(regionKey(region, streamName), stream);
|
||||
LOG.infov("Increased retention period for stream {0} to {1} hours", streamName, retentionPeriodHours);
|
||||
@@ -164,12 +171,16 @@ public class KinesisService {
|
||||
throw new AwsException("InvalidArgumentException",
|
||||
"Retention period must not be less than 24 hours", 400);
|
||||
}
|
||||
if (retentionPeriodHours >= stream.getRetentionPeriodHours()) {
|
||||
if (retentionPeriodHours > stream.getRetentionPeriodHours()) {
|
||||
throw new AwsException("InvalidArgumentException",
|
||||
"Requested retention period (" + retentionPeriodHours +
|
||||
" hours) must be less than current retention period (" +
|
||||
" hours) must not be greater than current retention period (" +
|
||||
stream.getRetentionPeriodHours() + " hours)", 400);
|
||||
}
|
||||
// Same value is a no-op on real AWS (mirrors IncreaseStreamRetentionPeriod). See #342.
|
||||
if (retentionPeriodHours == stream.getRetentionPeriodHours()) {
|
||||
return;
|
||||
}
|
||||
stream.setRetentionPeriodHours(retentionPeriodHours);
|
||||
store.put(regionKey(region, streamName), stream);
|
||||
LOG.infov("Decreased retention period for stream {0} to {1} hours", streamName, retentionPeriodHours);
|
||||
|
||||
Reference in new issue
Block a user