wso2 / product-microgateway

Choreo Connect is a cloud-native, open-source, and developer-centric API gateway.
https://wso2.com/choreo/choreo-connect/
Apache License 2.0
294 stars 253 forks source link

Error un-deploying an API deployed to multiple labels form APICTL #2363

Closed renuka-fernando closed 2 years ago

renuka-fernando commented 3 years ago

Description:

Getting an error when un-deploying an API deployed to multiple labels through APICTL. The API is undeployed from one label. The error occurs when trying to un-deploy from the next label.

Adapter logs

adapter_1     | 2021-11-01 10:08:59 INFO [auth.go:156] - [auth.ValidateToken] [-] Valid token recieved
adapter_1     | 2021-11-01 10:08:59 INFO [server.go:441] - [xds.DeleteAPIs] [-] Unable to delete API SwaggerPetstore:1.0.5 from Organization carbon.super. API does not exist.

APICTL

$ apictl mg undeploy api -n SwaggerPetstore -v 1.0.5 -e dev -k -g Default
apictl: Error undeploying API Reason: the API does not exist
Exit status 1

Steps to reproduce:

Configure two gateway environments (Default and US).

Add the following config to the adapter

# Default virtual host mapping for standalone mode
[[adapter.vhostMapping]]
  # The Adapter environment
  environment = "Default"
  # Virtual host to map to the environment
  vhost = "localhost"
# Default virtual host mapping for standalone mode
[[adapter.vhostMapping]]
  # The Adapter environment
  environment = "US"
  # Virtual host to map to the environment
  vhost = "us.wso2.com"

Deploy the pet-store API to both labels. Used the following deployment_environments.yaml file.

type: deployment_environments
version: v4.0.0
data:
 -
   displayOnDevportal: true
   deploymentEnvironment: US
 -
   displayOnDevportal: true
   deploymentEnvironment: Default
 -
   displayOnDevportal: true
   deploymentVhost: us.wso2.com
   deploymentEnvironment: Default
$ apictl mg deploy api -f petstore -e dev -k
Successfully deployed API to microgateway.
$ apictl mg get apis -e dev -k
Limit flag not set. Set to default: 25
APIs total: 2 received: 2
NAME                VERSION             TYPE                CONTEXT             GATEWAY_ENVS        VHOST
SwaggerPetstore     1.0.5               HTTP                /v2                 [US Default]        us.wso2.com
SwaggerPetstore     1.0.5               HTTP                /v2                 [Default]           localhost
$ apictl mg undeploy api -n SwaggerPetstore -v 1.0.5 -e dev -k -g US
API undeployed from microgateway successfully!
$ apictl mg get apis -e dev -k
Limit flag not set. Set to default: 25
APIs total: 2 received: 2
NAME                VERSION             TYPE                CONTEXT             GATEWAY_ENVS        VHOST
SwaggerPetstore     1.0.5               HTTP                /v2                 [Default]           us.wso2.com
SwaggerPetstore     1.0.5               HTTP                /v2                 [Default]           localhost
$ apictl mg undeploy api -n SwaggerPetstore -v 1.0.5 -e dev -k -g Default
apictl: Error undeploying API Reason: the API does not exist
Exit status 1

Even following command is not working

$ apictl mg undeploy api -n SwaggerPetstore -v 1.0.5 -e dev -k
apictl: Error undeploying API Reason: the API does not exist
Exit status 1

Affected Product Version:

v1.0.0-alpha-snapshot

Environment details (with versions):


Optional Fields

Related Issues:

Suggested Labels:

Suggested Assignees:

pubudu538 commented 2 years ago

@slahirucd7 is working on this