bazel-contrib / rules_oci

Bazel rules for building OCI containers
Apache License 2.0
303 stars 158 forks source link

Created time is showing as 0001-01-01T00:00:00Z when it should be 1970-01-01T00:00:00Z #438

Closed prestonvanloon closed 3 months ago

prestonvanloon commented 11 months ago

Not sure how to best explain this issue, but we are seeing layers uploaded with an invalid creation time when it is expected to be unix epoch 0 (1970-01-01T00:00:00Z)

Example of an image created with rules_oci and the history is all invalid timestamps

crane config gcr.io/prysmaticlabs/prysm/beacon-chain:HEAD-344e68 | jq . 
{
  "architecture": "amd64",
  "created": "0001-01-01T00:00:00Z",
  "history": [
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    },
    {
      "created": "0001-01-01T00:00:00Z"
    }
  ],
  "os": "linux",
  "rootfs": {
    "type": "layers",
    "diff_ids": [
      "sha256:54ad2ec71039b74f7e82f020a92a8c2ca45f16a51930d539b56973a18b8ffe8d",
      "sha256:6fbdf253bbc2490dcfede5bdb58ca0db63ee8aff565f6ea9f918f3bce9e2d5aa",
      "sha256:7bea6b893187b14fc0a759fe5f8972d1292a9c0554c87cbf485f0947c26b8a05",
      "sha256:ff5700ec54186528cbae40f54c24b1a34fb7c01527beaa1232868c16e2353f52",
      "sha256:d52f02c6501c9c4410568f0bf6ff30d30d8290f57794c308fe36ea78393afac2",
      "sha256:e624a5370eca2b8266e74d179326e2a8767d361db14d13edd9fb57e408731784",
      "sha256:1a73b54f556b477f0a8b939d13c504a3b4f4db71f7a09c63afbc10acb3de5849",
      "sha256:d2d7ec0f6756eb51cf1602c6f8ac4dd811d3d052661142e0110357bf0b581457",
      "sha256:4cb10dd2545bd173858450b80853b850e49608260f1a0789e0d0b39edf12f500",
      "sha256:f33e343848bd9064955eb26f7cdaa1a313116ff7cbae32b1b539dbcee622a593",
      "sha256:714f56238fb5a6e9cde67167648f2d4af7702c2fa07b9de428970fb9b0693e4c",
      "sha256:c8beeff22ce7a27d75ad5f57277fc1859f7107f02a2c0548b9e892fe53fffb5d",
      "sha256:bb0331ba46923a59e01101fbd6c18a7f68a782f4622ed1d3ddc4062ee2b835fa",
      "sha256:dcecd3d0367df6fe0709ccdac68f3e710d499fc6e93110fa84765ba9f288418e",
      "sha256:5bf213caca445a019d6501033d1a6ad8c26fb0415e25d2e7ef7830ae47026597",
      "sha256:61ada874d7c5b5ac41698b5566f1e97bbe725b90e9c80d9ae66cc431c2bafa16",
      "sha256:ffe0700e254b85b1093ca12e3326c32ff5d9c64bd03ea21c612e6110ee1cbf73",
      "sha256:168f2066958566af94b5b4c23cd366fa585e61df42a8ed7591221aa77bb63f58",
      "sha256:8fb8019914ee25ba1775523f1edc1d012bfd38a42c71fd1204350d3ebd0b727d"
    ]
  },
  "config": {
    "Entrypoint": [
      "/beacon-chain"
    ],
    "Env": [
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
      "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt"
    ],
    "User": "0",
    "WorkingDir": "/"
  }
}
prestonvanloon commented 11 months ago

Looks like this a workaround in https://github.com/bazel-contrib/rules_oci/issues/49. I still think this is a bug to not have a sensible default created timestamp.

prestonvanloon commented 11 months ago

Actually, that workaround to the labels does add the proper config labels but the timestamps are still all bogus as seen above.

prestonvanloon commented 11 months ago

Also relevant: https://github.com/google/go-containerregistry/issues/1703

thesayyn commented 11 months ago

It is done for reproducibility purposes. Principled fix for this is #49.

Can i close this?

thesayyn commented 5 months ago

It is done for reproducibility purposes.

turns out we never implemented this. sorry for the confusion.

thesayyn commented 3 months ago

This is now fixed, for stamping please see: https://github.com/bazel-contrib/rules_oci/issues/661