aboutsummaryrefslogtreecommitdiff
path: root/pkg/bindings/system/system.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-08-02 14:09:55 -0700
committerMatthew Heon <mheon@redhat.com>2021-08-30 13:34:34 -0400
commitf363b805c59ed4d25d89f08e3a099e5c7028eb2f (patch)
treec7143d9a08e039192b330e1a0d78d56a0590aa46 /pkg/bindings/system/system.go
parentd1ea5454939745f98c42c00269fd646a08c5b6ac (diff)
downloadpodman-f363b805c59ed4d25d89f08e3a099e5c7028eb2f.tar.gz
podman-f363b805c59ed4d25d89f08e3a099e5c7028eb2f.tar.bz2
podman-f363b805c59ed4d25d89f08e3a099e5c7028eb2f.zip
Fix file descriptor leaks and add test
* Add response.Body.Close() where needed to release HTTP connections to API server. * Add tests to ensure no general leaks occur. 100% coverage would be required to ensure no leaks on any call. * Update code comments to be godoc correct Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings/system/system.go')
-rw-r--r--pkg/bindings/system/system.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go
index 310bcef15..719cde52e 100644
--- a/pkg/bindings/system/system.go
+++ b/pkg/bindings/system/system.go
@@ -31,6 +31,8 @@ func Events(ctx context.Context, eventChan chan entities.Event, cancelChan chan
if err != nil {
return err
}
+ defer response.Body.Close()
+
if cancelChan != nil {
go func() {
<-cancelChan
@@ -75,6 +77,8 @@ func Prune(ctx context.Context, options *PruneOptions) (*entities.SystemPruneRep
if err != nil {
return nil, err
}
+ defer response.Body.Close()
+
return &report, response.Process(&report)
}
@@ -101,6 +105,7 @@ func Version(ctx context.Context, options *VersionOptions) (*entities.SystemVers
if err != nil {
return nil, err
}
+ defer response.Body.Close()
if err = response.Process(&component); err != nil {
return nil, err
@@ -141,5 +146,7 @@ func DiskUsage(ctx context.Context, options *DiskOptions) (*entities.SystemDfRep
if err != nil {
return nil, err
}
+ defer response.Body.Close()
+
return &report, response.Process(&report)
}