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

[2.x] Handling load balance and fail over endpoints through api_params.yaml file from APIMCLI 2.x.x #321

Merged

Conversation

wasuradananjith
Copy link
Contributor

@wasuradananjith wasuradananjith commented May 27, 2020

Purpose

When importing an API using APIMCLI, there is a need to support to mention multiple endpoints in the api_params.yaml file to handle the load balancing and failover scenarios, because publisher portal already supports those.

Goals

Add optional parameters to api_params.yaml file to handle multiple endpoints if the user needs to have those.

Approach

Introduced two (2) new fields (which are almost similar to the field “endpoints”) named as loadBalanceEndpoints and failoverEndpoints that should be used for load balancing or failover scenarios.

  1. loadBalanceEndpoints field contains the following.
    1. production: an array which consists the multiple production endpoints
    2. sandbox: an array which consists the multiple sandbox endpoints
    3. sessionManagement: values can be "none", "transport", "soap", "simpleClientSession" and if not specified the default value would be "transport"
    4. sessionTimeout: the number of milliseconds after which the session would time out
  2. failoverEndpoints field contains the following.
    1. production: the primary production endpoint (not an array)
    2. sandbox: the primary sandbox endpoint (not an array)
    3. productionFailovers: an array which consists failover production endpoints
    4. sandboxFailovers: an array which consists failover sandbox endpoints

If you do not want load balancing or fail-over to happen, you can specify the endpoints field as usual.

User stories

  • Load balancing scenario (in production environment)
    The user needs to specify the fields as shown in the below example. (Here production and sandbox fields are yaml arrays) Additionally user can specify sessionManagement (values can be "none", "transport", "soap", "simpleClientSession" and if not specified the default value would be "transport") and sessionTimeout fields.
environments:
 - name: dev
   endpoints:
       production:
       sandbox:
 - name: production
   loadBalanceEndpoints:
       production:
           - url: http://localhost:8001
           - url: http://localhost:8002
           - url: http://localhost:8003
       sandbox:
           - url: http://localhost:8004
           - url: http://localhost:8005
       sessionManagement: soap
       sessionTimeOut: 2000

After the API is imported to the APIM (2.6.0) the endpoints will be shown as below.
image

  • Failover scenario (in production environment)
    The user needs to specify the fields as shown in the below example. (Here production, productionFailovers, sandbox and sandboxFailovers fields are yaml arrays)
environments:
  - name: dev
    endpoints:
        production:
        sandbox:
  - name: production
    failoverEndpoints:
       production:
            url: http://localhost:8001
       productionFailovers:
           - url: http://localhost:8002
           - url: http://localhost:8003
       sandbox:
            url: http://localhost:8004
       sandboxFailovers:
            - url: http://localhost:8005

After the API is imported to the APIM (2.6.0) the endpoints will be shown as below.
image

  • If the user does not want to specify multiple endpoints, the user can use the earlier approach (current approach that we are having) by specifying the fields under endpoints as shown below. (Here production and sandbox fields are not yaml arrays)
environments:
  - name: dev
    endpoints:
      production:
      sandbox:
  - name: production
    endpoints:
      production:
          url: https://test1.wso2.com
      sandbox:
          url: https://test4.wso2.com

After the API is imported to the APIM (2.6.0) the endpoints will be shown as below.
image

  • If the user try to specify more than one field from endpoints, loadBalanceEndpoints or failoverEndpoints fields at once in api_params.yaml, the user will receive the below error when trying to import the API.
apimcli: Error importing API Reason: Please specify only one field from endpoints, loadBalanceEndpoints or failOverEndpoints in the api_params.yaml file for production and continue...
Exit status 1

Release note

Multiple endpoint support from api_params.yaml has been added to WSO2 APIMCLI 2.x.x.

Documentation

Documentation changes need to be done.

Test environment

  • Ubuntu 18.04.4 LTS
  • go version go1.14 linux/amd64

@wasuradananjith wasuradananjith force-pushed the multiple-endpoints-fix-2.x.x branch from 9d8c4cb to 7859c50 Compare May 27, 2020 18:50
@wasuradananjith wasuradananjith force-pushed the multiple-endpoints-fix-2.x.x branch from 36f48e8 to bbed183 Compare May 28, 2020 07:01
@malinthaprasan malinthaprasan merged commit c9fa663 into wso2:2.x.x May 29, 2020
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.

3 participants