Skip to content

Commit

Permalink
fix: using http client with timeout (argoproj#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiachengxu authored and Akuity committed Nov 21, 2024
1 parent c92b09e commit 1ee6afc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions controller/cache/ak-dashboard/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ func (p *akProcessor) sendEvents(events *gkEvents, override health.HealthOverrid
log.Errorf("failed to marshal resource events: %v", err)
}
log.Debug("sending resource events", string(jsonData))
resp, err := http.Post(resourceURL, "application/json", bytes.NewBuffer(jsonData))
req, err := http.NewRequest(http.MethodPost, resourceURL, bytes.NewBuffer(jsonData))
if err != nil {
log.Errorf("failed to create request: %v", err)
return
}
resp, err := p.client.Do(req)
if err != nil {
log.Errorf("failed to send resource events: %v", err)
return
Expand All @@ -98,7 +103,12 @@ func (p *akProcessor) sendClusterInfo(info clustercache.ClusterInfo) {
log.Errorf("failed to marshal cluster info: %v", err)
return
}
resp, err := http.Post(clusterInfoURL, "application/json", bytes.NewBuffer(jsonData))
req, err := http.NewRequest(http.MethodPost, clusterInfoURL, bytes.NewBuffer(jsonData))
if err != nil {
log.Errorf("failed to create request: %v", err)
return
}
resp, err := p.client.Do(req)
if err != nil {
log.Errorf("failed to send cluster info: %v", err)
return
Expand Down
1 change: 1 addition & 0 deletions controller/cache/ak-dashboard/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func NewResourceEvent(events gkEvents, appLister v1alpha1.ApplicationNamespaceLi
obj.SetNamespace(ref.Namespace)
obj.SetAPIVersion(ref.APIVersion)
obj.SetKind(ref.Kind)
obj.SetOwnerReferences(res.OwnerRefs)
deletedObjs = append(deletedObjs, obj)
}
resourceEvents.DeletedResources = deletedObjs
Expand Down

0 comments on commit 1ee6afc

Please sign in to comment.