Currently it seems that Fleet Server is returning a 401 error when performing agent checkins and Fleet Server cannot communicate properly with Elastic Agent. This causes the Elastic Agents to go into automatical unenrollment which is bad (and requires a manual restart of Elastic Agent). Instead it should be returning a 503 error until its able to start communicating with elasticsearch properly.
Currently it seems that Fleet Server is returning a 401 error when performing agent checkins and Fleet Server cannot communicate properly with Elastic Agent. This causes the Elastic Agents to go into automatical unenrollment which is bad (and requires a manual restart of Elastic Agent). Instead it should be returning a 503 error until its able to start communicating with elasticsearch properly.
I believe the issue is this code here: https://github.com/elastic/fleet-server/blob/main/internal/pkg/apikey/auth.go#L54-L60