RedHatInsights/sources-api

Sources API backend should rollback source creation when broker is down

Closed this issue · 0 comments

While testing Cost Management's Sources Client I noticed that the Sources API server is saving source creation events when the broker is down.

In this situation the user would think their source creation was successful but the consuming applications would never get the kafka event.

sources_server    | [----] I, [2020-04-09T13:03:13.882392 #1:2b0fdd0225d4]  INFO -- :   Parameters: {"source_type_id"=>"5", "name"=>"Test OCP Source 2", "source_ref"=>"8770d031-9b46-41d9-be14-629239cf899f9"}
sources_server    | [----] D, [2020-04-09T13:03:13.885633 #1:2b0fdd0225d4] DEBUG -- :   Tenant Load (1.1ms)  SELECT  "tenants".* FROM "tenants" WHERE "tenants"."external_tenant" = $1 LIMIT $2  [["external_tenant", "10001"], ["LIMIT", 1]]
sources_server    | [----] D, [2020-04-09T13:03:13.887543 #1:2b0fdd0225d4] DEBUG -- :    (0.3ms)  BEGIN
sources_server    | [----] D, [2020-04-09T13:03:13.890869 #1:2b0fdd0225d4] DEBUG -- :   SourceType Load (1.6ms)  SELECT  "source_types".* FROM "source_types" WHERE "source_types"."id" = $1 LIMIT $2  [["id", 5], ["LIMIT", 1]]
sources_server    | [----] D, [2020-04-09T13:03:13.895816 #1:2b0fdd0225d4] DEBUG -- :   Source Exists (3.7ms)  SELECT  1 AS one FROM "sources" WHERE "sources"."name" = $1 AND "sources"."tenant_id" = $2 LIMIT $3  [["name", "Test OCP Source 2"], ["tenant_id", 2], ["LIMIT", 1]]
sources_server    | [----] D, [2020-04-09T13:03:13.902674 #1:2b0fdd0225d4] DEBUG -- :   Source Create (4.9ms)  INSERT INTO "sources" ("name", "uid", "created_at", "updated_at", "tenant_id", "source_type_id", "source_ref") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["name", "Test OCP Source 2"], ["uid", "478d468d-3cdb-4d1f-b7ea-5ac1db98625a"], ["created_at", "2020-04-09 13:03:13.896528"], ["updated_at", "2020-04-09 13:03:13.896528"], ["tenant_id", 2], ["source_type_id", 5], ["source_ref", "8770d031-9b46-41d9-be14-629239cf899f9"]]
sources_server    | [----] D, [2020-04-09T13:03:13.904761 #1:2b0fdd0225d4] DEBUG -- :    (0.9ms)  COMMIT
sources_server    | [----] D, [2020-04-09T13:03:13.905569 #1:2b0fdd0225d4] DEBUG -- : publishing message to topic "platform.sources.event-stream"...
sources_server    | [----] E, [2020-04-09T13:03:13.938211 #1:2b0fdd0225d4] ERROR -- : Kafka::ConnectionError: Could not connect to any of the seed brokers:
sources_server    | - kafka://kafka:29092: getaddrinfo: Name or service not known