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

fix(webhooks): Construct Webhook status check URL honoring the origin… #3187

Merged
merged 2 commits into from
Sep 23, 2019
Merged

fix(webhooks): Construct Webhook status check URL honoring the origin… #3187

merged 2 commits into from
Sep 23, 2019

Conversation

srekapalli
Copy link
Contributor

  • Change here is to make the status check URL of a webhook to have the same protocol/scheme of the webhook.
  • RestTemplate provider keys on the URL as a whole and it is important to keep the scheme as is from the original webhook so that the same RestTemplate provider as webhook will be used for making the status check call.

@@ -70,7 +70,7 @@ class WebhookService {
)
HttpHeaders headers = buildHttpHeaders(customHeaders)
HttpEntity<Object> httpEntity = new HttpEntity<>(headers)
return restTemplateProvider.getRestTemplate().exchange(validatedUri, HttpMethod.GET, httpEntity, Object)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Method expects a URL to be provided so adding it though Groovy doesn't complain about it during compilation time

@@ -160,7 +160,6 @@ class MonitorWebhookTask implements OverridableTimeoutRetryableTask {
return TaskResult.builder(statusMap[result.toString().toUpperCase()]).context(responsePayload).build()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed unnecessary statement.

@@ -162,4 +157,41 @@ class CreateWebhookTask implements RetryableTask {
return TaskResult.builder(ExecutionStatus.TERMINAL).context(outputs).build()
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Below method adjusts the status check URL if the original webhook domain and status check URL domain given back matches.

@Slf4j
@Component
class CreateWebhookTask implements RetryableTask {

private static final Pattern URL_SCHEME = Pattern.compile("(.*)://(.*)")
Copy link
Contributor

Choose a reason for hiding this comment

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

was trying to see if there are ways to make the URL class do the "hard" work here but can't find anything.

Copy link
Contributor

@marchello2000 marchello2000 left a comment

Choose a reason for hiding this comment

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

LGTM

@marchello2000 marchello2000 added the ready to merge Approved and ready for merge label Sep 23, 2019
@marchello2000 marchello2000 merged commit 3bc32da into spinnaker:master Sep 23, 2019
Copy link
Contributor

@cfieber cfieber left a comment

Choose a reason for hiding this comment

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

@srekapalli I believe you mentioned there are some other URIs involved in the webhook flow besides status? How are those going to be handled

@srekapalli
Copy link
Contributor Author

srekapalli commented Sep 23, 2019

@srekapalli I believe you mentioned there are some other URIs involved in the webhook flow besides status? How are those going to be handled

@cfieber : Actually they were all going through the same webHookService implementation and only status URL is derived from the webhook call response and that is the reason we needed special treatment for that. I wondered initially that I need to do the same for 'cancel' and 'progress' URL's but we don't need to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Approved and ready for merge target-release/1.17
Projects
None yet
4 participants