Policies: Conflict error when the same policy is applied by multiple datasets
The problem can be checked here:
https://qa.ops.orb.live/staging/a33d08b2/orb/python-test/output/
Sounds as a intermittent behavior and the points to check is described below:
- Name conflict error code returned is 500 (instead of 409)
'{"level":"warn","ts":"2022-07-22T13:46:11.167Z","caller":"policyMgr/manager.go:193","msg":"policy failed to apply","policy_id":"28b7a7e9-0a8b-40c0-b29e-a333abe1a646","policy_name":"test_policy_name_KKJyfNOYiL","error":"500 policy with name /'test_policy_name_KKJyfNOYiL/' already defined"}'
-
The error occurs when the policy is applied through a dataset and not when it is created (at the time of creation, the policy was created normally because there was no other with the same name).
-
The error appears in the log before the success case
'{"level":"info","ts":"2022-07-22T13:46:11.167Z","caller":"pktvisor/pktvisor.go:261","msg":"pktvisor stdout","log":"[2022-07-22 13:46:11.167] [visor] [info] REQUEST: POST /api/v1/policies 500"}', '{"level":"info","ts":"2022-07-22T13:46:11.167Z","caller":"pktvisor/pktvisor.go:261","msg":"pktvisor stdout","log":"[2022-07-22 13:46:11.167] [visor] [error] {//"error//"://"policy with name /'test_policy_name_KKJyfNOYiL/' already defined//"}"}', '{"level":"warn","ts":"2022-07-22T13:46:11.167Z","caller":"pktvisor/pktvisor.go:189","msg":"yaml policy application failure","policy_id":"28b7a7e9-0a8b-40c0-b29e-a333abe1a646","policy":"version: //"1.0//"//nvisor://n policies://n test_policy_name_KKJyfNOYiL://n handlers://n modules://n default_net_ikG://n filter: {}//n type: net//n input://n config: {}//n filter: {}//n input_type: pcap//n tap: default_pcap//n kind: collection//n"}', '{"level":"warn","ts":"2022-07-22T13:46:11.167Z","caller":"policyMgr/manager.go:193","msg":"policy failed to apply","policy_id":"28b7a7e9-0a8b-40c0-b29e-a333abe1a646","policy_name":"test_policy_name_KKJyfNOYiL","error":"500 policy with name /'test_policy_name_KKJyfNOYiL/' already defined"}', '{"level":"info","ts":"2022-07-22T13:46:11.168Z","caller":"policyMgr/manager.go:197","msg":"policy applied successfully","policy_id":"28b7a7e9-0a8b-40c0-b29e-a333abe1a646","policy_name":"test_policy_name_KKJyfNOYiL"}', '{"level":"info","ts":"2022-07-22T13:46:11.170Z","caller":"pktvisor/pktvisor.go:261","msg":"pktvisor stdout","log":"[2022-07-22 13:46:11.169] [visor] [info] REQUEST: POST /api/v1/policies 200"}', '{"level":"info","ts":"2022-07-22T13:46:11.656Z","caller":"policyMgr/manager.go:55","msg":"managing agent policy from core","action":"manage","name":"test_policy_name_KKJyfNOYiL","dataset":"0ccf54f7-79d5-4ca2-b108-ef70419dd8bd","backend":"pktvisor","id":"28b7a7e9-0a8b-40c0-b29e-a333abe1a646","version":0}'
At the end of the process, one of the datasets failed to be applied to the agent (even without any error in the log regarding this, the two policies should have 3 linked datasets and the policy whose id is '28b7a7e9-0a8b-40c0-b29e-a333abe1a646' only got 2).
So the action points for this issue are:
-
Investigate why return 500 in this case (even after this fix #1421)
-
Check the reason for a policy name conflict error in the application of this policy to the agent
-
Check the asynchronous performance of the cod and understand why the error happens even before the successful application.
it is happening more frequently: https://qa.ops.orb.live/orb/production/d929e192/orb/python-test/output/
