Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project are documented here. The format follows
## [Unreleased]

### Fixed
- `keepstack validate` reported services the emulator does not have (`404 UnknownService`, which recent emulator
versions return instead of 501) as config errors; they are emulator gaps now and only warn unless `--strict`.
- A write that waited while keepstack restored the emulator (or behind a slow write), and whose client gave up and
retried meanwhile, was still executed afterwards: the resource was created behind Terraform's back and the retry
failed with "already exists" (`BucketAlreadyExists`, `ResourceInUseException`). keepstack now checks that the client
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ plans again and classifies every problem:
|---|---|---|
| ❌ | **Config error**: AWS rejected the request, or the provider did | Yes |
| 🔁 | **Not idempotent**: the plan is not empty right after the apply | Yes |
| ⚠️ | **Emulator gap**: the emulator does not implement that API (HTTP 501) or has a known bug | Only with `--strict` |
| ⚠️ | **Emulator gap**: the emulator does not implement that API or service (HTTP 501, `UnknownService`) or has a known bug | Only with `--strict` |

```console
$ keepstack validate infra/
Expand Down
2 changes: 1 addition & 1 deletion docs/i18n/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ a planificar y clasifica cada problema:
|---|---|---|
| ❌ | **Error de configuración**: AWS o el provider rechazaron la petición | Sí |
| 🔁 | **No idempotente**: el plan no sale vacío justo después del apply | Sí |
| ⚠️ | **Carencia del emulador**: el emulador no implementa esa API (HTTP 501) o tiene un bug conocido | Solo con `--strict` |
| ⚠️ | **Carencia del emulador**: el emulador no implementa esa API o servicio (HTTP 501, `UnknownService`) o tiene un bug conocido | Solo con `--strict` |

```console
$ keepstack validate infra/
Expand Down
2 changes: 1 addition & 1 deletion docs/i18n/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ override 文件把 Terraform 指向它(你的后端和 `.terraform` 不受影
|---|---|---|
| ❌ | **配置错误**:AWS 或 provider 拒绝了请求 | 是 |
| 🔁 | **非幂等**:apply 之后 plan 不为空 | 是 |
| ⚠️ | **模拟器缺陷**:模拟器未实现该 API(HTTP 501)或存在已知 bug | 仅在 `--strict` 时 |
| ⚠️ | **模拟器缺陷**:模拟器未实现该 API 或服务(HTTP 501、`UnknownService`)或存在已知 bug | 仅在 `--strict` 时 |

```console
$ keepstack validate infra/
Expand Down
2 changes: 1 addition & 1 deletion src/keepstack/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from . import check, daemon

OVERRIDE = "zz_keepstack_override.tf"
GAP_RE = re.compile(r"StatusCode: 501|NotImplemented|not implemented in this emulator", re.IGNORECASE)
GAP_RE = re.compile(r"StatusCode: 501|NotImplemented|not implemented in this emulator|UnknownService|no emulated service", re.IGNORECASE)
# Terraform's JSON plan actions; "noop" and "read" are not changes.
CHANGE_ACTIONS = ("create", "update", "replace", "delete", "move", "import", "remove")
DESTRUCTIVE = ("replace", "delete")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_e2e_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
QUEUE = 'resource "aws_sqs_queue" "jobs" {\n name = "%s"\n}\n'
OUTPUT = 'output "queue" {\n value = aws_sqs_queue.jobs.url\n}\n'
# The emulator answers 501 for Athena's ListTagsForResource.
GAP = 'resource "aws_athena_workgroup" "gap" {\n name = "validate-gap"\n}\n'
# A service the emulator does not have (404 UnknownService); the emulator grows, so this may need updating.
GAP = 'resource "aws_qldb_ledger" "gap" {\n name = "validate-gap"\n permissions_mode = "STANDARD"\n}\n'
# Rejected by the provider before any API call: a genuine configuration error.
BROKEN = TABLE.replace('type = "S"\n }\n}', 'type = "S"\n }\n attribute {\n name = "unused"\n'
' type = "S"\n }\n}')
Expand Down
5 changes: 5 additions & 0 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def test_501_is_an_emulator_gap(self):
"api error NotImplemented: scaffolded but not implemented in this emulator"), COMPAT)
self.assertEqual((f["kind"], f["file"], f["line"]), ("emulator", "main.tf", 3))

def test_unknown_service_is_an_emulator_gap(self): # regression #43
f = v.classify(diag("operation error Service Catalog: CreatePortfolio, https response error StatusCode: 404, "
"api error UnknownService: no emulated service is registered for 'servicecatalog'"), COMPAT)
self.assertEqual(f["kind"], "emulator")

def test_known_broken_resource_is_an_emulator_gap_with_its_workaround(self):
f = v.classify(diag("InvalidPermission.NotFound", "aws_security_group.web"), COMPAT)
self.assertEqual((f["kind"], f["hint"]), ("emulator", "keepstack up --shims"))
Expand Down
Loading