feat(scheduler): pass the shutdown/reload ctx to running tasks (#1671)

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu
2023-09-05 19:48:56 +03:00
committed by GitHub
parent a0290b4b37
commit 59dc4c3229
28 changed files with 190 additions and 143 deletions
+4 -2
View File
@@ -1,6 +1,7 @@
package common
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
@@ -112,10 +113,11 @@ func CreateHTTPClient(verifyTLS bool, host string, certDir string) (*http.Client
}, nil
}
func MakeHTTPGetRequest(httpClient *http.Client, username string, password string, resultPtr interface{},
func MakeHTTPGetRequest(ctx context.Context, httpClient *http.Client,
username string, password string, resultPtr interface{},
blobURL string, mediaType string, log log.Logger,
) ([]byte, string, int, error) {
req, err := http.NewRequest(http.MethodGet, blobURL, nil) //nolint
req, err := http.NewRequestWithContext(ctx, http.MethodGet, blobURL, nil) //nolint
if err != nil {
return nil, "", 0, err
}
+2 -1
View File
@@ -1,6 +1,7 @@
package common_test
import (
"context"
"crypto/x509"
"os"
"path"
@@ -75,7 +76,7 @@ func TestHTTPClient(t *testing.T) {
var resultPtr interface{}
httpClient, err := common.CreateHTTPClient(true, "localhost", tempDir)
So(err, ShouldBeNil)
_, _, _, err = common.MakeHTTPGetRequest(httpClient, "", "",
_, _, _, err = common.MakeHTTPGetRequest(context.Background(), httpClient, "", "",
resultPtr, baseURL+"/v2/", ispec.MediaTypeImageManifest, log.NewLogger("", ""))
So(err, ShouldBeNil)
})