feedernet / petnet-feeder-service

The Petnet v2 feeder has been hacked!
MIT License
87 stars 20 forks source link

Latest Image Broken #130

Open ky13d3nt0n opened 2 years ago

ky13d3nt0n commented 2 years ago

Had to reset my database and found that the latest image seems to be having troubles finding new feeders.

Was able to find an old image on Docker: https://hub.docker.com/r/tedder42/petnet-feeder-service and things are back up and running.

Checked error logs before and nothing was outputting as an issue, feeders were just never found.

kruton commented 2 years ago

I've been trying to upgrade the dependencies lately. This might have broken some stuff, but it also would reveal that we don't have enough testing. Perhaps some end-to-end testing is in order.

I'll try to straighten it out in the next day or so.

ky13d3nt0n commented 2 years ago

Got ya, no worries. Was able to get my feeders back up and working on the old image for now. But +1 on the testing for sure.

Appreciate it!

Sidenote: Is there anyway to grab a previous release of the package? https://github.com/feedernet/petnet-feeder-service/pkgs/container/petnet-feeder-service, it looks like only tagged releases here are latest. Kinda new to the GH packages.

jordan-hamilton commented 2 years ago

I noticed that a new setup (without an existing /data directory) caused 422 errors when adding a pet. Switching the Content-Type header on the /api/v1/pet POST request from text/plain to application/json resolved this for me, but it seems like all requests are text/plain and cause the same 422 error:

{"detail":[{"loc":["body"],"msg":"value` is not a valid dict","type":"type_error.dict"}]}

ky13d3nt0n commented 2 years ago

I noticed that a new setup (without an existing /data directory) caused 422 errors when adding a pet. Switching the Content-Type header on the /api/v1/pet POST request from text/plain to application/json resolved this for me, but it seems like all requests are text/plain and cause the same 422 error:

{"detail":[{"loc":["body"],"msg":"value` is not a valid dict","type":"type_error.dict"}]}

Yep, was able to hack together some quick js to get my pets created, feeders assigned, and schedules set. What's strange is I'm able to delete pets and scheduled events through the ui, but anything to do with POST or PUT methods seem to be failing

ky13d3nt0n commented 2 years ago
Screen Shot 2022-02-15 at 18 26 58

I saw that the application/json update was merged, but now seeing an error upon setup of feeder. Using the Manual Entry option for setting food weight sends me to a blank page. Whenever I try to do the Start weighing food option, it never seems to work.

I tried to manually register the feeder and it seems to register, but says:

 New feeders might take a few seconds to come online.

Once it has started communicating with the message broker, it will be available in the UI.

and the feeder never connects. Clicking on "Edit Feeder" also presents me with a blank page and react error.

zoeglynn commented 2 years ago

@ky13d3nt0n any chance you stashed your js workarounds in a form you can share? I'm trying to set up from scratch and ran into the same blank page on the latest image, and haven't had any success with the old images at https://hub.docker.com/r/tedder42/petnet-feeder-service, either.

(Or, have you been able to identify a working image, suitable for a Pi 4?)

kruton commented 2 years ago

I created a release and tagged it as '1.0.0' which should be stable. It's before I started upgrading all the backend stuff and realized our existing tests aren't covering everything.

zoeglynn commented 2 years ago

Thanks @kruton ! This is an awesome project. Pet & feeder setup worked with the 1.0.0 image, and the manual feed is working. But scheduled feeds fail to dispense, and the logs aren't spelling out a clear difference, or anything meaningful, as far as I can tell.

Logs around successful manual feed:

petnet-feeder-service    | 2022-02-26 17:03:22,331   INFO     uvicorn.access: 172.22.0.3:52726 - "POST /api/v1/feeder/2dd6dc3e65d6f5bac896e043f653456091e96bc3/feed HTTP/1.0" 200
petnet-feeder-service    | 2022-02-26 17:03:22,343   INFO     feeder.util.mqtt.client: Unknown message: krs/cmd/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"hid": "taxbhbbofktldcuofqqpteuqyesewvtv", "name": "SendCommand", "encrypted": false, "parameters": {"deviceHid": "2dd6dc3e65d6f5bac896e043f653456091e96bc3", "command": "feed", "payload": "{\\"portion\\": 0.0625}"}}')
petnet-feeder-service    | 2022-02-26 17:03:22,657   INFO     uvicorn.access: 172.22.0.3:52728 - "GET /api/v1/feeder/ HTTP/1.0" 200
petnet-feeder-service    | 2022-02-26 17:03:22,704   INFO     uvicorn.access: 172.22.0.3:52730 - "GET /api/v1/feeder/history?size=10&page=1 HTTP/1.0" 200
petnet-feeder-service    | 2022-02-26 17:03:22,831   INFO     feeder.util.mqtt.client: Unknown message: krs/api/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"requestId": "GS-2022-02-26T17:03:22.000Z", "eventName": "GatewayToServer_ApiRequest", "encrypted": false, "parameters": {"status": "OK"}}')
petnet-feeder-service    | 2022-02-26 17:03:23,393   INFO     feeder.util.mqtt.client: Unknown message: krs/api/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"requestId": "GS-2022-02-26T17:03:23.000Z", "eventName": "GatewayToServer_ApiRequest", "encrypted": false, "parameters": {"status": "OK"}}')

Logs around scheduled feed post:

petnet-feeder-service    | 2022-02-26 17:04:42,101   INFO     feeder.util.mqtt.client: Unknown message: krs/cmd/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"hid": "teirjxmtvkgaqvahoaglxxhiybiffous", "name": "SendCommand", "encrypted": false, "parameters": {"deviceHid": "2dd6dc3e65d6f5bac896e043f653456091e96bc3", "command": "schedule", "payload": "[{\\"active\\": true, \\"automatic\\": true, \\"feeding_id\\": \\"2dd6dc3e65d6f5ba_feed1_9:06AM\\", \\"name\\": \\"FEED0\\", \\"portion\\": 1.0, \\"reminder\\": true, \\"time\\": 32760}]"}}')
petnet-feeder-service    | 2022-02-26 17:04:42,125   INFO     uvicorn.access: 172.22.0.3:52776 - "PUT /api/v1/pet/1/schedule/1 HTTP/1.0" 200
petnet-feeder-service    | 2022-02-26 17:04:42,649   INFO     feeder.util.mqtt.client: Unknown message: krs/api/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"requestId": "GS-2022-02-26T17:04:42.000Z", "eventName": "GatewayToServer_ApiRequest", "encrypted": false, "parameters": {"status": "OK"}}')
petnet-feeder-service    | 2022-02-26 17:04:42,721   INFO     uvicorn.access: 172.22.0.3:52778 - "GET /api/v1/feeder/history?size=10&page=1 HTTP/1.0" 200
petnet-feeder-service    | 2022-02-26 17:04:43,148   INFO     feeder.util.mqtt.client: Unknown message: krs/api/stg/884cc6653cf24a926cc2ee4ca2c311fd2aa5779b => bytearray(b'{"requestId": "GS-2022-02-26T17:04:42.000Z", "eventName": "GatewayToServer_ApiRequest", "encrypted": false, "parameters": {"status": "OK"}}')

There did seem to be a correlated flurry of asyncio exceptions around the time of the scheduled feed the first few times I was testing (same as mentioned in https://github.com/feedernet/petnet-feeder-service/issues/61#issuecomment-780006948) but it has not been consistent.

Any troubleshooting advice?

ky13d3nt0n commented 2 years ago

@zoeglynn I was able to get things somewhat working with the form solution, but not everything. I ended up having to dig out one of my old sd cards with an image from maybe 8-10 months ago that is stable.

zoeglynn commented 2 years ago

thanks for the note @ky13d3nt0n. Any chance the image holds any clues about the revision it was built from? Or even the timestamp from docker inspect -f '{{ .Created }}' <image> so we could then reconstitute it?

ky13d3nt0n commented 2 years ago
Screen Shot 2022-03-08 at 18 59 51

Looks like it's just over a year old.

I was trying to look at ways to export the image, but not sure if that's going to bundle my database and whatnot.

kruton commented 2 years ago

I think I've fixed all the problems from the latest Bootstrap 5 upgrade with #206. I am still working on some end-to-end tests that test the Node.js frontend together with the Python backend to make sure we don't run into the same problems.