Skip to content

chore(analytics): opensearch client creation based on config#7810

Merged
likhinbopanna merged 7 commits intomainfrom
open_search_config_change
Apr 17, 2025
Merged

chore(analytics): opensearch client creation based on config#7810
likhinbopanna merged 7 commits intomainfrom
open_search_config_change

Conversation

@su-shivanshmathur
Copy link
Contributor

@su-shivanshmathur su-shivanshmathur commented Apr 14, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Making OpenSearchClient optional based on the config for querying OpenSearch Server for dashboard based on the Deployment status of the same ( OpenSearch Server ).

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

When you don't have OpenSearch deployed for Global Search feature on dashboard , the /health/ready ( deep health check ) API which checks health of all the underlying queryable resources fails because OpenSearch is not present.

To make it optional based on the deployment type needs changes and should be dependent on a config which should be given out on time of router deployment

Currently if you don't have OpenSearch Deployment and have router running

curl http://localhost:8080/health/ready -v
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /health/ready HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 500 Internal Server Error
< content-length: 136
< access-control-expose-headers: x-request-id, content-type, via, strict-transport-security
< via: HyperSwitch
< x-request-id: 019634f7-a837-7d50-9a50-bb8e7651bd62
< content-type: application/json
< vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
< strict-transport-security: max-age=31536000
< date: Mon, 14 Apr 2025 15:42:47 GMT
< 
{ [136 bytes data]
100   136  100   136    0     0   7613      0 --:--:-- --:--:-- --:--:--  8000
* Connection #0 to host localhost left intact
{
  "error": {
    "type": "api",
    "message": "Opensearch health check failed with error: Error while executing query in Opensearch",
    "code": "HE_00"
  }
}

How did you test it?

curl http://localhost:8080/health/ready -v | jq .
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /health/ready HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< content-length: 90
< content-type: application/json
< x-request-id: 01963e0a-e41d-7251-b20a-e9a0a6d1a67a
< vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
< access-control-expose-headers: content-type, strict-transport-security, x-request-id, via
< strict-transport-security: max-age=31536000
< via: HyperSwitch
< date: Wed, 16 Apr 2025 10:00:23 GMT
< 
{ [90 bytes data]
100    90  100    90    0     0    236      0 --:--:-- --:--:-- --:--:--   236
* Connection #0 to host localhost left intact
{
  "database": true,
  "redis": true,
  "analytics": true,
  "opensearch": false,
  "outgoing_request": true
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@su-shivanshmathur su-shivanshmathur self-assigned this Apr 14, 2025
@su-shivanshmathur su-shivanshmathur requested review from a team as code owners April 14, 2025 15:46
@semanticdiff-com
Copy link

semanticdiff-com bot commented Apr 14, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/analytics.rs  81% smaller
  crates/router/src/core/health_check.rs  56% smaller
  crates/router/src/routes/app.rs  40% smaller
  crates/analytics/src/opensearch.rs  34% smaller
  config/config.example.toml Unsupported file format
  config/deployments/env_specific.toml Unsupported file format
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format

@su-shivanshmathur su-shivanshmathur linked an issue Apr 14, 2025 that may be closed by this pull request
vspecky
vspecky previously approved these changes Apr 15, 2025
tsdk02
tsdk02 previously approved these changes Apr 15, 2025
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that, looks good to me!

@su-shivanshmathur su-shivanshmathur dismissed stale reviews from tsdk02 and vspecky via 629c3c4 April 15, 2025 18:56
SanchithHegde
SanchithHegde previously approved these changes Apr 15, 2025
tsdk02
tsdk02 previously approved these changes Apr 15, 2025
.await
.change_context(errors::HealthCheckDBError::OpensearchError)?;
}
Ok(HealthState::Running)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can send HealthState::NotApplicable in absence of opensearch_client right?

@su-shivanshmathur su-shivanshmathur dismissed stale reviews from tsdk02 and SanchithHegde via bce8b2f April 16, 2025 10:11
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 17, 2025
Merged via the queue into main with commit 2067bc3 Apr 17, 2025
24 of 28 checks passed
@likhinbopanna likhinbopanna deleted the open_search_config_change branch April 17, 2025 08:33
pixincreate added a commit that referenced this pull request Apr 21, 2025
…acilitapay-pix-pmt

* 'main' of github.com:juspay/hyperswitch: (21 commits)
  refactor(required_fields): move pm required fields to pm crate (#7539)
  fix(connector): [noon] address `next_action_url` being `null` for cards in 3ds payment (#7832)
  refactor(middleware): add middleware to record metrics for request count and duration (#7803)
  chore(version): 2025.04.18.0
  chore(postman): update Postman collection files
  fix(connector): [globalpay] handle edge case where currency comes as empty upon payment decline (#7812)
  refactor(cypress-v2): change `Authorization` and `payment_methods_enabled` for v2 cypress tests (#7805)
  fix(connector): [Cybersource] send type selection indicator for co-batch cards (#7828)
  feat(payment_method): add logic for setup_future_usage downgrade and add filter based on zero mandate config (#7775)
  refactor(accounts): move dashboard_metadata table to accounts_schema and point v2 to v1 dashboard_metadata (#7793)
  chore(analytics): opensearch client creation based on config (#7810)
  ci(postman): update assertion error message for nmi collection (#7765)
  feat: add primary key not null query to generic filter function (#7785)
  chore(version): 2025.04.17.0
  chore: change payment method files ownership to `hyperswitch-payment-methods` (#7808)
  feat(vsaas): modify api key auth to support vsaas cases (#7593)
  ci(cypress): verify mandate id to be `null` if payment id not `succeeded` (#7749)
  feat(connector): [chargebee] consumes required fields to support transaction monitoring (#7774)
  ci(configs): remove vault private key from configs (#7825)
  chore(version): 2025.04.16.0
  ...
@su-shivanshmathur su-shivanshmathur restored the open_search_config_change branch April 23, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deep health check failing because of OpenSearch

6 participants