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

Add hooks and other improvements #1257

Merged

Conversation

BrianBaboch
Copy link
Contributor

No description provided.

@svinota svinota requested a review from etene January 24, 2025 17:15
pyroute2/dhcp/client.py Show resolved Hide resolved
pyroute2/dhcp/hooks.py Outdated Show resolved Hide resolved
pyroute2/dhcp/leases.py Outdated Show resolved Hide resolved
@svinota
Copy link
Owner

svinota commented Jan 24, 2025

@etene beside of ip.route('del', …) LTGM, but review pls too

pyroute2/dhcp/dhcp4msg.py Outdated Show resolved Hide resolved
pyroute2/dhcp/hooks.py Outdated Show resolved Hide resolved
pyroute2/dhcp/hooks.py Show resolved Hide resolved
pyroute2/dhcp/hooks.py Outdated Show resolved Hide resolved
pyroute2/dhcp/hooks.py Outdated Show resolved Hide resolved
pyroute2/dhcp/hooks.py Show resolved Hide resolved
pyroute2/dhcp/leases.py Outdated Show resolved Hide resolved
@BrianBaboch BrianBaboch force-pushed the add-hooks-and-other-improvements branch from d19d44c to abfc20a Compare January 27, 2025 13:23
pyroute2/dhcp/hooks.py Outdated Show resolved Hide resolved
@BrianBaboch BrianBaboch force-pushed the add-hooks-and-other-improvements branch from abfc20a to 1485932 Compare January 27, 2025 17:28
pyroute2/dhcp/leases.py Outdated Show resolved Hide resolved
@etene
Copy link
Collaborator

etene commented Jan 27, 2025

@BrianBaboch if you could replace "s with 's it would better match the current project code style

@BrianBaboch BrianBaboch force-pushed the add-hooks-and-other-improvements branch from 1485932 to 2c658c6 Compare January 27, 2025 18:46
# "dev",
# lease.interface,
# )
LOG.info('Adding %s/%s to %s', lease.ip,
Copy link
Owner

Choose a reason for hiding this comment

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

Not for this PR, just an idea for some future refactoring — go through the code and make all the logging in one single parsable format, be it golang key=value or json or anything else, but that could have single handler in the log collection stacks like loki/grafana or victorialogs. (looking is there any "make a ticket from this comment" :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do that in production, but it does not necessarily entail going through all logging calls. We use the "logfmt" format with a custom logging formatter and that does the trick, we can export them to loki.

Since pyroute2 is a library, i believe logging format should be up to the callers anyway.

LOG.error('Lease does not set the router option')
return
LOG.info('Removing %s as default route.', lease.default_gateway)
async with AsyncIPRoute() as ipr:
Copy link
Owner

@svinota svinota Jan 27, 2025

Choose a reason for hiding this comment

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

Again, not a request to change the code.

Would we benefit if I add an option like "idempotent" (default False) to AsyncIPRoute — that would ignore EEXIST for add and ENOENT for del calls?

Nope, ignore that. I went through possible situations and it looks like such behaviour would contribute more to problems than solutions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the most useful thing we could do in that regard would be to raise specific exceptions for errno codes, and make them inherit NetlinkError. That way, we wouldn't break any existing code while still allowing callers to catch specific exceptions instead of comparing the error code manually.

Copy link
Owner

Choose a reason for hiding this comment

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

A good idea, thanks.

@svinota
Copy link
Owner

svinota commented Jan 28, 2025

Are we ready to merge it?

@etene etene merged commit 7eeb28a into svinota:p10-dhcp-protocol Jan 28, 2025
3 checks passed
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