Fix possible context leak problem (#483)
This commit is contained in:
+7
-6
@@ -20,6 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -37,7 +38,6 @@ import (
|
|||||||
"github.com/fission/fission"
|
"github.com/fission/fission"
|
||||||
"github.com/fission/fission/controller/client"
|
"github.com/fission/fission/controller/client"
|
||||||
"github.com/fission/fission/crd"
|
"github.com/fission/fission/crd"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const SPEC_API_VERSION = "fission.io/v1"
|
const SPEC_API_VERSION = "fission.io/v1"
|
||||||
@@ -420,7 +420,7 @@ func specApply(c *cli.Context) error {
|
|||||||
checkErr(err, "read specs")
|
checkErr(err, "read specs")
|
||||||
|
|
||||||
// make changes to the cluster based on the specs
|
// make changes to the cluster based on the specs
|
||||||
pkgMeta, as, err := apply(fclient, specDir, fr, deleteResources)
|
pkgMetas, as, err := applyResources(fclient, specDir, fr, deleteResources)
|
||||||
checkErr(err, "apply specs")
|
checkErr(err, "apply specs")
|
||||||
printApplyStatus(as)
|
printApplyStatus(as)
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ func specApply(c *cli.Context) error {
|
|||||||
if watchResources || waitForBuild {
|
if watchResources || waitForBuild {
|
||||||
// watch package builds
|
// watch package builds
|
||||||
ctx, pkgWatchCancel = context.WithCancel(context.Background())
|
ctx, pkgWatchCancel = context.WithCancel(context.Background())
|
||||||
pbw.addPackages(pkgMeta)
|
pbw.addPackages(pkgMetas)
|
||||||
}
|
}
|
||||||
|
|
||||||
if watchResources {
|
if watchResources {
|
||||||
@@ -441,6 +441,7 @@ func specApply(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !watchResources {
|
if !watchResources {
|
||||||
|
pkgWatchCancel()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +534,7 @@ func specDestroy(c *cli.Context) error {
|
|||||||
emptyFr.deploymentConfig = fr.deploymentConfig
|
emptyFr.deploymentConfig = fr.deploymentConfig
|
||||||
|
|
||||||
// "apply" the empty state
|
// "apply" the empty state
|
||||||
_, _, err = apply(fclient, specDir, &emptyFr, true)
|
_, _, err = applyResources(fclient, specDir, &emptyFr, true)
|
||||||
checkErr(err, "delete resources")
|
checkErr(err, "delete resources")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -608,8 +609,8 @@ func applyArchives(fclient *client.Client, specDir string, fr *FissionResources)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply applies the given set of fission resources.
|
// applyResources applies the given set of fission resources.
|
||||||
func apply(fclient *client.Client, specDir string, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, map[string]resourceApplyStatus, error) {
|
func applyResources(fclient *client.Client, specDir string, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, map[string]resourceApplyStatus, error) {
|
||||||
|
|
||||||
applyStatus := make(map[string]resourceApplyStatus)
|
applyStatus := make(map[string]resourceApplyStatus)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user