Skip to content

migrate printhost to nix#240

Merged
BNH440 merged 142 commits into
mainfrom
printhost-migration-v2
Apr 13, 2026
Merged

migrate printhost to nix#240
BNH440 merged 142 commits into
mainfrom
printhost-migration-v2

Conversation

@BNH440

@BNH440 BNH440 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

migrates the whiteout config with some MAJOR CHANGES:

  • replacing tea4cups with a new drop-in backend
  • drop all custom ocf postscript filters and replace the filter stack with the official hp and epson drivers
  • replaced enforcer-pc (page counter) with a very similar python implementation
  • removed enforcer-size (A5 / non-letter print blocker) as the clients now understand the printer's supported page sizes
  • fixed clients not understanding printer capabilities (SEE BELOW)
    • now that clients understand the options the printers provide, we can have TWO classes, OCF-BW for black&white, and OCF-Color for color
  • use socket for all printers (including epson, epson used ipp on whiteout)
    • why? turns out socket is just way faster, it causes the printers to queue a set of prints locally which allows them to print multiple documents in a row without spooling down and back up again. (as opposed to the jobs all queuing in the cups queue before being sent after the printer is confirmed finished printing the last doc)
    • what about tls? with ipps (which we weren't actually using on epson with whiteout) we can have an encrypted connection, but due to what I mentioned above, the extra security of ipps is just not worth the speed difference
  • basically the entire printing pipeline is just different now (SEE BELOW)

note: I did NOT go with the approach I mentioned a few days ago about having a client side cups server that did the filtering (driver stack / postscript conversion) and then sent to a remote cups server. I ended up having a lot of problems with double filtering, but the main reason was that I discovered I could create basically the same pipeline without any of the downsides by using a fake printer in front of the class. (which is what the client did but just more complicated) So we are NOT using cups-browsed or anything related to it anymore (compared to the double cups server approach).

note: we are still billing by sides of paper because counting physical pages before sending to the printer is very difficult. more details:

you can either wait until the job finishes and check the cups variables for how many physical sheets the printer printed (which doesn't work for a quota check pre-hook)
or you can calculate the physical pages yourself by dividing by 2 if duplex is enabled. the only issue is that I couldn't find a good way to get whether duplex was enabled when I was testing earlier

Why did clients not understand the printer capabilities (page size, double sided, etc)

  • we previously needed to have a queue for every double sided option (-double, -single), which is no longer required because the client now receives more detailed information about the printer from the server, which makes the double sided dialogue show up as the client knows it's supported
  • the main difference is we used to advertise cups classes from the server, and cups classes send minimal information on the capabilities of the printers the contain
  • now we still use classes as the load balancer (for B&W), but we put a "fake" printer in front of the class, which points to the class's ipp url. the big difference is that a printer in cups can advertise a ppd / printer driver that contains the printer's capabilities.

New Pipeline

image

What changes for the user?

the user will now see OCF-BW and OCF-Color, they will choose between those as usual, but for double sided they can change the two-sided setting on the print dialog.

The black and white default is double sided and the color default is single sided. I think this best represents what most people use the two modes for (B&W for documents, Color for fliers).

TODO in the future

  • modify dns to point printhost.ocf.berkeley.edu to tule (and modify client to point to printhost again)
    new color printer installation
  • add new color printer
    • due to new color printer being HP, we can basically just duplicate the method we used for the BW printers (but just have one printer in the color class), this is preferable over keeping the current 1 stage print pipeline that we have for the epson because it will have the correct printer destination name in wayout and the db
  • OAuth for management operations: we tried to get kerberos working before realizing it's now deprecated in favor of OAuth. We plan on integrating OAuth with auth.ocf.berkeley.edu (which will also auto login on desktops with a kerberos ticket). Except OAuth is added in CUPS 2.5, which is currently in beta. We can update and configure this once cups is updated in nixpkgs.
  • rewrite enforcer and the new tea4cups compatible backend to make things simpler

ongoing issues

fixed issues:
- need to check printing from servers (lp works)
- need to check print failure emails (works!)
- need to check A5 printing (it auto scales to letter 🎉)
- billing seems to be incorrect for copies (at least on BW) (FIXED)
- color printing broken (filter failed) (FIXED)
- the user.js change didn't work d1607ac (FIXED)
QUOTA IS NOT CHECKED!!! - need to add back the postscript filter for page count and remove epson support (FIXED 🎉)

@BNH440
BNH440 force-pushed the printhost-migration-v2 branch 14 times, most recently from 2b0be7d to c649404 Compare April 8, 2026 18:44
BNH440 added 16 commits April 8, 2026 15:02
this commit directly migrates the old puppet config with a few
differences:
- replacing tea4cups with a new drop-in backend
- adding color-double queue to get ready for new color printer
- remove old browse directives no longer supported in cups v2
- disable mDNS / avahi service to not conflict with cups' own service
the printhost url config variable is set to default on all machines
except tule so we have to just set it manually
fixes the print dialog long loading time, but we need a better solution
in the future
BNH440 added 8 commits April 11, 2026 16:13
- moved ssl cert moving to its own service as to not override the
existing preStart script provided by the nixos module
- removed the raw.convs configs as those don't seem to do anything anyways
for some reason the print dialog opens quickly now, not sure what changed
so we can re-enable this
@BNH440
BNH440 requested a review from oliver-ni April 12, 2026 00:17
it will be way easier to migrate dns if we have the live url not
conflict with the future dns changes. we can set this url to
printhost.obe after modifying the dns
@BNH440

BNH440 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

ok I actually decided to change the server url from printhost-dev to tule on the desktops so when we move dns printhost-dev to printhost it won't interrupt lab operations

@BNH440

BNH440 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

I plan on changing dns on monday after we've proved tule works well in a normal day of lab operations

@BNH440
BNH440 disabled auto-merge April 12, 2026 00:45
@BNH440

BNH440 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

ok TLS is broken from the client to server and idk why, I set encryption to IfRequested which masked the issue, but that should preferably be fixed, although idk if it should be a requirement tbh

@BNH440

BNH440 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

ok the TLS issue we're having has been fixed and will be in a later update
OpenPrinting/cups#1128

@BNH440
BNH440 enabled auto-merge (rebase) April 12, 2026 01:21
@BNH440
BNH440 disabled auto-merge April 12, 2026 01:21
@BNH440
BNH440 enabled auto-merge (squash) April 12, 2026 01:22
@BNH440
BNH440 disabled auto-merge April 13, 2026 05:00
@BNH440

BNH440 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

disabled auto merge so this doesn't get auto deployed during lab hours on Monday if approved

oliver-ni
oliver-ni previously approved these changes Apr 13, 2026
@BNH440

BNH440 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

oh I didn't realize that would cancel the review 😭

@BNH440
BNH440 merged commit 98ef554 into main Apr 13, 2026
3 checks passed
@BNH440
BNH440 deleted the printhost-migration-v2 branch April 13, 2026 23:10
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