Skip to content

[gateway-controller] Notify on-prem APIM of deploy/undeploy status via notify-api-deployment-status#1302

Closed
YasasRangika wants to merge 217 commits intowso2:feature-on-prem-apim-connectionfrom
YasasRangika:yasas-on-prem-connector
Closed

[gateway-controller] Notify on-prem APIM of deploy/undeploy status via notify-api-deployment-status#1302
YasasRangika wants to merge 217 commits intowso2:feature-on-prem-apim-connectionfrom
YasasRangika:yasas-on-prem-connector

Conversation

@YasasRangika
Copy link
Contributor

Description

Gateway-controller now notifies the on-prem APIM's internal API when API deploy or undeploy events are processed, so deployment stats (deployedGatewayCount, failedGatewayCount) and revision state stay in sync with the Synapse flow.

Changes

1. New notifyDeploymentStatus and request types

  • deploymentStatusAckPayload / deploymentStatusAckItem: JSON payload aligned with APIM GatewayDeploymentStatusAcknowledgmentListDTO (gatewayId, apiId, deploymentStatus, action, revisionId, timeStamp; tenantDomain left empty — APIM resolves org from gatewayId).
  • notifyDeploymentStatus(apiID, revisionID, status, action string):
    • No-op if gateway ID is not set (e.g. before connection.ack).
    • POSTs to {getRestAPIBaseURL()}/notify-api-deployment-status with api-key auth and JSON body.
    • Uses bytes.NewReader(body) for the request body (added bytes import).
    • Sets Content-Type and api-key header; reuses existing TLS/InsecureSkipVerify behavior.
    • Logs errors and non-OK responses; debug log on success.

2. Deploy event – success and failure notification

  • handleAPIDeployedEvent:
    • On error from fetchAndDeployAPI: calls notifyDeploymentStatus(apiID, deploymentID, "FAILURE", "DEPLOY") so APIM can increment failedGatewayCount.
    • On success: calls notifyDeploymentStatus(apiID, deploymentID, "SUCCESS", "DEPLOY") so deployedGatewayCount is updated (same idea as Synapse DeploymentStatusNotifier).

3. Undeploy event – success notification

  • handleAPIUndeployedEvent: After updating the xDS snapshot, calls notifyDeploymentStatus(apiID, "", "SUCCESS", "UNDEPLOY") so deployment stats reflect the undeploy.

Context

APIM’s internal API exposes POST /notify-api-deployment-status so gateways can report deploy/undeploy results. APIM uses these acks to update AM_GW_REVISION_DEPLOYMENT and deployment stats. Without these calls, platform gateways would not update deployedGatewayCount/failedGatewayCount like Synapse gateways do.

Testing

  • Build and run gateway-controller; trigger deploy/undeploy via WebSocket.
  • Confirm SUCCESS/FAILURE acks are sent to the control plane and that APIM deployment stats and revision state update accordingly.

Loading
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.