Pulp3 wrong timezone

Problem: I have pulp3 running inside a Docker container, and both on the server where the container is located and within the container itself I have the correct timezone set to Europe/Madrid. However, when I upload a file of any type, the timestamp appears incorrect, showing a two-hour delay."

Pulpcore version: Last available

Pulp plugins installed and their versions: Rpm last version available, File last version avaiable, Container last version avaiable

Operating system - distribution and version: Pulp/pulp container

1 Like

Hi there @Danieru085!

By default, postgres stores all times as UTC-time (also Zulu-time, Z-Time, GMT). For example, when I upload into my Pulp instance here in the US, it shows as follows:

(oci-env) (main) ~/github/Pulp3/pulp_startup/rhel $ pulp rpm content upload --repository foo --relative-path bear-4.1-1.noarch.rpm --file ./bear-4.1-1.noarch.rpm
Started background task /pulp/api/v3/tasks/018b294d-9500-7299-81d5-a1ea87f8e5b4/
.Done.
{
  "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/018b294c-5853-7727-bb32-d4cdfda82391/versions/1/",
  "pulp_created": "2023-10-13T13:50:32.418546Z",
  ...
}
(oci-env) (main) ~/github/Pulp3/pulp_startup/rhel $  pulp rpm content show --href /pulp/api/v3/content/rpm/packages/018b294d-95ca-78e3-9d79-4404bb74d2b5/ | jq '{location_href, pulp_created}'
{
  "location_href": "bear-4.1-1.noarch.rpm",
  "pulp_created": "2023-10-13T13:50:32.395320Z"
}
(oci-env) (main) ~/github/Pulp3/pulp_startup/rhel $ date
Fri Oct 13 09:52:30 AM EDT 2023

Note the ‘Z’ at the end of the timestamps, indicating it’s in Zulu-time.

This is accepted best-practice - servers can be on different machines than the database, in different timezones, and users can be all over the world. Keeping “database time” always in UTC keeps the data sane in that context.

G

2 Likes

Django basically handles all the timezone stuff for us. I do not know if there is a preferred way to adjust time representation in the rest api accordingly. For not session based api operation, I could only see that you could use a header to tell the server your desired timezone.

The REST API should not adjust the timezone. The CLI could do it though.

CLI currently just hands back the JSON from the REST call; I don’t know that we want to get involved in manipulating it along the way. I wonder if there’s a tool one could filter JSON through that would recognize/translate timestamps into current-local-timezone?

Thx all for the help!

2 Likes