Skip to content

Implemented health check route#428

Open
kartikgoyal137 wants to merge 7 commits intobl4ze/devfrom
kiritov2/healthcheck
Open

Implemented health check route#428
kartikgoyal137 wants to merge 7 commits intobl4ze/devfrom
kiritov2/healthcheck

Conversation

@kartikgoyal137
Copy link

/status/health/:name displays cpu_percentage, memory_percentage and memory_usage in bytes.
Does simple challenge use any cpu? It came 0 percent.
Added three functions in package cr containers.go, GetContainerStats, GetContainerLimits and RestartContainer
beast health-probe also logs the memory usage.

@kartikgoyal137 kartikgoyal137 changed the base branch from master to bl4ze/dev October 7, 2025 12:33
@v1bh475u v1bh475u requested a review from DarkPhoenix42 October 8, 2025 20:56
@@ -0,0 +1,5 @@

Choose a reason for hiding this comment

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

Why is this file pushed?

Copy link
Author

Choose a reason for hiding this comment

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

probably during setup and build. Will remove

api/router.go Outdated
statusGroup.GET("/challenge/:name", challengeStatusHandler)
statusGroup.GET("/all", statusHandler)
statusGroup.GET("/all/:filter", statusHandler)
statusGroup.GET("/health/:name", ChallengeHealthHandler)

Choose a reason for hiding this comment

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

Why is this route unauthorized?

Copy link
Author

Choose a reason for hiding this comment

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

the authorise middleware is there in the whole api group on line 53. Do i need to create a separate auth for status group?

@DarkPhoenix42
Copy link

Please remove all the irrelevant changes i.e version upgrades from the mod files. Also, did you manage to test this and get accurate usage statistics for the containers?

@kartikgoyal137
Copy link
Author

kartikgoyal137 commented Dec 12, 2025

memory part is accurate and working fine, however the CPU still returns 0 even if I print the absolute amount instead of difference.
I ran the healthprobe in a go routine as it was exiting and added resource limits to example challenges (otherwise there was an error while running). Should I keep these changes?

@kartikgoyal137
Copy link
Author

@DarkPhoenix42 reverted go.mod and go.sum files


// API routes group
apiGroup := router.Group("/api", authorize)
apiGroup := router.Group("/api",

Choose a reason for hiding this comment

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

The "authorize" middleware has been removed from this entire group. Please fix it. Also, we only want admins to be able to access the healthcheck route, so move this endpoint to an appropriate group.

Signed-off-by: kartikgoyal137 <kartikcodes137@gmail.com>
@kartikgoyal137
Copy link
Author

Done. Put it as a separate route with adminauthorize middleware

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.

2 participants