Prove that a change isn't configuration before you change code. Most change requests to an installed Connector are a value in its install form, and a redeploy applies them in minutes without a pull request, a tag, or a new validation run.
Zen Electron's marketing team asks for a different sender address on order confirmations, by tomorrow. By the end of this page, you can tell whether that needs a pull request, apply it, and confirm it. You can also move the Deployment to new code, diagnose the common failures, and remove the Connector cleanly.
zen-order-confirmation-sandbox Deployment from Install and test your Connector.Change request: a new sender address
SENDER_EMAIL_ADDRESS key in the mail-sender application's securedConfiguration, which the handler reads from the environment. The change is therefore a redeploy with a new value, not a pull request.What the redeploy does to the other values
configurationValues, existing values are unchanged. Don't assume the same for individual keys: when you send some keys, treat the keys you omit as unknown.Two rules keep the change safe:
- Keep every secured value in your own secrets store. Secured values can't be read back from the Deployment after they're set, so the store is the only place you can recover them from.
- Send the full set of values, and never a placeholder for a secured key you can't recover. Resending the full set from your secrets store works whether a redeploy merges or replaces.
For this module, the other values are stubs, so the examples that follow resend the full set with the new sender.
With the Connect CLI
CONFIG array from Stage, preview, and publish privately, then pass the whole array:CONFIG=("${CONFIG[@]/SENDER_EMAIL_ADDRESS=orders@example.com/SENDER_EMAIL_ADDRESS=confirmations@example.com}")
commercetools connect deployment redeploy \
--key zen-order-confirmation-sandbox \
"${CONFIG[@]}"
With the Connect API
Failed Deployment, so you can correct a bad configuration value without deleting the Deployment. The reference lists every state that it accepts. Use the token and variables from Stage, preview, and publish privately. Replace the sender in the CONFIGURATIONS array from Stage, preview, and publish privately, then send the whole array:CONFIGURATIONS=$(jq 'map(.securedConfiguration |= map(
if .key == "SENDER_EMAIL_ADDRESS" then .value = "confirmations@example.com" else . end))' <<< "$CONFIGURATIONS")
VERSION=$(curl -sS --fail-with-body "$CONNECT_URL/$CTP_PROJECT_KEY/deployments/key=zen-order-confirmation-sandbox" \
-H "Authorization: Bearer $TOKEN" | jq .version)
jq -n --argjson version "$VERSION" --argjson configurations "$CONFIGURATIONS" '{
version: $version,
actions: [{ action: "redeploy", configurationValues: $configurations }]
}' | curl -sS --fail-with-body -X POST "$CONNECT_URL/$CTP_PROJECT_KEY/deployments/key=zen-order-confirmation-sandbox" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @- | jq '{status, version}'
Scripts run again
postDeploy by default. The template's postDeploy deletes and recreates the Subscription, so Messages created during that gap aren't delivered. That's why Implement and test the event app to the contract asked for repeatable lifecycle scripts.--skipScripts in the CLI, or "skipScripts": true in the API, to keep the Subscription as it is. Don't skip scripts when the change affects what postDeploy creates, such as a new Message type.Confirm the change
Deployed again, import another Order as in Trigger an Order and read the logs. The stub's line now shows the new sender:Email provider stub: email not sent {"sender":"confirmations@example.com","templateId":"order-confirmation","lineItemCount":1}
Marketing's request needed no pull request. If the change had been to the email's content or to which Orders get an email, it would have been code: a new version.
Move to a new version
v0.2.1, the sequence is:git tag v0.2.1 && git push origin v0.2.1
commercetools connect connectorstaged update \
--key zen-order-confirmation \
--repository-tag v0.2.1
commercetools connect connectorstaged publish --key zen-order-confirmation
# Wait until `connectorstaged describe` shows status Published.
commercetools connect deployment redeploy \
--key zen-order-confirmation-sandbox \
--updateConnector
If the Deployment still behaves the old way, one of the first three steps didn't land. Compare the tag that the Deployment runs with the tag of the published Connector and of the ConnectorStaged:
curl -sS --fail-with-body "$CONNECT_URL/$CTP_PROJECT_KEY/deployments/key=zen-order-confirmation-sandbox" \
-H "Authorization: Bearer $TOKEN" | jq '{deployed: .connector.version, tag: .connector.repository.tag}'
curl -sS --fail-with-body "$CONNECT_URL/connectors/key=zen-order-confirmation" \
-H "Authorization: Bearer $TOKEN" | jq '{published: .version, tag: .repository.tag}'
curl -sS --fail-with-body "$CONNECT_URL/connectors/drafts/key=zen-order-confirmation" \
-H "Authorization: Bearer $TOKEN" | jq '{status, tag: .repository.tag, report: .publishingReport.entries}'
status is Failed, read publishingReport: the new tag didn't pass the validation pipeline, so there's no new version to move to. If the published Connector has the new tag but the Deployment's tag is old, the redeploy ran without updateConnector.Read logs and reports
Connect gives you three views of a Deployment. Each answers a different question.
mail-sender application with commercetools connect deployment logs --key zen-order-confirmation-sandbox --application mail-sender. Logs are only as useful as what the application writes, which is why Implement and test the event app to the contract added the Message type, resource.id, and sequenceNumber to the success and failure lines for every decoded Message.details.build.report.entries:curl -sS --fail-with-body "$CONNECT_URL/$CTP_PROJECT_KEY/deployments/key=zen-order-confirmation-sandbox" \
-H "Authorization: Bearer $TOKEN" | jq '{status, report: .details.build.report.entries}'
postDeploy output might not appear in the Deployment logs, so query the Subscription, as in Verify the resource, not the status.| Symptom | Look first at |
|---|---|
Deployment Failed | The report, then the logs |
Deployment Deployed, but no events arrive | The Subscription by key: exists, Healthy, expected Message types |
| Events arrive, but no email is requested | The logs for that resource.id |
| The provider has no record of an email that the logs say was handed over | The provider's activity log |
| New code isn't running | The Deployment's connector.version and the ConnectorStaged's publishingReport |
Debug a failed Deployment
A configuration value is missing or rejected
connect.yaml doesn't declare, or that leaves a required global key empty. The Create Deployment and Redeploy references list these errors, such as DeploymentUnknownApplicationConfigurationKey.mail-sender/src/validators/env.validators.js) before you change code.The Region doesn't match
DeploymentUnsupportedRegion when its Region isn't in the ConnectorStaged's supportedRegions, as Choose the Region and environment explains. Add the Region to the ConnectorStaged's supported Regions, publish again, and deploy. Otherwise, deploy in the Project's Region unless you have a reason not to.Check Subscription health
status field reports health, and the Get Health Status of Subscription endpoint returns it. Alert on any status other than Healthy in production. Each health status has its own retry window, and notifications can be dropped when the window ends. The Subscription delivery guarantees list the windows. Resolve a ConfigurationError before its window ends, and don't rely on the separate Connect broker retention for unacknowledged messages to extend it.Uninstall and confirm cleanup
Delete the Deployment:
commercetools connect deployment delete --key zen-order-confirmation-sandbox
y/n prompt. Deleting runs preUndeploy, which deletes the Subscription. Confirm it with the same query as in Verify the resource, not the status. The expected result is an empty list:curl -sS --fail-with-body -G \
"https://api.$CTP_REGION.commercetools.com/$CTP_PROJECT_KEY/subscriptions" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode 'where=key="ct-connect-email-delivery-subscription"' \
| jq '.count'
1 means that preUndeploy didn't run or failed. Delete the Subscription by key yourself, or it keeps sending Messages to a topic with no consumer.job application can also override the job's schedule for each Deployment. See Job. The email Connector has no job application.Worked example: change Zen Electron's sender address
- Confirm the request is configuration:
SENDER_EMAIL_ADDRESSis a secured key, not code. - Redeploy
zen-order-confirmation-sandboxwith the full set of values and the new sender, using--skipScriptsbecause the Subscription doesn't change. - Wait for
Deployed, import an Order, and find"sender":"confirmations@example.com"in the stub's log line.
Marketing has its new sender address the same day, with no pull request, tag, or validation run.
Key takeaways
- Check whether a change is configuration before you change code. A redeploy with new values applies it without a new version.
- The redeploy action leaves values unchanged when you omit
configurationValues. Keep secured values in your own secrets store, because Connect can't return them. - A redeploy reruns
postDeployunless you skip scripts. Skip them only when the change doesn't affect what the scripts create. - A new version needs four steps: tag, set the repository, publish, and redeploy with
updateConnector. If behavior doesn't change, compare versions and read the publishing report. - Logs show what your application did, reports show what Connect did, and the resources show whether the lifecycle scripts worked. Check all three.
- A fixed Subscription key means two Deployments in one Project overwrite each other, and undeploying either removes the shared Subscription.
- After you uninstall, confirm that
preUndeployremoved the Subscription.