Merge ~ruinedyourlife/lp-archive:feat-landing-page into lp-archive:main

Proposed by Quentin Debhi
Status: Merged
Approved by: Quentin Debhi
Approved revision: ba7caf290eb1e70d7f46165ec74b8fae93c8a68f
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ruinedyourlife/lp-archive:feat-landing-page
Merge into: lp-archive:main
Diff against target: 185 lines (+139/-4)
4 files modified
lp_archive/root.py (+2/-2)
lp_archive/templates/index.html (+129/-0)
setup.cfg (+4/-0)
tests/test_root.py (+4/-2)
Reviewer Review Type Date Requested Status
Quentin Debhi Approve
Ines Almeida Approve
Review via email: mp+463798@code.launchpad.net

This proposal supersedes a proposal from 2024-03-27.

Commit message

Add a landing page

Display a stylized html page with the snapshot documentation

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote : Posted in a previous version of this proposal

A screenshot of the landing page would be super helpful when reviewing these changes.

review: Needs Fixing
Revision history for this message
Jürgen Gmach (jugmac00) wrote : Posted in a previous version of this proposal
Revision history for this message
Jürgen Gmach (jugmac00) wrote : Posted in a previous version of this proposal

Guruprasad will follow up with Julian about some details, see https://chat.canonical.com/canonical/pl/4ng563xt6tghjpkyrtcbphsqxe

Revision history for this message
Ines Almeida (ines-almeida) wrote : Posted in a previous version of this proposal

The page looks great, this is a great improvement! I added a few suggestions.

A bit of a nit, but when `apt` shows up in the text sometimes it's between the `<code>` tags and sometimes not - I would always have it with the `<code>` tag.

review: Needs Fixing
Revision history for this message
Ines Almeida (ines-almeida) wrote : Posted in a previous version of this proposal

Left a couple of very minor comments that still need to be addressed, but this looks good to me :thumbs_up:

review: Approve
Revision history for this message
Guruprasad (lgp171188) : Posted in a previous version of this proposal
Revision history for this message
Ines Almeida (ines-almeida) wrote (last edit ): Posted in a previous version of this proposal

Thinking about this further and after a chat with Aaron, I think we should generally either follow what is in https://docs.google.com/document/d/1loqLRYCZ1CmvK5iVIRunTC947XjlRHkUMnUHGndwqtg more faithfully, or suggest any changes in the document directly, since the contents of that document were reviewed by a few people already and that way they would have a say in any changes.

Happy to go through this with you to decide which changes to suggest, but also happy with whatever you decide (revert any changes to the original, or add the comment in the docs). Sorry for going back on my approval :)

review: Needs Fixing
Revision history for this message
Ines Almeida (ines-almeida) wrote : Posted in a previous version of this proposal

Looks good, thank you for making the suggested changes!

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote : Posted in a previous version of this proposal
Revision history for this message
Ines Almeida (ines-almeida) wrote :

Approving as I did in the last MP

