Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update status badges for Anaconda.org #2278

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/StatusDashboard/repos_and_bots.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ function Image({ alt, link, children }) {
}

function CDNStatus() {
const [{ minutes, status }, setState] = useState({ minutes: 0, status: "…" });
const [{ minutes, status }, setState] = useState({ minutes: "…", status: "…" });
useEffect(() => {
void (async () => {
try {
const response = await (await fetch(urls.repos.cdn.api)).text();
const updated = new Date(response.trim()).getTime();
const response = await (await fetch(`${urls.repos.cdn.api}?bustcache=${Date.now()}`)).json();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that we need this bustcache trick again (also needed in the packages page for the RSS stuff). Is this a conda.anaconda.org misconfiguration? We don't need it for e.g. raw.githubusercontent.com.

cc @jezdez @morremeyer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimergp I'll look into how we can improve that this week. We explicitly purge all updated files from the Cloudflare cache at the end of each cache run.

However, we do also set a Cache-Control: public, max-age=1200 header in responses so that clients don't always download the files anew.

I expect that this leads to the effect that the status does not update: If the browser requests the file when the last update was 19 minutes ago, it will serve it from cache for the next 20 minutes, so it will show the last update being 39 minutes ago even though there should have been another update in the meantime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the max-age for these status files (last_updated.json, rss.xml, etc) should be smaller, like a minute or something? I'm busting the browser cache with these ?bustcache=<timestamp> hacks but ideally we wouldn't need them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, my thoughts exactly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd stick with the work-around for now.

const updated = new Date(response.timestamp.iso8601).getTime();
const delta = (new Date()).getTime() - updated;
const status = delta < OPERATIONAL_WINDOW ? "operational" :
delta < DEGRADED_WINDOW ? "degraded" : "major outage";
Expand Down
4 changes: 2 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ export const urls = {
},
],
cdn: {
api: "https://s3.amazonaws.com/conda-static.anaconda.org/conda-forge/last-updated",
link: "https://conda-static.anaconda.org/conda-forge/rss.xml",
api: "https://conda.anaconda.org/conda-forge/last-updated.json",
link: "https://conda.anaconda.org/conda-forge/rss.xml",
},
services: {
api: "https://conda-forge.herokuapp.com/alive",
Expand Down