nanos / FediFetcher

FediFetcher is a tool for Mastodon that automatically fetches missing replies and posts from other fediverse instances, and adds them to your own Mastodon instance.
https://blog.thms.uk/fedifetcher?utm_source=github
MIT License
293 stars 213 forks source link

label:"help wanted" error on k3s, but not in bash #111

Closed RJGhugo closed 2 months ago

RJGhugo commented 2 months ago

I can run FediFetcher from bash without issue.

{ "access-token": "TOKEN_xxxxxxxxxxxxxxxxxxxxx", "server": "mastodon.xx.xx", "home-timeline-length": 200, "max-followings": 80, "from-notifications": 1 }

but not inside a k3s/k8s pod.

apiVersion: apps/v1 kind: StatefulSet metadata: name: fedifetcher spec: selector: matchLabels: app: fedifetcher template: metadata: labels: app: fedifetcher spec: containers:

  • name: fedifetcher image: ghcr.io/nanos/fedifetcher:latest args:
  • --server=mastodon.xx.xx
  • --access-token=["TOKEN_xxxxxxxxxxxxxxxxxxxxx"]
  • --home-timeline-length
  • "200"
  • --max-followings
  • "80"
  • --from-notification
  • "4" resources: requests: memory: "64Mi" cpu: "0.1" limits: memory: "1Gi" cpu: "1" volumeMounts:
  • name: fedifetcher mountPath: "/app/artifacts" volumes:
  • name: fedifetcher persistentVolumeClaim: claimName: nfs-mastodon-fedifetcher
nanos commented 2 months ago

Don’t leave me hanging: What happens on k3s?

RJGhugo commented 2 months ago

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn 2024-04-18 05:56:54.009683 UTC: Starting FediFetcher 2024-04-18 05:56:59.032337 UTC: Error getting timeline toots: HTTPSConnectionPool(host='mastodon.xx.xx', port=443): Max retries exceeded with url: /api/v1/timelines/home (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7268d1af5150>: Failed to establish a new connection: [Errno 101] Network unreachable')) 2024-04-18 05:56:59.047916 UTC: Job failed after 0:00:05.038199. conn = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) OSError: [Errno 101] Network unreachable

nanos commented 2 months ago

OSError: [Errno 101] Network unreachable

This is gonna be your root cause: Your container can't reach your network.

RJGhugo commented 2 months ago
    spec:
      hostNetwork: true
      containers:
      - name: fedifetcher
        image: ghcr.io/nanos/fedifetcher:latest

I had to add hostNetwork: true. Else the CronJob has no access to the outer network...

nanos commented 2 months ago

Glad you got that sorted. I guess we should add that to the example file.

Are you able to provide a PR by any chance?

RJGhugo commented 2 months ago

The problem was the lack of knowledge about network functionality in k3s.

A pod uses the internal DNS structure and cannot access resources in the LAN (e.g. proxy).

As I understood...

A PR doesn't seem appropriate here.

nanos commented 2 months ago

OK, great. Thanks for the feedback, and I'll close the issue again then.