Merge lp:~hloeung/turku/include-metadata into lp:turku

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 42
Merged at revision: 42
Proposed branch: lp:~hloeung/turku/include-metadata
Merge into: lp:turku
Diff against target: 69 lines (+12/-2)
2 files modified
turku_storage/ping.py (+10/-1)
turku_storage/update_config.py (+2/-1)
To merge this branch: bzr merge lp:~hloeung/turku/include-metadata
Reviewer Review Type Date Requested Status
Barry Price Approve
Review via email: mp+465911@code.launchpad.net

Commit message

Include environment name and write out metadata file - LP:2004450

Description of the change

Upstream - https://github.com/rfinnie/turku-storage/pull/2

There can be more environments where they can have same or similar unit names. This includes the environment name to make it easier to tell which unit from which environment.

Also, for each machine directory on disk, we write out metadata info so it's easier to tell what backups the files on disk are for. See https://bugs.launchpad.net/turku/+bug/2004450

Example:

```
ubuntu@juju-86e177-prod-turku-4:~$ cat /media/turku_storage_0-turku_storage/e07b063d-5b36-4acf-9e52-11509491260f/.turku-storage-metadata.txt
unit_name: cassandra-ps5-r2/0
service_name: cassandra
environment_name: stg-ols-cassandra
ubuntu@juju-86e177-prod-turku-4:~$
```

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Barry Price (barryprice) wrote :

LGTM +1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 42

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'turku_storage/ping.py'
2--- turku_storage/ping.py 2022-02-01 02:35:22 +0000
3+++ turku_storage/ping.py 2024-05-10 08:56:58 +0000
4@@ -193,17 +193,20 @@
5 os.makedirs(machine_dir)
6
7 machine_symlink = machine["unit_name"]
8+ meta = ["unit_name: %s" % (machine['unit_name'])]
9 if "service_name" in machine and machine["service_name"]:
10 machine_symlink = machine["service_name"] + "-" + machine_symlink
11+ meta.append("service_name: %s" % (machine['service_name']))
12 if "environment_name" in machine and machine["environment_name"]:
13 machine_symlink = machine["environment_name"] + "-" + machine_symlink
14+ meta.append("environment_name: %s" % (machine['environment_name']))
15 machine_symlink = machine_symlink.replace("/", "_")
16 if os.path.islink(os.path.join(var_machines, machine_symlink)):
17 os.unlink(os.path.join(var_machines, machine_symlink))
18 if not os.path.exists(os.path.join(var_machines, machine_symlink)):
19 os.symlink(machine["uuid"], os.path.join(var_machines, machine_symlink))
20
21- self.logger.info("Begin: %s %s" % (machine["unit_name"], source_name))
22+ self.logger.info("Begin: %s %s (%s)" % (machine["unit_name"], source_name, machine.get("environment_name")))
23
24 rsync_args = [
25 "rsync",
26@@ -278,6 +281,7 @@
27 snapshot_name = None
28 summary_output = None
29 if success:
30+ meta.append("status: Success!")
31 if snapshot_mode == "link-dest":
32 summary_output = ""
33 if base_snapshot:
34@@ -310,6 +314,7 @@
35 summary_output + "Removed old snapshot: %s\n" % snapshot
36 )
37 else:
38+ meta.append("status: Failed!")
39 summary_output = "rsync exited with return code %d" % returncode
40
41 time_end = time.time()
42@@ -340,6 +345,10 @@
43 self.logger.info("Done")
44 lock.close()
45
46+ meta_path = os.path.join(machine_dir, ".turku-storage-metadata.txt")
47+ with open(meta_path, "w") as f:
48+ f.write("\n".join(meta) + "\n")
49+
50 def main(self):
51 try:
52 return self.process_ping()
53
54=== modified file 'turku_storage/update_config.py'
55--- turku_storage/update_config.py 2020-06-21 21:29:35 +0000
56+++ turku_storage/update_config.py 2024-05-10 08:56:58 +0000
57@@ -101,11 +101,12 @@
58 authorized_keys_out += f.read()
59 for machine_uuid in api_reply["machines"]:
60 machine = api_reply["machines"][machine_uuid]
61- authorized_keys_out += '%s,command="%s %s" %s (%s)\n' % (
62+ authorized_keys_out += '%s,command="%s %s" %s (%s %s)\n' % (
63 "no-pty,no-agent-forwarding,no-X11-forwarding,no-user-rc",
64 config["authorized_keys_command"],
65 machine_uuid,
66 machine["ssh_public_key"],
67+ machine.get("environment_name", ""),
68 machine["unit_name"],
69 )
70

Subscribers

People subscribed via source and target branches

to all changes: