Skip to content

Commit f4dc3eb

Browse files
committed
connect kafka topic to endpoint, but disable deletes from API
1 parent f71f224 commit f4dc3eb

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

snuba/datasets/configuration/events_analytics_platform/storages/eap_items.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ query_processors:
157157
timeout_before_checking_execution_speed: 0
158158

159159
deletion_settings:
160-
is_enabled: 1
160+
is_enabled: 0
161161
max_rows_to_delete: 2000000
162162
tables:
163163
- eap_items_1_local

snuba/utils/streams/topics.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ class Topic(Enum):
1919
SUBSCRIPTION_SCHEDULED_EVENTS = "scheduled-subscriptions-events"
2020
SUBSCRIPTION_SCHEDULED_TRANSACTIONS = "scheduled-subscriptions-transactions"
2121
SUBSCRIPTION_SCHEDULED_METRICS = "scheduled-subscriptions-metrics"
22-
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_SETS = (
23-
"scheduled-subscriptions-generic-metrics-sets"
24-
)
22+
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_SETS = "scheduled-subscriptions-generic-metrics-sets"
2523
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_DISTRIBUTIONS = (
2624
"scheduled-subscriptions-generic-metrics-distributions"
2725
)
2826
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_COUNTERS = (
2927
"scheduled-subscriptions-generic-metrics-counters"
3028
)
31-
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_GAUGES = (
32-
"scheduled-subscriptions-generic-metrics-gauges"
33-
)
29+
SUBSCRIPTION_SCHEDULED_GENERIC_METRICS_GAUGES = "scheduled-subscriptions-generic-metrics-gauges"
3430

3531
SUBSCRIPTION_RESULTS_EVENTS = "events-subscription-results"
3632
SUBSCRIPTION_RESULTS_TRANSACTIONS = "transactions-subscription-results"
@@ -48,9 +44,7 @@ class Topic(Enum):
4844
UPTIME_RESULTS = "snuba-uptime-results"
4945
GENERIC_METRICS = "snuba-generic-metrics"
5046
GENERIC_METRICS_SETS_COMMIT_LOG = "snuba-generic-metrics-sets-commit-log"
51-
GENERIC_METRICS_DISTRIBUTIONS_COMMIT_LOG = (
52-
"snuba-generic-metrics-distributions-commit-log"
53-
)
47+
GENERIC_METRICS_DISTRIBUTIONS_COMMIT_LOG = "snuba-generic-metrics-distributions-commit-log"
5448
GENERIC_METRICS_COUNTERS_COMMIT_LOG = "snuba-generic-metrics-counters-commit-log"
5549
GENERIC_METRICS_GAUGES_COMMIT_LOG = "snuba-generic-metrics-gauges-commit-log"
5650
GENERIC_EVENTS = "generic-events"
@@ -78,6 +72,7 @@ class Topic(Enum):
7872
DEAD_LETTER_ITEMS = "snuba-dead-letter-items"
7973

8074
LW_DELETIONS_GENERIC_EVENTS = "snuba-lw-deletions-generic-events"
75+
LW_DELETIONS_EAP_ITEMS = "snuba-lw-eap-items"
8176

8277
COGS_SHARED_RESOURCES_USAGE = "shared-resources-usage"
8378

snuba/web/bulk_delete_query.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class DeleteQueryMessage(TypedDict):
4848

4949
PRODUCER_MAP: MutableMapping[str, Producer] = {}
5050
STORAGE_TOPIC: Mapping[str, Topic] = {
51-
StorageKey.SEARCH_ISSUES.value: Topic.LW_DELETIONS_GENERIC_EVENTS
51+
StorageKey.SEARCH_ISSUES.value: Topic.LW_DELETIONS_GENERIC_EVENTS,
52+
StorageKey.EAP_ITEMS.value: Topic.LW_DELETIONS_EAP_ITEMS,
5253
}
5354

5455

@@ -80,17 +81,13 @@ def _flush_producers() -> None:
8081
for storage, producer in PRODUCER_MAP.items():
8182
messages_remaining = producer.flush(5.0)
8283
if messages_remaining:
83-
logger.debug(
84-
f"{messages_remaining} {storage} messages pending delivery"
85-
)
84+
logger.debug(f"{messages_remaining} {storage} messages pending delivery")
8685
time.sleep(1)
8786

8887
Thread(target=_flush_producers, name="flush_producers", daemon=True).start()
8988

9089

91-
def _delete_query_delivery_callback(
92-
error: Optional[KafkaError], message: KafkaMessage
93-
) -> None:
90+
def _delete_query_delivery_callback(error: Optional[KafkaError], message: KafkaMessage) -> None:
9491
metrics.increment(
9592
"delete_query.delivery_callback",
9693
tags={"status": "failure" if error else "success"},
@@ -147,9 +144,7 @@ def delete_from_storage(
147144

148145
delete_settings = storage.get_deletion_settings()
149146
if not delete_settings.is_enabled:
150-
raise DeletesNotEnabledError(
151-
f"Deletes not enabled for {storage.get_storage_key().value}"
152-
)
147+
raise DeletesNotEnabledError(f"Deletes not enabled for {storage.get_storage_key().value}")
153148

154149
columns_diff = set(conditions.keys()) - set(delete_settings.allowed_columns)
155150
if columns_diff != set():
@@ -170,9 +165,7 @@ def delete_from_storage(
170165
return delete_from_tables(storage, delete_settings.tables, conditions, attr_info)
171166

172167

173-
def construct_query(
174-
storage: WritableTableStorage, table: str, condition: Expression
175-
) -> Query:
168+
def construct_query(storage: WritableTableStorage, table: str, condition: Expression) -> Query:
176169
cluster_name = storage.get_cluster().get_clickhouse_cluster_name()
177170
on_cluster = literal(cluster_name) if cluster_name else None
178171
return Query(
@@ -233,7 +226,5 @@ def construct_or_conditions(conditions: Sequence[ConditionsType]) -> Expression:
233226

234227

235228
def should_use_killswitch(storage_name: str, project_id: str) -> bool:
236-
killswitch_config = get_str_config(
237-
f"lw_deletes_killswitch_{storage_name}", default=""
238-
)
229+
killswitch_config = get_str_config(f"lw_deletes_killswitch_{storage_name}", default="")
239230
return project_id in killswitch_config if killswitch_config else False

0 commit comments

Comments
 (0)