Skip to content

Commit

Permalink
fixing migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
claudioiac committed Mar 16, 2022
1 parent f53f8dd commit 6e1dc4e
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions aviso-server/admin/migration/etcd_migration.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

import requests

old_etcd = "http://k8s-dataservices-master.ecmwf.int:30000"
new_etcd = "http://localhost:2379"
from_revision = 145679891
old_etcd = "http://127.0.0.1:2379"
new_etcd = "http://127.0.0.1:2389"
from_revision = 1
to_revision = 9
MAX_KV_RETURNED = 10000


Expand Down Expand Up @@ -62,7 +63,7 @@ def pull_kvpairs(etcd_repo, revision):
:param revision
:return: kv pairs as dictionary
"""
main_key = "/ec/"
main_key = "f"

old_etcd_url = etcd_repo + "/v3/kv/range"

Expand All @@ -80,12 +81,11 @@ def pull_kvpairs(etcd_repo, revision):
"limit": MAX_KV_RETURNED,
"sort_order": "DESCEND",
"sort_target": "KEY",
"min_mod_revision": revision,
"revision": revision,
}
# make the call
# print(f"Pull request: {body}")

# start an infinite loop of request if the server side is unreachable
resp = requests.post(old_etcd_url, json=body)
resp.raise_for_status()

Expand Down Expand Up @@ -171,8 +171,14 @@ def incr_last_byte(path: str) -> bytes:
return bytes(s)


# first get the key-value pairs from the old repo
kvs = pull_kvpairs(old_etcd, from_revision)
################
# main worflow #
################

# send them to the new repo
completed = push_kvpairs(new_etcd, kvs)
for rev in range(from_revision, to_revision + 1):

# first get the key-value pairs from the old repo
kvs = pull_kvpairs(old_etcd, rev)

# send them to the new repo
completed = push_kvpairs(new_etcd, kvs)

0 comments on commit 6e1dc4e

Please sign in to comment.