>Pretty sure the questions start and end with “was it illegal”.

Disclaimer: I don't have any skin in this game or association with any government, any law enforcement agency, nor do I know the person discussed or (at least as far as I know) anyone who knows that person. And IANAL.

IIUC (and I may not), the guy was on probation[0], which is release from or in lieu of prison.

If someone is on probation, they are still under the authority of the (in this case Federal) judicial/prison authority which sentenced them.

It is (whether you think it's right or not) normal for restrictions to be placed upon those on probation, including random drug tests, restrictions on certain types of behavior (this is often related to the crime(s) for which they've been convicted).

Often, this also provides for warrantless searches and other privacy-invading stuff as part of the probation agreement. I'd note that (again, IIUC) that the convicted person must agree to the terms of probation or they will have to go to (or not be released from) prison to serve their (remaining) sentence.

Violation of the terms of probation (as is clearly defined in probation agreements) may result in imprisonment to complete the sentence imposed by the court after trial or (as it was in this case) a plea bargain.

I am unfamiliar with the case at hand, but sending someone to (or back to) prison for violating probation is the stick which (presumably) keeps people from re-offending and/or violating the terms of their probation, at least until they complete the term of probation.

[0] https://www.uscourts.gov/about-federal-courts/probation-and-...