Skip to content

Treat 404 the same as an empty policy response

Brian Williams requested to merge bwill/fix-error-handling-for-policies into master

When a project does not have an ultimate license, we return 404 from the security policy endpoint. The agent currently treats this as an error, causing the logs to be polluted with errors for free-premium tier projects. We should treat this the same as an empty policy response.

Before

{"level":"info","time":"2022-10-25T09:07:07.491-0500","msg":"Observability endpoint is up","mod_name":"observability","net_network":"tcp","net_address":"[::]:8080"}
{"level":"info","time":"2022-10-25T09:07:07.562-0500","msg":"attempting to acquire leader lease gitlab-agent/agent-1-lock...\n","agent_id":1}
{"level":"info","time":"2022-10-25T09:07:07.626-0500","msg":"successfully acquired lease gitlab-agent/agent-1-lock\n","agent_id":1}
{"level":"info","time":"2022-10-25T09:07:07.626-0500","msg":"Event occurred","object":{"name":"agent-1-lock","namespace":"gitlab-agent"},"fieldPath":"","kind":"Lease","apiVersion":"coordination.k8s.io/v1","type":"Normal","reason":"LeaderElection","message":"gitlab-agent became leader","agent_id":1}
{"level":"error","time":"2022-10-25T09:07:08.345-0500","msg":"error checking security policies","mod_name":"starboard_vulnerability","error":"unexpected status code: 404","agent_id":1}
{"level":"error","time":"2022-10-25T09:07:20.541-0500","msg":"error checking security policies","mod_name":"starboard_vulnerability","error":"unexpected status code: 404","agent_id":1}
{"level":"error","time":"2022-10-25T09:07:53.012-0500","msg":"error checking security policies","mod_name":"starboard_vulnerability","error":"unexpected status code: 404","agent_id":1}

After

{"level":"info","time":"2022-10-25T09:06:01.639-0500","msg":"Observability endpoint is up","mod_name":"observability","net_network":"tcp","net_address":"[::]:8080"}
{"level":"info","time":"2022-10-25T09:06:07.338-0500","msg":"attempting to acquire leader lease gitlab-agent/agent-1-lock...\n","agent_id":1}
{"level":"info","time":"2022-10-25T09:06:07.370-0500","msg":"successfully acquired lease gitlab-agent/agent-1-lock\n","agent_id":1}
{"level":"info","time":"2022-10-25T09:06:07.370-0500","msg":"Event occurred","object":{"name":"agent-1-lock","namespace":"gitlab-agent"},"fieldPath":"","kind":"Lease","apiVersion":"coordination.k8s.io/v1","type":"Normal","reason":"LeaderElection","message":"gitlab-agent became leader","agent_id":1}
Edited by Brian Williams

Merge request reports