Skip to content
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

RHINENG-5011 playbook not getting dispatched with POST /profiles #153

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

r14chandra
Copy link
Collaborator

Why do we need this change? 💭

Playbook was not getting dispatched on requesting POST /profiles. This was mainly because we are currently getting 401 Unauthorized Status in the response due to missing X-Rh-Identity field in context.Context - we are sending context.Background() and we don't get any error i.e. the request was successfully sent, but the server responded with a 401 Unauthorized status. Due to this, it goes to ApplyProfile function with no hosts where it doesn't fall into any code block. Hence, nothing happens.

Logs without fix

{"level":"debug","org_id":"0002","num_hosts":0,"timestamp":"2024-03-27T18:10:59.534168816+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/host.go:46","message":"applying profile for hosts"}

Below are the logs with the fix when identity header is provided.

{"level":"debug","org_id":"0002","num_hosts":1,"timestamp":"2024-03-27T18:11:27.314342855+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/host.go:46","message":"applying profile for hosts"}
{"level":"debug","org_id":"0002","client_id":"4b1efbbe-a447-48d0-98c3-3594aae1d2c5","timestamp":"2024-03-27T18:11:27.314353851+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/host.go:54","message":"creating run for host"}
{"level":"debug","start":0,"end+1":1,"timestamp":"2024-03-27T18:11:27.314367885+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/host.go:76","message":"batching runs"}
{"level":"debug","http_client":"playbook-dispatcher","http_status":"207 Multi-Status","timestamp":"2024-03-27T18:11:27.319437834+05:30","caller":"/home/rohinichandra/Rohini/config-manager/infrastructure/persistence/dispatcher/dispatcher.go:78","message":"received response from playbook-dispatcher"}
{"level":"debug","http_client":"playbook-dispatcher","runs_created":[{"code":201,"id":"6845182c-880c-4a7d-8664-064fcf321615"}],"timestamp":"2024-03-27T18:11:27.319466795+05:30","caller":"/home/rohinichandra/Rohini/config-manager/infrastructure/persistence/dispatcher/dispatcher.go:85","message":"runs created"}
{"level":"trace","org_id":"0002","runs_created":[{"code":201,"id":"6845182c-880c-4a7d-8664-064fcf321615"}],"timestamp":"2024-03-27T18:11:27.319475304+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/host.go:83","message":"dispatched work to playbook-dispatcher"}
{"level":"info","profile_id":"eaad1e5c-4b60-475b-adb0-1b1210a05d9c","timestamp":"2024-03-27T18:11:27.319481669+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/dispatch/dispatch.go:33","message":"applied profile"}

Below are the logs with the fix when identity header is not provided.

{"level":"error","error":"unable to get inventory clients: received non-200 status code: 401, response body: {\n  \"detail\": \"No authorization token provided\",\n  \"status\": 401,\n  \"title\": \"Unauthorized\",\n  \"type\": \"about:blank\"\n}\n","timestamp":"2024-03-27T18:42:19.226713932+05:30","caller":"/home/rohinichandra/Rohini/config-manager/internal/dispatch/dispatch.go:28","message":"cannot get hosts from inventory"}

Documentation update? 📝

  • Yes
  • No

💂‍♂️ Checklist 🎯

  • Bugfix
  • New Feature
  • Refactor
  • Unittests Added
  • DRY code
  • Dependency Added
  • DB Migration Added

Additional 📣

Feel free to add any other relevant details such as links, notes, screenshots, here.

@r14chandra r14chandra changed the title RHINENG-5010 playbook not getting dispatched with POST /profiles RHINENG-5011 playbook not getting dispatched with POST /profiles Mar 27, 2024
@r14chandra r14chandra requested a review from subpop March 28, 2024 12:08
@r14chandra r14chandra merged commit fb23ecb into RedHatInsights:master Apr 1, 2024
4 checks passed
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