Skip to content

Commit

Permalink
Cover load-star-saves-hints-to-local-meta-and-uses-them-at-store-when…
Browse files Browse the repository at this point in the history
…-there-was-recent-slot use case
  • Loading branch information
dimikot committed Dec 17, 2024
1 parent 2242f54 commit 3610299
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ci-storage
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ def action_load(
# Write hints, so next time we call "store" action, we don't
# have to pass them again, the hints will be derived from
# the "load" action.
meta = SlotMeta.read_from(local_dir=local_dir)
meta.hints = hints
meta.write_to(local_dir=local_dir)
if hints:
meta = SlotMeta.read_from(local_dir=local_dir)
meta.hints = hints
meta.write_to(local_dir=local_dir)
return
elif not layer:
slot_id = infer_best_slot_to_load_full_from(
Expand Down Expand Up @@ -309,10 +310,14 @@ def action_load(

if not layer:
slot_info = slot_infos[slot_id]
# We update full_snapshot_history to remember the actual slot "*" has
# just loaded from, to allow the next "store" action better choose the
# "dedupping" slot with --link-dest.
# We update full_snapshot_history to remember the actual slot "*" we
# have just loaded from, to allow the next "store" action better choose
# the "dedupping" slot with --link-dest.
slot_info.meta.full_snapshot_history.insert(0, slot_id)
# Write hints, so next time we call "store" action, we don't have to
# pass them again, the hints will be derived from the "load" action.
if hints:
slot_info.meta.hints = hints
slot_info.meta.write_to(local_dir=local_dir)


Expand Down Expand Up @@ -429,6 +434,7 @@ def action_clean(
],
print_elapsed=True,
)
SlotMeta().write_to(local_dir=local_dir)
finally:
try:
os.rmdir(empty_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ source ./common.sh
test -e "$LOCAL_DIR/file-1"
test -e "$LOCAL_DIR/dir-a"

echo "hints=old" > "$LOCAL_META_FILE"

ci-storage \
--slot-id="*" \
load

grep -qF 'Checking slot-id="*"... storage has no slots, so cleaning' "$OUT"

grep -qE "hints=$" "$LOCAL_META_FILE"
test ! -e "$LOCAL_DIR/file-1"
test ! -e "$LOCAL_DIR/dir-a"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
source ./common.sh

ci-storage \
--slot-id=myslot0 \
store

ci-storage \
--slot-id="*" \
--hint="aaa" \
load

grep -qF "hints=aaa" "$LOCAL_META_FILE"

ci-storage \
--slot-id=myslot1 \
--hint="" \
store

grep -qF "hints=aaa" "$STORAGE_DIR/myslot1/.ci-storage.meta"

0 comments on commit 3610299

Please sign in to comment.