`linkerd check` sends params on version check (#1642)

The `linkerd check` parameter hits
https://versioncheck.linkerd.io/version.json to check for the latest
Linkerd version. This loses information, as that endpoint is intended to
record current version, uuid, and source.

Modify `linkerd check` to set `version`, `uuid`, and `source`
parameters when performing a version check.

Part of #1604.

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
This commit is contained in:
Andrew Seigner 2018-09-14 15:39:05 -07:00 committed by GitHub
parent 6c6310e3b9
commit c3150d2c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 13 deletions

View File

@ -98,12 +98,13 @@ type HealthChecker struct {
*HealthCheckOptions
// these fields are set in the process of running checks
kubeAPI *k8s.KubernetesAPI
httpClient *http.Client
kubeVersion *k8sVersion.Info
apiClient pb.ApiClient
dataPlanePods []v1.Pod
latestVersion string
kubeAPI *k8s.KubernetesAPI
httpClient *http.Client
kubeVersion *k8sVersion.Info
controlPlanePods []v1.Pod
apiClient pb.ApiClient
dataPlanePods []v1.Pod
latestVersion string
}
func NewHealthChecker(checks []Checks, options *HealthCheckOptions) *HealthChecker {
@ -201,11 +202,12 @@ func (hc *HealthChecker) addLinkerdAPIChecks() {
retry: hc.ShouldRetry,
fatal: true,
check: func() error {
pods, err := hc.kubeAPI.GetPodsByNamespace(hc.httpClient, hc.ControlPlaneNamespace)
var err error
hc.controlPlanePods, err = hc.kubeAPI.GetPodsByNamespace(hc.httpClient, hc.ControlPlaneNamespace)
if err != nil {
return err
}
return validateControlPlanePods(pods)
return validateControlPlanePods(hc.controlPlanePods)
},
})
@ -298,7 +300,23 @@ func (hc *HealthChecker) addLinkerdVersionChecks() {
if hc.VersionOverride != "" {
hc.latestVersion = hc.VersionOverride
} else {
hc.latestVersion, err = version.GetLatestVersion()
// The UUID is only known to the web process. At some point we may want
// to consider providing it in the Public API.
uuid := "unknown"
for _, pod := range hc.controlPlanePods {
if strings.Split(pod.Name, "-")[0] == "web" {
for _, container := range pod.Spec.Containers {
if container.Name == "web" {
for _, arg := range container.Args {
if strings.HasPrefix(arg, "-uuid=") {
uuid = strings.TrimPrefix(arg, "-uuid=")
}
}
}
}
}
}
hc.latestVersion, err = version.GetLatestVersion(uuid, "cli")
}
return
},

View File

@ -18,7 +18,7 @@ var Version = undefinedVersion
const (
undefinedVersion = "undefined"
versionCheckURL = "https://versioncheck.linkerd.io/version.json"
versionCheckURL = "https://versioncheck.linkerd.io/version.json?version=%s&uuid=%s&source=%s"
)
func init() {
@ -61,8 +61,9 @@ func CheckServerVersion(apiClient pb.ApiClient, latestVersion string) error {
return nil
}
func GetLatestVersion() (string, error) {
req, err := http.NewRequest("GET", versionCheckURL, nil)
func GetLatestVersion(uuid string, source string) (string, error) {
url := fmt.Sprintf(versionCheckURL, Version, uuid, source)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return "", err
}

View File

@ -85,7 +85,7 @@ class Sidebar extends React.Component {
}
fetchVersion() {
let versionUrl = `https://versioncheck.linkerd.io/version.json?version=${this.props.releaseVersion}&uuid=${this.props.uuid}`;
let versionUrl = `https://versioncheck.linkerd.io/version.json?version=${this.props.releaseVersion}&uuid=${this.props.uuid}&source=web`;
fetch(versionUrl, { credentials: 'include' })
.then(rsp => rsp.json())
.then(versionRsp =>