Skip to content

Execute HTTP calls to Kubernetes in Sidekiq Worker Job

Shinya Maeda requested to merge wrap-update-canary-in-sidekiq into master

What does this MR do?

This MR addresses the concern raised by @DylanGriffith that HTTP request to an external service (in this case Kubernetes) is currently performed in puma workers.

As the MR performance guideline states, HTTP calls to external services should be executed in Sidekiq jobs i.e. async process.

Close #277372 (closed)

Manual QA

Executed the following GraphQL query:

mutation {
  environmentsCanaryIngressUpdate(input:{
    id: "gid://gitlab/Environment/29",
    weight: 58
  }) {
    errors
  }
}

GitLab returns the following response. If errors is empty, the request succeeded.

{
  "data": {
    "environmentsCanaryIngressUpdate": {
      "errors": []
    }
  }
}

Verified that the new weight is correctly reflected in the rollout status.

screenshot_179

Here is the sidekiq log

{"severity":"INFO","time":"2020-11-09T03:42:37.078Z","class":"Environments::CanaryIngress::UpdateWorker","args":["29","[FILTERED]"],"retry":0,"queue":"environments_canary_ingress_update","backtrace":true,"version":0,"jid":"11afa625ea30270df251fb83","created_at":"2020-11-09T03:42:37.077Z","meta.user":"root","meta.caller_id":"GraphqlController#execute","meta.feature_category":"not_owned","correlation_id":"ctXGRs8HKx6","enqueued_at":"2020-11-09T03:42:37.078Z","pid":22,"message":"Environments::CanaryIngress::UpdateWorker JID-11afa625ea30270df251fb83: start","job_status":"start","scheduling_latency_s":0.00055}
{"severity":"INFO","time":"2020-11-09T03:42:39.747Z","class":"Environments::CanaryIngress::UpdateWorker","args":["29","[FILTERED]"],"retry":0,"queue":"environments_canary_ingress_update","backtrace":true,"version":0,"jid":"11afa625ea30270df251fb83","created_at":"2020-11-09T03:42:37.077Z","meta.user":"root","meta.caller_id":"GraphqlController#execute","meta.feature_category":"not_owned","correlation_id":"ctXGRs8HKx6","enqueued_at":"2020-11-09T03:42:37.078Z","pid":22,"message":"Environments::CanaryIngress::UpdateWorker JID-11afa625ea30270df251fb83: done: 2.668779 sec","job_status":"done","scheduling_latency_s":0.00055,"redis_calls":3,"redis_duration_s":0.00038,"redis_read_bytes":487,"redis_write_bytes":238,"redis_cache_calls":1,"redis_cache_duration_s":0.000105,"redis_cache_read_bytes":485,"redis_cache_write_bytes":35,"redis_queues_calls":2,"redis_queues_duration_s":0.000275,"redis_queues_read_bytes":2,"redis_queues_write_bytes":203,"db_count":8,"db_write_count":0,"db_cached_count":0,"duration_s":2.668779,"cpu_s":0.075587,"completed_at":"2020-11-09T03:42:39.747Z","db_duration_s":0.006204}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda

Merge request reports