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

src/handlers.rs: explicitly handle INVALIDATE, SHUTDOWN, GETFD* #38

Merged
merged 5 commits into from
Nov 20, 2022

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Oct 10, 2022

In both cases, we want to no-op. The client doesn't expect any response from nscd, but let's at least log a debug message on why we're no-op'ing here, to distinguish from the operations that are not yet implemented.

@flokli
Copy link
Contributor Author

flokli commented Oct 12, 2022

I saw the GETFD* requests on the wire when working on reverse host lookups (while adding GETHOSTBYADDR*) support as part of #37.

@geofft @leifwalsh WDYT?

@leifwalsh leifwalsh requested a review from geofft October 12, 2022 23:10
@leifwalsh
Copy link
Collaborator

Seems reasonable to me

In both cases, we want to no-op. The client doesn't expect any response
from nscd, but let's at least log a debug message on why we're no-op'ing
here, to distinguish from the operations that are not yet implemented.
These will normally send an FD pointing to the internal cache structure,
which clients use to look into the cache contents on their own.

We don't cache, and we don't want clients to poke around in cache structures either.
Luckily clients fall back to explicit queries if no FDs are sent over.
@flokli flokli changed the title src/handlers.rs: explicitly handle INVALIDATE and SHUTDOWN src/handlers.rs: explicitly handle INVALIDATE, SHUTDOWN, GETFD* Oct 13, 2022
@flokli flokli mentioned this pull request Oct 14, 2022
Copy link
Collaborator

@geofft geofft left a comment

Choose a reason for hiding this comment

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

Hmm, not unreasonable but I'm curious about the motivation. I feel like I'd do it the other way around - all of these really should get no response but the rest of them are unimplemented and it might be worth noting if we get one.

Should we (also? instead?) log the unimplemented requests? The enum derives Debug so we can just log the actual request value.

(Also now that I'm looking at this it occurs to me that LASTREQ isn't actually a valid protocol request. :) )

RequestType::GETHOSTBYADDR
| RequestType::GETHOSTBYADDRv6
| RequestType::GETHOSTBYNAME
| RequestType::GETHOSTBYNAMEv6
| RequestType::SHUTDOWN
| RequestType::GETSTAT
Copy link
Collaborator

Choose a reason for hiding this comment

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

This returns statistics about the daemon - you can also mark this as will-not-implement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? I've been thinking about exposing some prometheus-style metrics on the number of requests, success rate and timing Information, by request type. That'd of course primarily be exposed via http, but if that getstat call is actually usable to expose some of these numbers, and there's some userspace tool to query and show, why not?

@flokli
Copy link
Contributor Author

flokli commented Oct 16, 2022

Hmm, not unreasonable but I'm curious about the motivation. I feel like I'd do it the other way around - all of these really should get no response but the rest of them are unimplemented and it might be worth noting if we get one.

I was mostly concerned about having a distinction in code if something has not been implemented yet, or if we consciously decided it's okay to return no data, and userspace can cope with it.

Should we (also? instead?) log the unimplemented requests? The enum derives Debug so we can just log the actual request value.

I think we already debug! the request in main.rs.

(Also now that I'm looking at this it occurs to me that LASTREQ isn't actually a valid protocol request. :) )

Can you elaborate? It's not something that ever happens to be sent out by the client, or it's something where we should always pretend to have not yet have had any previous request?

@flokli
Copy link
Contributor Author

flokli commented Oct 16, 2022

Btw, can these workflows be changed to not require approval? It'd be nice to immediately get feedback on the various GH action checks...

@leifwalsh
Copy link
Collaborator

It's set to require approval for first time contributors, to prevent something like someone running a crypto miner using actions. Once we get you that CLA (#44) and merge some PRs from you you'll be good.

@flokli
Copy link
Contributor Author

flokli commented Nov 18, 2022

Is this good to go?

@leifwalsh
Copy link
Collaborator

I feel like I'd do it the other way around - all of these really should get no response but the rest of them are unimplemented and it might be worth noting if we get one.

Should we (also? instead?) log the unimplemented requests? The enum derives Debug so we can just log the actual request value.

I like the gist of this: it clarifies which operations we'll never implement and makes it clear which remain to be implemented. We can log the unimplemented ones (at info? warn?) later.

I'm gonna merge this for now, we can tweak later (e.g. doing something with LASTREQ).

@leifwalsh leifwalsh enabled auto-merge (squash) November 20, 2022 02:42
@codecov-commenter
Copy link

Codecov Report

Base: 30.04% // Head: 29.22% // Decreases project coverage by -0.82% ⚠️

Coverage data is based on head (c6282ba) compared to base (e3de17c).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   30.04%   29.22%   -0.83%     
==========================================
  Files           5        5              
  Lines         213      219       +6     
==========================================
  Hits           64       64              
- Misses        149      155       +6     
Impacted Files Coverage Δ
src/handlers.rs 33.33% <0.00%> (-2.23%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@leifwalsh leifwalsh merged commit 276333c into twosigma:main Nov 20, 2022
@flokli flokli deleted the invalidate-shutdown branch October 31, 2023 07:18
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.

4 participants