Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created February 5, 2019 17:57
Show Gist options
  • Save jsanda/fee693cfbd761a348bcef66e2628588d to your computer and use it in GitHub Desktop.
Save jsanda/fee693cfbd761a348bcef66e2628588d to your computer and use it in GitHub Desktop.
// ...
} else { // Active=False
url := fmt.Sprintf("http://%s.%s", pa.Spec.ServiceName, pa.ObjectMeta.Namespace)
client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("knative-activator-probe", "true")
resp, err := client.Do(req)
if err != nil {
logger.Errorf("Probe request to %s failed", url, zap.Error(err))
return desiredScale, err
}
if resp.StatusCode != http.StatusOK {
return desiredScale, nil
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
logger.Errorf("Failed to read response from probe request to %s", url, err)
return desiredScale, nil
}
if string(body) == "queue-proxy" {
return desiredScale, nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment