-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix(registration): handle 401 on update with reregistration #16
Conversation
Not sure if I undestand it correctly, but i saw this when loggin
Seems to deregister and just "stopped"? Same happened to Editted: Oh never mind. I think I forgot to rebuild the agent. |
Looks working as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022-12-19 19:37:41,780 INFO [io.cry.age.Registration] (cryostat-agent-worker-2) publishing self as service:jmx:rmi:///jndi/rmi://cryostat:9097/jmxrmi 2022-12-19 19:37:41,806 SEVERE [io.cry.age.CryostatClient] (ForkJoinPool.commonPool-worker-1) Non-OK response (401) on HTTP API https://localhost:8181/api/v2.2/discovery/79ed4412-9488-40b9-92b1-3e23a152d0b1?token=eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..qrlA00sWLx-7fcOR.vS4VQyM_8dXz4pH7gfHZRtESFys1gzzkMcfKWszfoz7zbkF-I10kC5GrhuDCzSwUKtbSUaOfXYrUhtf1DDNNaX1noHXy41AmQxRkX9pWIpDlTjwmdxPhwX-f3GLZGd-HJlYJhftyu0zIx7eRneJ4biI33FB2j32SnpTI33VQZezPMfZbI962MDY3qSXdApHs-AIh0rVRG7oiIGmllmMAtTfyZTzvpc6N2YV8nxMOPQoHWpO55OSR94Z0ty4jnDFOLgmksjLsxC71wperom_Mb0eTsGUIb_fZwTEr308ADcpYGCwWBqgIHD0WIMqzn8ZA1goZrO6s6eYP1dXVvXCLS5Bmr0vV0zg2Y44hGSzV4kJpK_NVkdsW5oxBJ9aQv9pfyJZRGC3GsdUcUIWlloEF0bLQWA0CQguju7Lcrr0nDr6SSPDZNWu568tmlKOaaHUVCyz89c_sz6ckN9Db-spIBaxGokLO9aS6Uvc9tMgGkRnY0mmGsYkfkBz7Y91a_IzMxGoP9xmNscCfp3-LHEyHbrY4eXQiEVO7REF7RsTdlWVvZYvyg_KbS5fH2WOCQVdFYfse8bWvSA.4NgkJYJOAqIRlzZCB8GNqA 2022-12-19 19:37:41,806 SEVERE [io.cry.age.Registration] (cryostat-agent-worker-0) Update failure: java.util.concurrent.CompletionException: io.cryostat.agent.HttpException: Unexpected non-OK status code 401 on API path https://localhost:8181/api/v2.2/discovery/79ed4412-9488-40b9-92b1-3e23a152d0b1 at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649) at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:844) at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) Caused by: io.cryostat.agent.HttpException: Unexpected non-OK status code 401 on API path https://localhost:8181/api/v2.2/discovery/79ed4412-9488-40b9-92b1-3e23a152d0b1 at io.cryostat.agent.CryostatClient.assertOkStatus(CryostatClient.java:206) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646) ... 9 more 2022-12-19 19:37:41,847 INFO [io.cry.age.Registration] (cryostat-agent-worker-2) Deregistered from Cryostat discovery plugin [79ed4412-9488-40b9-92b1-3e23a152d0b1] 2022-12-19 19:37:46,863 INFO [io.cry.age.Registration] (cryostat-agent-worker-0) Registered as a9418965-204f-4198-bf4d-cddfca949ee7 2022-12-19 19:37:46,864 INFO [io.cry.age.Registration] (cryostat-agent-worker-0) publishing self as service:jmx:rmi:///jndi/rmi://cryostat:9097/jmxrmi 2022-12-19 19:37:47,024 INFO [io.cry.age.Registration] (cryostat-agent-worker-2) Publish success
Looks working as expected.
Worked as expected for me too.
Fixes #15
To test, I have two possible procedures. The first is the way I accidentally noticed this behaviour. Run the Cryostat
smoketest.sh
and put the laptop to sleep for a while with everything spun up and running. The default discovery ping period is 5 minutes, but theCRYOSTAT_DISCOVERY_PING_PERIOD
variable can be set to reduce that time for faster testing cycles. Put the host machine to sleep for at least the ping period, then awaken the machine again and check the logs. The Cryostat logs should reflect that it is responding401
to the agent(s) because their JWTs are expired. Before this PR this will continue repeating. After this PR, the agents should see the first 401 and react by refreshing their registration, so no subsequent 401s should occur.To simplify that testing procedure, this patch can also be applied to the Cryostat backend:
This means 10% of the time, the agents' attempt to publish updates will fail with a 401. The
0.9
can be adjusted to make this more likely.