Skip to content

Add additional_payload in the Zoekt callback logging

What does this MR do and why?

Add the additional_payload param in the Zoekt callback logging. In the newer Zoekt indexer version, this param will be sent for the indexing action

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Create the token

  • Run the rails console
bundle exec rails c
secret_token =  Gitlab::Shell.secret_token
issuer =  API::Helpers::GITLAB_SHELL_JWT_ISSUER
jwt_token = JSONWebToken::HMACToken.new(secret_token).tap do |token|
  token.issuer = issuer
  token.expire_time = 1.hour.from_now
end
jwt_token.encoded

Tail the zoekt.log

tail -f log/zoekt.log

Please replace jwt_encode_token_from_above_step for the following tests with the token you get from the above step.

Testing for Success true:

  • Run the following curl command. And expect you get 202 Accepted. And check that you get log entries with info, node_id, payload, and additional_payload
curl --location 'http://127.0.0.1:3000/api/v4/internal/search/zoekt/00000000-0000-0000-0000-000000000000/callback' \
--header 'Gitlab-Shell-Api-Request: jwt_encode_token_from_above_step' \
--header 'Content-Type: application/json' \
--data '{
    "name": "index",
    "success": true,
    "payload": {"a": 5 },
    "additional_payload": {"key": "value"}
}'

Testing for Success false:

  • Run the following curl command. And expect you get 202 Accepted. And check that you get log entries with error, node_id, payload, and additional_payload
curl --location 'http://127.0.0.1:3000/api/v4/internal/search/zoekt/00000000-0000-0000-0000-000000000000/callback' \
--header 'Gitlab-Shell-Api-Request: jwt_encode_token_from_above_step' \
--header 'Content-Type: application/json' \
--data '{
    "name": "index",
    "success": false,
    "payload": {"a": 5 }
}'

Related to #424126 (closed)

Edited by Ravi Kumar

Merge request reports