diff --git a/cache/advertise.go b/cache/advertise.go index b1d1b1ccc..b923f83e1 100644 --- a/cache/advertise.go +++ b/cache/advertise.go @@ -147,15 +147,15 @@ func (server *CacheServer) GetNamespaceAdsFromDirector() error { // Attempt to get data from the 2.0 endpoint, if that returns a 404 error, then attempt to get data // from the 1.0 endpoint and convert from V1 to V2 - - respData, err := utils.MakeRequest(context.Background(), directorNSListEndpointURL, "GET", nil, nil) + tr := config.GetTransport() + respData, err := utils.MakeRequest(context.Background(), tr, directorNSListEndpointURL, "GET", nil, nil) if err != nil { if strings.Contains(err.Error(), "404") { directorNSListEndpointURL, err = url.JoinPath(fedInfo.DirectorEndpoint, "api", "v1.0", "director", "listNamespaces") if err != nil { return err } - respData, err = utils.MakeRequest(context.Background(), directorNSListEndpointURL, "GET", nil, nil) + respData, err = utils.MakeRequest(context.Background(), tr, directorNSListEndpointURL, "GET", nil, nil) var respNSV1 []server_structs.NamespaceAdV1 if err != nil { return errors.Wrap(err, "Failed to make request") diff --git a/director/origin_api.go b/director/origin_api.go index 8e0e3159c..27dda935d 100644 --- a/director/origin_api.go +++ b/director/origin_api.go @@ -144,7 +144,8 @@ func verifyAdvertiseToken(ctx context.Context, token, namespace string) (bool, e } if keyset == nil { - keyset, err = utils.GetJwks(ctx, keyLoc) + tr := config.GetTransport() + keyset, err = utils.GetJwks(ctx, tr, keyLoc) if err != nil { return false, errors.Wrapf(err, "failed to get jwks at %s", keyLoc) } diff --git a/launcher_utils/advertise.go b/launcher_utils/advertise.go index 61fbec302..3207613e9 100644 --- a/launcher_utils/advertise.go +++ b/launcher_utils/advertise.go @@ -118,7 +118,8 @@ func getSitenameFromReg(ctx context.Context, prefix string) (sitename string, er if err != nil { return } - res, err := utils.MakeRequest(context.Background(), requestUrl, http.MethodGet, nil, nil) + tr := config.GetTransport() + res, err := utils.MakeRequest(context.Background(), tr, requestUrl, http.MethodGet, nil, nil) if err != nil { return } diff --git a/local_cache/cache_linux_test.go b/local_cache/cache_linux_test.go index 997206b7c..e8349bc19 100644 --- a/local_cache/cache_linux_test.go +++ b/local_cache/cache_linux_test.go @@ -139,8 +139,8 @@ func TestForcePurge(t *testing.T) { Scheme: "unix", Path: param.LocalCache_Socket.GetString(), } - - _, err = utils.MakeRequest(ft.Ctx, param.Server_ExternalWebUrl.GetString()+"/api/v1.0/localcache/purge", "POST", nil, map[string]string{"Authorization": "Bearer abcd"}) + tr := config.GetTransport() + _, err = utils.MakeRequest(ft.Ctx, tr, param.Server_ExternalWebUrl.GetString()+"/api/v1.0/localcache/purge", "POST", nil, map[string]string{"Authorization": "Bearer abcd"}) assert.Error(t, err) require.Equal(t, fmt.Sprintf("The POST attempt to %s/api/v1.0/localcache/purge resulted in status code 403", param.Server_ExternalWebUrl.GetString()), err.Error()) @@ -172,7 +172,7 @@ func TestForcePurge(t *testing.T) { }() } - _, err = utils.MakeRequest(ft.Ctx, param.Server_ExternalWebUrl.GetString()+"/api/v1.0/localcache/purge", "POST", nil, map[string]string{"Authorization": "Bearer " + token}) + _, err = utils.MakeRequest(ft.Ctx, tr, param.Server_ExternalWebUrl.GetString()+"/api/v1.0/localcache/purge", "POST", nil, map[string]string{"Authorization": "Bearer " + token}) require.NoError(t, err) // Low water mark is small enough that a force purge will delete a file. diff --git a/local_cache/local_cache.go b/local_cache/local_cache.go index 225af6368..fe3cd5f9b 100644 --- a/local_cache/local_cache.go +++ b/local_cache/local_cache.go @@ -744,7 +744,8 @@ func (sc *LocalCache) updateConfig() error { return errors.Wrap(err, "Unable to generate the director's listNamespaces endpoint") } - respData, err := utils.MakeRequest(sc.ctx, directorNSListEndpointURL, "GET", nil, nil) + tr := config.GetTransport() + respData, err := utils.MakeRequest(sc.ctx, tr, directorNSListEndpointURL, "GET", nil, nil) if err != nil { return err } else { diff --git a/registry/client_commands.go b/registry/client_commands.go index b49ea9c78..c56f481bf 100644 --- a/registry/client_commands.go +++ b/registry/client_commands.go @@ -32,6 +32,7 @@ import ( "github.com/pkg/errors" log "github.com/sirupsen/logrus" + "github.com/pelicanplatform/pelican/config" "github.com/pelicanplatform/pelican/server_utils" "github.com/pelicanplatform/pelican/token" "github.com/pelicanplatform/pelican/token_scopes" @@ -58,7 +59,8 @@ func NamespaceRegisterWithIdentity(privateKey jwk.Key, namespaceRegistryEndpoint // it's also registered already } - resp, err := utils.MakeRequest(context.Background(), namespaceRegistryEndpoint, "POST", identifiedPayload, nil) + tr := config.GetTransport() + resp, err := utils.MakeRequest(context.Background(), tr, namespaceRegistryEndpoint, "POST", identifiedPayload, nil) var respData clientResponseData // Handle case where there was an error encoded in the body @@ -81,7 +83,7 @@ func NamespaceRegisterWithIdentity(privateKey jwk.Key, namespaceRegistryEndpoint "identity_required": "true", "device_code": respData.DeviceCode, } - resp, err = utils.MakeRequest(context.Background(), namespaceRegistryEndpoint, "POST", identifiedPayload, nil) + resp, err = utils.MakeRequest(context.Background(), tr, namespaceRegistryEndpoint, "POST", identifiedPayload, nil) if err != nil { return errors.Wrap(err, "Failed to make request") } @@ -137,7 +139,8 @@ func NamespaceRegister(privateKey jwk.Key, namespaceRegistryEndpoint string, acc "pubkey": keySet, } - resp, err := utils.MakeRequest(context.Background(), namespaceRegistryEndpoint, "POST", data, nil) + tr := config.GetTransport() + resp, err := utils.MakeRequest(context.Background(), tr, namespaceRegistryEndpoint, "POST", data, nil) var respData clientResponseData // Handle case where there was an error encoded in the body @@ -182,7 +185,7 @@ func NamespaceRegister(privateKey jwk.Key, namespaceRegistryEndpoint string, acc } // Send the second POST request - resp, err = utils.MakeRequest(context.Background(), namespaceRegistryEndpoint, "POST", unidentifiedPayload, nil) + resp, err = utils.MakeRequest(context.Background(), tr, namespaceRegistryEndpoint, "POST", unidentifiedPayload, nil) // Handle case where there was an error encoded in the body if unmarshalErr := json.Unmarshal(resp, &respData); unmarshalErr == nil { @@ -204,7 +207,8 @@ func NamespaceRegister(privateKey jwk.Key, namespaceRegistryEndpoint string, acc } func NamespaceList(endpoint string) error { - respData, err := utils.MakeRequest(context.Background(), endpoint, "GET", nil, nil) + tr := config.GetTransport() + respData, err := utils.MakeRequest(context.Background(), tr, endpoint, "GET", nil, nil) var respErr clientResponseData if err != nil { if jsonErr := json.Unmarshal(respData, &respErr); jsonErr == nil { // Error creating json @@ -217,7 +221,8 @@ func NamespaceList(endpoint string) error { } func NamespaceGet(endpoint string) error { - respData, err := utils.MakeRequest(context.Background(), endpoint, "GET", nil, nil) + tr := config.GetTransport() + respData, err := utils.MakeRequest(context.Background(), tr, endpoint, "GET", nil, nil) var respErr clientResponseData if err != nil { if jsonErr := json.Unmarshal(respData, &respErr); jsonErr == nil { // Error creating json @@ -264,8 +269,8 @@ func NamespaceDelete(endpoint string, prefix string) error { authHeader := map[string]string{ "Authorization": "Bearer " + tok, } - - respData, err := utils.MakeRequest(context.Background(), endpoint, "DELETE", nil, authHeader) + tr := config.GetTransport() + respData, err := utils.MakeRequest(context.Background(), tr, endpoint, "DELETE", nil, authHeader) var respErr clientResponseData if err != nil { if unmarshalErr := json.Unmarshal(respData, &respErr); unmarshalErr == nil { // Error creating json diff --git a/utils/ca_utils.go b/utils/ca_utils.go index 644d3b349..f86acf1ee 100644 --- a/utils/ca_utils.go +++ b/utils/ca_utils.go @@ -33,7 +33,6 @@ import ( log "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" - "github.com/pelicanplatform/pelican/config" "github.com/pelicanplatform/pelican/param" ) @@ -86,13 +85,13 @@ func WriteCABundle(filename string) (int, error) { // // If we're on a platform (Mac, Windows) that does not provide a CA bundle, we return // a count of 0 and do not launch the go routine. -func LaunchPeriodicWriteCABundle(ctx context.Context, filename string, sleepTime time.Duration) (count int, err error) { +func LaunchPeriodicWriteCABundle(ctx context.Context, egrpKey string, filename string, sleepTime time.Duration) (count int, err error) { count, err = WriteCABundle(filename) if err != nil || count == 0 { return } - egrp, ok := ctx.Value(config.EgrpKey).(*errgroup.Group) + egrp, ok := ctx.Value(egrpKey).(*errgroup.Group) if !ok { egrp = &errgroup.Group{} } diff --git a/utils/web_utils.go b/utils/web_utils.go index 8cebb8f7f..513b4395d 100644 --- a/utils/web_utils.go +++ b/utils/web_utils.go @@ -32,13 +32,11 @@ import ( "github.com/gin-gonic/gin" "github.com/lestrrat-go/jwx/v2/jwk" "github.com/pkg/errors" - - "github.com/pelicanplatform/pelican/config" ) // MakeRequest makes an http request with our custom http client. It acts similarly to the http.NewRequest but // it only takes json as the request data. -func MakeRequest(ctx context.Context, url string, method string, data map[string]interface{}, headers map[string]string) ([]byte, error) { +func MakeRequest(ctx context.Context, tr *http.Transport, url string, method string, data map[string]interface{}, headers map[string]string) ([]byte, error) { payload, _ := json.Marshal(data) req, err := http.NewRequestWithContext(ctx, method, url, bytes.NewBuffer(payload)) if err != nil { @@ -49,7 +47,6 @@ func MakeRequest(ctx context.Context, url string, method string, data map[string for key, val := range headers { req.Header.Set(key, val) } - tr := config.GetTransport() client := &http.Client{Transport: tr} resp, err := client.Do(req) @@ -140,11 +137,11 @@ func HasContentType(r *http.Response, mimetype string) bool { return false } -func GetJwks(ctx context.Context, location string) (jwk.Set, error) { +func GetJwks(ctx context.Context, tr *http.Transport, location string) (jwk.Set, error) { if location == "" { return nil, errors.New("jwks location is empty") } - client := http.Client{Transport: config.GetTransport()} + client := http.Client{Transport: tr} req, err := http.NewRequestWithContext(ctx, http.MethodGet, location, nil) if err != nil { return nil, err diff --git a/web_ui/frontend/package-lock.json b/web_ui/frontend/package-lock.json index c2df0dd3f..d555e922e 100644 --- a/web_ui/frontend/package-lock.json +++ b/web_ui/frontend/package-lock.json @@ -896,6 +896,126 @@ "node": ">= 10" } }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.1.tgz", + "integrity": "sha512-KCQmBL0CmFmN8D64FHIZVD9I4ugQsDBBEJKiblXGgwn7wBCSe8N4Dx47sdzl4JAg39IkSN5NNrr8AniXLMb3aw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.1.tgz", + "integrity": "sha512-YDQfbWyW0JMKhJf/T4eyFr4b3tceTorQ5w2n7I0mNVTFOvu6CGEzfwT3RSAQGTi/FFMTFcuspPec/7dFHuP7Eg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.1.tgz", + "integrity": "sha512-fiuN/OG6sNGRN/bRFxRvV5LyzLB8gaL8cbDH5o3mEiVwfcMzyE5T//ilMmaTrnA8HLMS6hoz4cHOu6Qcp9vxgQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.1.tgz", + "integrity": "sha512-rv6AAdEXoezjbdfp3ouMuVqeLjE1Bin0AuE6qxE6V9g3Giz5/R3xpocHoAi7CufRR+lnkuUjRBn05SYJ83oKNQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.1.tgz", + "integrity": "sha512-YAZLGsaNeChSrpz/G7MxO3TIBLaMN8QWMr3X8bt6rCvKovwU7GqQlDu99WdvF33kI8ZahvcdbFsy4jAFzFX7og==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.1.tgz", + "integrity": "sha512-1L4mUYPBMvVDMZg1inUYyPvFSduot0g73hgfD9CODgbr4xiTYe0VOMTZzaRqYJYBA9mana0x4eaAaypmWo1r5A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.1.tgz", + "integrity": "sha512-jvIE9tsuj9vpbbXlR5YxrghRfMuG0Qm/nZ/1KDHc+y6FpnZ/apsgh+G6t15vefU0zp3WSpTMIdXRUsNl/7RSuw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.1.tgz", + "integrity": "sha512-S6K6EHDU5+1KrBDLko7/c1MNy/Ya73pIAmvKeFwsF4RmBFJSO7/7YeD4FnZ4iBdzE69PpQ4sOMU9ORKeNuxe8A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index b8cca22f6..6341a1020 100644 --- a/web_ui/prometheus.go +++ b/web_ui/prometheus.go @@ -150,7 +150,8 @@ func runtimeInfo() (api_v1.RuntimeInfo, error) { func onceLaunchCABundleUpdate(ctx context.Context, caBundle string) (certCtn int, err error) { onceCABundle.Do(func() { - certCtn, err = utils.LaunchPeriodicWriteCABundle(ctx, caBundle, 2*time.Minute) + egrpKey := string(pelican_config.EgrpKey) + certCtn, err = utils.LaunchPeriodicWriteCABundle(ctx, egrpKey, caBundle, 2*time.Minute) }) return } diff --git a/xrootd/xrootd_config.go b/xrootd/xrootd_config.go index 04d43a562..7b8382a66 100644 --- a/xrootd/xrootd_config.go +++ b/xrootd/xrootd_config.go @@ -770,7 +770,8 @@ func ConfigXrootd(ctx context.Context, isOrigin bool) (string, error) { if !isOrigin { runtimeCAs = filepath.Join(param.Cache_RunLocation.GetString(), "ca-bundle.crt") } - caCount, err := utils.LaunchPeriodicWriteCABundle(ctx, runtimeCAs, 2*time.Minute) + egrpKey := string(config.EgrpKey) + caCount, err := utils.LaunchPeriodicWriteCABundle(ctx, egrpKey, runtimeCAs, 2*time.Minute) if err != nil { return "", errors.Wrap(err, "Failed to setup the runtime CA bundle") }