Skip to content

Conversation

@linkdd
Copy link
Collaborator

@linkdd linkdd commented Oct 1, 2024

Decision Record

The Netbox models a relationship that the local Docker daemon is not aware of:

erDiagram
    IMAGE ||--|| REGISTRY : "pull using"
Loading

When the agent is performing a "refresh", it has no way of knowing which registry was associated to the images it is recreating.

The PR #131 introduces one way of inferring the relationship, if the registry is named after the image (aka: they both have the same name). Otherwise, it fallbacks to "dockerhub".

However, this puts a constraint on the "Registry" entity in Netbox that is not modelled in said Netbox.

One easy solution is to duplicate that relationship on the agent, such that it is able to restore it when performing the "refresh".

Changes

  • ✨ Create $DATAPATH/image-registry.index.json file at startup, containing {}
  • ✨ When an image is successfully pulled, add the pair ${img.name}+":"+${img.version} = ${img.registry.id} to the index
  • ✨ When an image is deleted, remove it from the index
  • ✨ When a refresh is done, fetch the registry ID from the index, if not found fallback to the behavior introduced in Fix image registry not found #131
  • 🔖 v0.35.0

@linkdd linkdd self-assigned this Oct 1, 2024
@linkdd linkdd marked this pull request as ready for review October 2, 2024 10:42
@lvenier lvenier requested review from fanshan and lvenier October 2, 2024 11:37
Copy link
Contributor

@lvenier lvenier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the following error :

netbox-docker-agent level=info version=0.35.0 msg="\n{\n  image: [\n    \"Related object not found using the provided attributes: {'host': '25', 'ImageID': 'sha256:3d840293be1adba9c03706d33adbfb0c8f208e2d2d4a8053e0aa6c9c91ba545b'}\"\n  ]\n}"

Also refresh is not working on my current test env

{"name":["This field is required."]}

@lvenier
Copy link
Contributor

lvenier commented Oct 2, 2024

I have looked at the flow and here I would change :

  • Initialize Image/Registry Index as subflow makes no sense as it will be used once
  • It is never good to work on file directly. The best approach is to work on a global var et every Xsecs to flush the global into the file. Look at the save config in the INIT flow
  • in the "add host" registries are not used. should be the same as refresh
  • in the UI would be good to the registries with the associated image

@lvenier
Copy link
Contributor

lvenier commented Nov 6, 2024

this one is implemented in 1.0.0

@lvenier lvenier closed this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants