woodpecker-ci / woodpecker

Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
3.95k stars 351 forks source link

30'000 or more agent entries in database #2479

Closed dR3b closed 10 months ago

dR3b commented 10 months ago

Component

agent

Describe the bug

sqlite> select * from agents;:

88|1693396312|1693396312||-1|yYT|0|||-1||0
89|1693396372|1693396372||-1|yYT|0|||-1||0
90|1693396432|1693396432||-1|yYT|0|||-1||0
...
29862|1695189008|1695189008||-1|yYT|0|||-1||0
29863|1695189068|1695189068||-1|yYT|0|||-1||0
29864|1695189129|1695189129||-1|yYT|0|||-1||0
29865|1695189189|1695189189||-1|yYT|0|||-1||0
29866|1695189249|1695189249||-1|yYT|0|||-1||0
29867|1695189309|1695189309||-1|yYT|0|||-1||0
29868|1695189370|1695189370||-1|yYT|0|||-1||0

System Info

version "next-6d86ec7fe7"
image: woodpeckerci/woodpecker-agent:latest
image: woodpeckerci/woodpecker-server:next


### Additional context

_No response_

### Validations

- [X] Read the [Contributing Guidelines](https://github.com/woodpecker-ci/woodpecker/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://woodpecker-ci.org/docs/intro).
- [X] Check that there isn't [already an issue](https://github.com/woodpecker-ci/woodpecker/issues) that reports the same bug to avoid creating a duplicate.
- [X] Checked that the bug isn't fixed in the `next` version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
- [X] Check that this is a concrete bug. For Q&A join our [Discord Chat Server](https://discord.gg/fcMQqSMXJy) or the [Matrix room](https://matrix.to/#/#woodpecker:matrix.org).
anbraten commented 10 months ago

Every restart is resulting in a new agent when using the system token. There was a PR merged which saves the agent-id to a file. Please try next version for the agent as well

dR3b commented 10 months ago

Ok now I use the next image on the agent too. But every container restart its always creating a "new" agent:

[0]# sqlite3 /srv/docker/woodpecker/app/data/woodpecker.sqlite
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite>
sqlite> select * from agents limit 20;
29943|1695192746|1695192866||-1|yYT|1695192866|linux/amd64|docker|4|next-6d86ec7fe7|0
29944|1695192872|1695192872||-1|yYT|1695192872|linux/amd64|docker|4|next-6d86ec7fe7|0

[0]# docker-compose up -d --force-recreate
Recreating woodpecker-agent ... done
Recreating woodpecker-app   ... done

[0]# sqlite3 /srv/docker/woodpecker/app/data/woodpecker.sqlite
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> select * from agents limit 20;
29943|1695192746|1695192866||-1|yYT|1695192866|linux/amd64|docker|4|next-6d86ec7fe7|0
29944|1695192872|1695193032||-1|yYT|1695193032|linux/amd64|docker|4|next-6d86ec7fe7|0
29945|1695193037|1695193037||-1|yYT|1695193037|linux/amd64|docker|4|next-6d86ec7fe7|0
runephilosof-karnovgroup commented 10 months ago

If you want the agent to remember its id, you need to give it a persistent volume. Like here https://woodpecker-ci.org/docs/administration/agent-config

# docker-compose.yml
version: '3'

services:
  woodpecker-agent:
    [...]
    volumes:
      - woodpecker-agent-config:/etc/woodpecker
dR3b commented 10 months ago

@runephilosof-karnovgroup Thanks! I found the solution too.