review: Approve
Revision history for this message
Ines Almeida (ines-almeida) :
review: Approve
Revision history for this message
Quentin Debhi (ruinedyourlife) wrote :
review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lp_archive/root.py b/lp_archive/root.py
2index f0304b5..e175759 100644
3--- a/lp_archive/root.py
4+++ b/lp_archive/root.py
5@@ -3,11 +3,11 @@
6
7 """API views for the Launchpad archive service."""
8
9-from flask import Flask
10+from flask import Flask, render_template
11
12
13 def root() -> tuple[str, dict[str, str]]:
14- return "Launchpad archive service.\n", {"Content-Type": "text/plain"}
15+ return render_template("index.html"), {"Content-Type": "text/html"}
16
17
18 def init_app(app: Flask) -> None:
19diff --git a/lp_archive/templates/index.html b/lp_archive/templates/index.html
20new file mode 100644
21index 0000000..54f2c32
22--- /dev/null
23+++ b/lp_archive/templates/index.html
24@@ -0,0 +1,129 @@
25+<!DOCTYPE html>
26+<html lang="en">
27+<head>
28+ <meta charset="UTF-8">
29+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
30+ <title>Ubuntu Snapshot Service</title>
31+ <link rel="stylesheet" href="https://assets.ubuntu.com/v1/vanilla-framework-version-4.9.1.min.css" />
32+</head>
33+<body class="is-paper">
34+
35+<div class="p-strip--highlighted">
36+ <div class="row">
37+ <div class="col-12">
38+ <h1 class="p-heading--1">Ubuntu Snapshot Service</h1>
39+ <p>The Ubuntu snapshot service makes it possible to see and use the Ubuntu archive as it was at any specified date and time. Snapshots of the Ubuntu archive are available for any date and time after 1 March 2023. This means that you are able to enable the service on the repositories and use <code>apt</code> to query or install packages as they were at any recent date and time.</p>
40+ <p>Common use cases of this service include:</p>
41+ <ul>
42+ <li>enabling reproducible deployments of a set of packages as at a particular date and time;</li>
43+ <li>determining when a change in behaviour occurred in the archive; and</li>
44+ <li>supporting a structured update workflow, for example where a snapshot is validated in</br>one environment before being released to other environments.</li>
45+ </ul>
46+ <p>Snapshots are supported in Ubuntu 23.10 onwards, plus on updated installations of Ubuntu 20.04 LTS (<code>apt</code> 2.0.10) and Ubuntu 22.04 LTS (<code>apt</code> 2.4.11). We intend to ensure snapshots are available for dates up to at least 2 years in the past, which we may extend if there is demand.</p>
47+ </div>
48+ </div>
49+</div>
50+
51+<div class="p-strip">
52+ <div class="row">
53+ <div class="col-12">
54+ <h2 id="quick-start-example">Quick-start Example</h2>
55+ <p>On Ubuntu 24.04 LTS and later have installing the version of <code>hello</code> as it was at 3:04:00 am UTC on 1 March 2024 is as simple as using the following command (on an instance that does not already have hello installed):</p>
56+ <pre><code>apt install hello --update --snapshot 20240301T030400Z</code></pre>
57+ <p>This command first updates your package indexes (the <code>--update</code> argument is the equivalent of running <code>apt</code> update before the specified <code>apt</code> command) and then installs the hello package from the specified snapshot instead of the latest version in the archive. In the output you should see that the package is being downloaded from the snapshot server:</p>
58+ <pre><code>Get:1 https://snapshot.ubuntu.com/ubuntu/20240301T030400Z noble/main
59+amd64 hello amd64 2.10-3 [26.2 kB]</code></pre>
60+ </div>
61+ </div>
62+</div>
63+
64+<div class="p-strip--highlighted">
65+ <div class="row">
66+ <div class="col-12">
67+ <h2>How to Use Snapshots on Ubuntu</h2>
68+ <h3 class="u-sv3">Enable Snapshot Service</h3>
69+ <h4>For Ubuntu 24.04 and later</h4>
70+ <p>The <code>apt</code> included in Ubuntu 24.04 and later automatically detects when snapshots are supported for a repository (any repository with a Snapshots: directive in the Release file). This includes the official Ubuntu repositories, so snapshots for these will be enabled by default.</p>
71+
72+ <h4>For Ubuntu 23.10 and later</h4>
73+ <p>On Ubuntu 23.10 and earlier, edit <code>/etc/apt/sources.list</code> to add <code>[snapshot=yes]</code> into the standard prefix, for example:</p>
74+ <pre><code>deb [snapshot=yes] http://archive.ubuntu.com/ubuntu/ jammy main restricted
75+deb [snapshot=yes] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
76+deb [snapshot=yes] http://security.ubuntu.com/ubuntu jammy-security main restricted</code></pre>
77+
78+ <h3 class="u-sv3">Use a Snapshot ID with apt Commands</h3>
79+ <h4>Snapshot ID format</h4>
80+ <p>The Snapshot ID will be the desired date and UTC time in the YYYYMMDDTHHMMSSZ format, for example 20230302T030400Z for 03:04 UTC on 2 March 2023.</p>
81+
82+ <h4>Using a Snapshot ID with each apt command</h4>
83+ <p>Once snapshots are enabled for a repository, it is possible to pass a specific Snapshot ID to most <code>apt</code> or <code>apt-get</code> commands with <code>--snapshot [Snapshot ID]</code> or <code>-S [Snapshot ID]</code>, for example:</p>
84+ <pre><code>apt update --snapshot 20231102T030400Z
85+apt policy hello -S 20231102T030400Z
86+apt install hello --snapshot 20231102T030400Z</code></pre>
87+ <p>Note that the <code>apt update --snapshot [snapshot]</code> command needs to be run immediately before the other <code>apt</code> commands. These commands will also fail if the snapshot format is incorrect or the snapshot does not exist (for example, if you try to use a date before that Ubuntu release existed).</p>
88+
89+ <h4>Using a specifig Snapshot ID for all apt commands</h4>
90+ <p>Enabling snapshots for the repository will allow you to specify a snapshot when using <code>apt</code>, as shown above. Alternatively, it is possible to set <code>apt</code> to use a particular snapshot for all <code>apt</code> commands. To do this, the specific Snapshot ID (e.g. 20230302T030400Z) can be used in the place of “yes” in the relevant source. If a specific snapshot is configured in this way then it will be used even if a different snapshot ID is given as part of an <code>apt</code> command.</p>
91+ <p>For example, on Ubuntu 24.04 LTS onwards:</p>
92+ <pre><code>Types: deb
93+URIs: http://archive.ubuntu.com/ubuntu
94+Suites: noble noble-updates
95+Components: main universe
96+Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
97+Snapshot: 20240301T030400Z
98+
99+Ubuntu security updates. Aside from URIs and Suites,
100+## this should mirror your choices in the previous section.
101+Types: deb
102+URIs: http://security.ubuntu.com/ubuntu
103+Suites: noble-security
104+Components: main universe
105+Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
106+Snapshot: 20240301T030400Z</code></pre>
107+ <p>Ubuntu 23.10 and earlier:</p>
108+ <pre><code>deb [snapshot=20230302T030400Z] http://archive.ubuntu.com/ubuntu/ jammy main restricted
109+deb [snapshot=20230302T030400Z] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
110+deb [snapshot=20230302T030400Z] http://security.ubuntu.com/ubuntu jammy-security main restricted</code></pre>
111+
112+ <h3>Disable Snapshot Service</h3>
113+ <h4>For Ubuntu 24.04 and later (Deb822 sources)</h4>
114+ <p>As mentioned above, on Ubuntu 24.04 and later, snapshots are enabled automatically for supported repositories. If you do <b>not</b> want archive snapshots to be enabled for a repository, edit the relevant sources file (e.g. <code>/etc/apt/sources.list.d/ubuntu.sources</code>) to add <code>Snapshot: no</code> to the relevant sources, for example:</p>
115+ <pre><code>Types: deb
116+URIs: http://archive.ubuntu.com/ubuntu
117+Suites: noble noble-updates
118+Components: main universe
119+Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
120+Snapshot: no</code></pre>
121+
122+ <h4>For Ubuntu 23.10 and earlier</h4>
123+ <p>On Ubuntu 23.10 and earlier the included version of <code>apt</code> did not automatically detect snapshot support and so snapshots should not be enabled unless you have added <code>[snapshot=yes]</code> to the relevant source (as explained above).</p>
124+ </div>
125+ </div>
126+</div>
127+
128+<div class="p-strip">
129+ <div class="row">
130+ <div class="col-12">
131+ <h2>See Also</h2>
132+ <ul class="p-list">
133+ <li><a href="https://www.youtube.com/watch?v=0tAzyHsNi3s">APT Archive Snapshot Integration Demo (Ubuntu 23.10)</a></li>
134+ <li><a href="https://ubuntu.com/blog/ubuntu-snapshots-on-azure-ensuring-predictability-and-consistency-in-cloud-deployments">Ubuntu Snapshots on Microsoft Azure: Ensuring predictability and consistency in cloud deployments</a></li>
135+ <li><a href="https://ubuntu.com/blog/securing-multiple-ubuntu-instances-while-maximising-uptime">Ubuntu Explained: How to ensure security and stability in cloud instances—part 3</a></li>
136+ <li><a href="https://manpages.ubuntu.com/manpages/noble/en/man8/apt-get.8.html">apt-get manpage</a></li>
137+ <li><a href="https://manpages.ubuntu.com/manpages/noble/en/man5/apt.conf.5.html">apt.conf manpage</a></li>
138+ <li><a href="https://manpages.ubuntu.com/manpages/noble/en/man5/sources.list.5.html">sources.list manpage</a></li>
139+ <li><a href="https://techcommunity.microsoft.com/t5/linux-and-open-source-blog/increased-security-and-resiliency-of-canonical-workloads-on/ba-p/3970623">Increased security and resiliency of Canonical workloads on Azure - now in preview</a></li>
140+ <li><a href="https://www.youtube.com/watch?v=hxDPqRDY5Lk">Using Ubuntu’s new snapshot service at scale with Azure and AKS</a></li>
141+ </ul>
142+ </div>
143+ </div>
144+</div>
145+
146+<footer class="p-strip is-shallow">
147+ <div class="row">
148+ <p class="u-align-text--center">© 2024 <a href="http://canonical.com/">Canonical&nbsp;Ltd.</a></p>
149+ </div>
150+</footer>
151+
152+</body>
153+</html>
154diff --git a/setup.cfg b/setup.cfg
155index cae7361..9490c1d 100644
156--- a/setup.cfg
157+++ b/setup.cfg
158@@ -34,6 +34,10 @@ test =
159 coverage
160 pytest
161
162+[options.package_data]
163+lp_archive =
164+ templates/*.html
165+
166 [isort]
167 known_first_party = lp_archive
168 line_length = 79
169diff --git a/tests/test_root.py b/tests/test_root.py
170index 71a7f87..13c6c32 100644
171--- a/tests/test_root.py
172+++ b/tests/test_root.py
173@@ -4,8 +4,10 @@
174
175 def test_root(client):
176 response = client.get("/", headers=[("Host", "snapshot.ubuntu.test")])
177- assert response.data == b"Launchpad archive service.\n"
178- assert response.headers["Content-Type"] == "text/plain"
179+ assert response.headers["Content-Type"] == "text/html"
180+ assert b"<title>Ubuntu Snapshot Service</title>" in response.data
181+ assert b"<!DOCTYPE html>" in response.data
182+ assert b"</html>" in response.data
183
184
185 def test_health_check(client):

Subscribers

People subscribed via source and target branches