diff --git a/CHANGELOG.md b/CHANGELOG.md index 36a1fa8..8621612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 2ff82f1..5c67ae2 100644 --- a/README.md +++ b/README.md @@ -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/ diff --git a/docs/i18n/README.es.md b/docs/i18n/README.es.md index 364ef6f..17a8f0a 100644 --- a/docs/i18n/README.es.md +++ b/docs/i18n/README.es.md @@ -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/ diff --git a/docs/i18n/README.zh-CN.md b/docs/i18n/README.zh-CN.md index b80220d..16b76f5 100644 --- a/docs/i18n/README.zh-CN.md +++ b/docs/i18n/README.zh-CN.md @@ -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/ diff --git a/src/keepstack/validate.py b/src/keepstack/validate.py index 0c2dfde..5648e8a 100644 --- a/src/keepstack/validate.py +++ b/src/keepstack/validate.py @@ -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") diff --git a/tests/test_e2e_validate.py b/tests/test_e2e_validate.py index eec9743..4b8305a 100644 --- a/tests/test_e2e_validate.py +++ b/tests/test_e2e_validate.py @@ -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}') diff --git a/tests/test_validate.py b/tests/test_validate.py index ea5db7d..517978b 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -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"))