Skip to content

Commit

Permalink
Add a secondary port to try for metadata requests
Browse files Browse the repository at this point in the history
  • Loading branch information
wcs1only committed Sep 1, 2021
1 parent 9917bb6 commit 4cb749d
Show file tree
Hide file tree
Showing 2 changed files with 19,498 additions and 31 deletions.
12 changes: 9 additions & 3 deletions pkg/instances/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func (i *instances) GetControlPlaneStatus() []StatusOutput {
// GetMetadata returns the result from the /v1.0/metadata endpoint
func (i *instances) GetMetadata(scope string, id string) MetadataOutput {
url := ""
secondaryUrl := ""
if i.kubeClient != nil {
resp, err := i.kubeClient.AppsV1().Deployments(scope).List((meta_v1.ListOptions{}))
if err != nil || len(resp.Items) == 0 {
Expand All @@ -339,7 +340,8 @@ func (i *instances) GetMetadata(scope string, id string) MetadataOutput {

if len(pods.Items) > 0 {
p := pods.Items[0]
url = fmt.Sprintf("http://%v:%v/v1.0/metadata", p.Status.PodIP, 3500)
url = fmt.Sprintf("http://%v:%v/v1.0/metadata", p.Status.PodIP, 3501)
secondaryUrl = fmt.Sprintf("http://%v:%v/v1.0/metadata", p.Status.PodIP, 3500)
}
}
}
Expand All @@ -351,9 +353,13 @@ func (i *instances) GetMetadata(scope string, id string) MetadataOutput {
}
if url != "" {
resp, err := http.Get(url)
if err != nil {
if err != nil && secondaryUrl != "" {
log.Println(err)
return MetadataOutput{}
resp, err = http.Get(secondaryUrl)
if err != nil {
log.Println(err)
return MetadataOutput{}
}
}

defer resp.Body.Close()
Expand Down
Loading

0 comments on commit 4cb749d

Please sign in to comment.