@@ -205,26 +205,6 @@ def delete_expired_snapshots(
205205 A tuple of expired snapshot IDs and cleanup targets.
206206 """
207207
208- expired_snapshot_ids , cleanup_targets , _ = self .get_expired_snapshots (
209- environments = environments , ignore_ttl = ignore_ttl
210- )
211-
212- if expired_snapshot_ids :
213- self .delete_snapshots (expired_snapshot_ids )
214-
215- return expired_snapshot_ids , cleanup_targets
216-
217- def get_expired_snapshots (
218- self , environments : t .Iterable [Environment ], ignore_ttl : bool = False
219- ) -> t .Tuple [t .Set [SnapshotId ], t .List [SnapshotTableCleanupTask ], t .Dict [str , str ]]:
220- """Gets the expired snapshots.
221-
222- Args:
223- ignore_ttl: Whether to ignore the TTL of the snapshots.
224-
225- Returns:
226- A tuple of expired snapshot IDs, cleanup targets and gateway per snapshot dictionary.
227- """
228208 current_ts = now_timestamp (minute_floor = False )
229209
230210 expired_query = exp .select ("name" , "identifier" , "version" ).from_ (self .snapshots_table )
@@ -241,7 +221,7 @@ def get_expired_snapshots(
241221 for name , identifier , version in fetchall (self .engine_adapter , expired_query )
242222 }
243223 if not expired_candidates :
244- return set (), [], {}
224+ return set (), []
245225
246226 promoted_snapshot_ids = {
247227 snapshot .snapshot_id
@@ -261,7 +241,6 @@ def _is_snapshot_used(snapshot: SharedVersionSnapshot) -> bool:
261241 )
262242 cleanup_targets = []
263243 expired_snapshot_ids = set ()
264- snapshot_gateways : t .Dict [str , str ] = {}
265244 for versions_batch in version_batches :
266245 snapshots = self ._get_snapshots_with_same_version (versions_batch )
267246
@@ -275,9 +254,6 @@ def _is_snapshot_used(snapshot: SharedVersionSnapshot) -> bool:
275254 expired_snapshot_ids .update ([s .snapshot_id for s in expired_snapshots ])
276255
277256 for snapshot in expired_snapshots :
278- if (node := snapshot .raw_snapshot .get ("node" )) and (gateway := node .get ("gateway" )):
279- snapshot_gateways [snapshot .snapshot_id .name ] = gateway
280-
281257 shared_version_snapshots = snapshots_by_version [(snapshot .name , snapshot .version )]
282258 shared_version_snapshots .discard (snapshot .snapshot_id )
283259
@@ -291,10 +267,14 @@ def _is_snapshot_used(snapshot: SharedVersionSnapshot) -> bool:
291267 SnapshotTableCleanupTask (
292268 snapshot = snapshot .full_snapshot .table_info ,
293269 dev_table_only = bool (shared_version_snapshots ),
270+ gateway = snapshot .raw_snapshot .get ("node" , {}).get ("gateway" , None ),
294271 )
295272 )
296273
297- return expired_snapshot_ids , cleanup_targets , snapshot_gateways
274+ if expired_snapshot_ids :
275+ self .delete_snapshots (expired_snapshot_ids )
276+
277+ return expired_snapshot_ids , cleanup_targets
298278
299279 def delete_snapshots (self , snapshot_ids : t .Iterable [SnapshotIdLike ]) -> None :
300280 """Deletes snapshots.
0 commit comments