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

Docker container unhealthy #225

Closed
cford1080 opened this issue Apr 20, 2023 · 3 comments · Fixed by #229
Closed

Docker container unhealthy #225

cford1080 opened this issue Apr 20, 2023 · 3 comments · Fixed by #229

Comments

@cford1080
Copy link

cford1080 commented Apr 20, 2023

Despite the logs stating a lock is acquired and subsequently released, the file properties on .geoipupdate.lock are not being updated, resulting in the Docker healthcheck failing.

Log:

# STATE: Creating configuration file at /etc/GeoIP.conf
# STATE: Running geoipupdate
geoipupdate version 5.0.4
Using config file /etc/GeoIP.conf
Using database directory /usr/share/GeoIP
Initializing file lock at /usr/share/GeoIP/.geoipupdate.lock
Acquired lock file at /usr/share/GeoIP/.geoipupdate.lock
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-City.mmdb: 550a2a481ca62df86191dbb0675c7d66
Requesting updates for GeoLite2-City: https://updates.maxmind.com/geoip/databases/GeoLite2-City/update?db_md5=550a2a481ca62df86191dbb0675c7d66
No new updates available for GeoLite2-City
Database GeoLite2-City up to date
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-ASN.mmdb: b8b7c65a9faca55877d9c88b45acfba2
Requesting updates for GeoLite2-ASN: https://updates.maxmind.com/geoip/databases/GeoLite2-ASN/update?db_md5=b8b7c65a9faca55877d9c88b45acfba2
No new updates available for GeoLite2-ASN
Database GeoLite2-ASN up to date
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-City.mmdb: 550a2a481ca62df86191dbb0675c7d66
Requesting updates for GeoLite2-City: https://updates.maxmind.com/geoip/databases/GeoLite2-City/update?db_md5=550a2a481ca62df86191dbb0675c7d66
No new updates available for GeoLite2-City
Database GeoLite2-City up to date
Calculated MD5 sum for /usr/share/GeoIP/GeoLite2-Country.mmdb: e29a42b0e33358fdc16471fe43b72a1d
Requesting updates for GeoLite2-Country: https://updates.maxmind.com/geoip/databases/GeoLite2-Country/update?db_md5=e29a42b0e33358fdc16471fe43b72a1d
No new updates available for GeoLite2-Country
Database GeoLite2-Country up to date
Lock file /usr/share/GeoIP/.geoipupdate.lock successfully released
# STATE: Sleeping for 8 hours

According to the Dockerfile:

# The health check is done by checking if the database directory is modified within the
# update period minus 1 minute. The 1 minute is a threshold for allowing slower starts.
# Without the LockFile in the database directory, this check is not going to be working
# since database files are not going to be modified when there are no updates.
HEALTHCHECK --interval=10s --timeout=10s \
    CMD test $(stat -c %Y /usr/share/GeoIP) -gt $(($(date +%s) - $GEOIPUPDATE_FREQUENCY * 60 * 61 )) \
    || exit 1;

But the access time of the lock file does not change, resulting in no change detected on the GeoIP directory when the databases aren't updated.

I did recently find the update schedule and did update GEOIPUPDATE_FREQUENCY from 8 hours to 3 days to better align with that, but I'd still call this undesirable behavior.

@oschwald
Copy link
Member

What version of geoipupdate are you using and did this start? Did this start after upgrading to 5.x.x?

@cford1080
Copy link
Author

cford1080 commented Apr 20, 2023

geoipupdate version 5.0.4

I'm using the latest image tag. Currently, the above version is what was pulled. I do not know when this started. I only noticed it over the last week, but that is not to say that it wasn't happening before that. I only looked into it last night.

edit: I did try some older versions last night, but I saw no different behavior until I reached a 4.x version that was not compatible with Docker Secrets.

@cford1080
Copy link
Author

cford1080 commented Apr 21, 2023

Now that the databases have updated, here's some evidence of my claim. At the very least, regardless of frequency, we can be certain that whenever the databases are updated, .geoipupdate.lock should have been locked prior to the update and released after, resulting in a modification time close to the mod time of the databases. However, despite still seeing the same logs as posted previously, the mod time of the lock file was not updated. At least, that appears to be what the health check is expecting; I don't know enough about file locks or Flock to know if that expectation is valid or not.

-rw------- 1 root  root         0 Apr 20 06:03 .geoipupdate.lock
-rw-r--r-- 1 root  root   8157979 Apr 21 04:01 GeoLite2-ASN.mmdb
-rw-r--r-- 1 root  root  72441306 Apr 21 04:01 GeoLite2-City.mmdb
-rw-r--r-- 1 root  root   5841222 Apr 21 04:01 GeoLite2-Country.mmdb

This was referenced Apr 25, 2023
oschwald added a commit that referenced this issue May 5, 2023
5.1.0

* Fixed the Docker health-check script to use the correct time of
  the last update attempt. Reported by cford1080. GitHub #225.
* Added new `--output` flag to print JSON to standard output describing
  the result of the run.
* Compilation with Go versions before 1.19 is no longer supported.
* When using the provided Docker images, `geoipupdate` no longer runs
  as root in the container. Based on pull request by Andreas
  Grünenfelder. GitHub #200.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants