Merge pull request #777 from Vafilor/fix/adjust.curl

fix: adjust curl to use specific version and fail on non 200 responses
This commit is contained in:
Aleksandr Melnikov
2020-12-09 11:16:18 -08:00
committed by GitHub

View File

@@ -1975,17 +1975,18 @@ with statistics about the workflow that was just executed.
func getCURLNodeTemplate(name, curlMethod, curlPath, curlBody string, inputs wfv1.Inputs) (template *wfv1.Template, err error) { func getCURLNodeTemplate(name, curlMethod, curlPath, curlBody string, inputs wfv1.Inputs) (template *wfv1.Template, err error) {
host := "onepanel-core.onepanel.svc.cluster.local" host := "onepanel-core.onepanel.svc.cluster.local"
endpoint := fmt.Sprintf("http://%s%s", host, curlPath) endpoint := fmt.Sprintf("http://%s%s", host, curlPath)
template = &wfv1.Template{ template = &wfv1.Template{
Name: name, Name: name,
Inputs: inputs, Inputs: inputs,
Container: &corev1.Container{ Container: &corev1.Container{
Name: "curl", Name: "curl",
Image: "curlimages/curl", Image: "curlimages/curl:7.73.0",
Command: []string{"sh", "-c"}, Command: []string{"sh", "-c"},
Args: []string{ Args: []string{
"SERVICE_ACCOUNT_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) " + "SERVICE_ACCOUNT_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) " +
"&& curl -X " + curlMethod + " -s -o /dev/null -w '%{http_code}' " + "&& curl -X " + curlMethod + " -s -o /dev/null -w '%{http_code}' " +
"--connect-timeout 10 --retry 5 --retry-delay 5 " + "--connect-timeout 10 --retry 10 --retry-delay 5 --retry-all-errors --fail " +
"'" + endpoint + "' -H \"Content-Type: application/json\" -H 'Connection: keep-alive' -H 'Accept: application/json' " + "'" + endpoint + "' -H \"Content-Type: application/json\" -H 'Connection: keep-alive' -H 'Accept: application/json' " +
"-H 'Authorization: Bearer '\"$SERVICE_ACCOUNT_TOKEN\"'' " + "-H 'Authorization: Bearer '\"$SERVICE_ACCOUNT_TOKEN\"'' " +
"--data '" + curlBody + "' --compressed", "--data '" + curlBody + "' --compressed",