From 4dbf136a04084a2e56b7e240d12cec43ee597784 Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Thu, 5 Dec 2024 15:45:21 -0600 Subject: [PATCH 1/6] Run the 'typos' linter as a 'pre-commit' hook --- .pre-commit-config.yaml | 7 ++++ _typos.toml | 25 ++++++++++++++ broker/client.go | 4 +-- cache/cache_api.go | 2 +- client/acquire_token.go | 2 +- client/director_test.go | 4 +-- client/handle_http.go | 10 +++--- client/main_test.go | 2 +- cmd/config_printer/utils.go | 6 ++-- cmd/plugin_stage.go | 2 +- config/config.go | 6 ++-- config/csrf.go | 12 +++---- config/init_server_creds.go | 12 +++---- dev/dev_pelican.yaml | 2 +- director/advertise_test.go | 2 +- director/director.go | 12 +++---- director/director_api.go | 2 +- director/director_db.go | 2 +- director/director_test.go | 10 +++--- director/director_ui.go | 2 +- director/prom_query_test.go | 2 +- director/sort.go | 2 +- director/sort_algorithms.go | 2 +- director/stat.go | 10 +++--- docs/error_codes.yaml | 4 +-- .../getting-data-with-pelican/client.mdx | 2 +- docs/pages/install/macos.mdx | 2 +- .../pages/operating-a-federation/director.mdx | 2 +- docs/parameters.yaml | 12 +++---- docs/public/origin-dashboard-template.json | 2 +- docs/scopes.yaml | 4 +-- github_scripts/x509_test.sh | 8 ++--- launcher_utils/advertise.go | 2 +- launchers/director_serve.go | 4 +-- local_cache/local_cache.go | 2 +- lotman/lotman_linux.go | 6 ++-- lotman/lotman_test.go | 6 ++-- lotman/lotman_ui.go | 4 +-- metrics/director.go | 6 ++-- metrics/xrootd_metrics.go | 8 ++--- metrics/xrootd_metrics_test.go | 12 +++---- origin/globus.go | 2 +- origin/globus_client.go | 2 +- origin/origin_db_test.go | 2 +- origin/reg_status.go | 2 +- registry/registry.go | 2 +- registry/registry_db_test.go | 4 +-- registry/registry_ui.go | 10 +++--- registry/registry_ui_test.go | 2 +- registry/registry_validation.go | 4 +-- server_structs/director.go | 4 +-- server_structs/generic_server.go | 2 +- server_utils/origin.go | 2 +- server_utils/server_utils.go | 6 ++-- server_utils/server_utils_test.go | 2 +- swagger/pelican-swagger.yaml | 34 +++++++++---------- utils/utils.go | 2 +- web_ui/README.md | 2 +- web_ui/frontend/app/director/page.tsx | 2 +- .../frontend/components/graphs/LineGraph.tsx | 6 ++-- web_ui/session.go | 2 +- web_ui/ui_test.go | 6 ++-- xrootd/authorization_test.go | 2 +- xrootd/xrootd_config.go | 2 +- 64 files changed, 182 insertions(+), 150 deletions(-) create mode 100644 _typos.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 668c3c9a4..2d3d160c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,3 +35,10 @@ repos: rev: v1.56.2 hooks: - id: golangci-lint +- repo: https://github.com/crate-ci/typos + rev: v1.28.2 + hooks: + - id: typos + # Override the default arguments, which include writing back all + # suggested changes. We don't want false positives to mangle files. + args: [--force-exclude, --sort] diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 000000000..e86c36807 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,25 @@ +# Configure 'typos' to reduce false positives. +# For more information, see . + +[default] +extend-ignore-identifiers-re = [ + ## Ignore TLAs. Two and three letter acronyms are not worth fixing. + "^[A-Za-z]{2,3}$", +] + +[default.extend-identifiers] +## The 'cipher' library uses "Encrypter"; 'typos' prefers "Encryptor". +NewCFBEncrypter = "NewCFBEncrypter" +## HTCondor's daemon names follow the usual "{word} + 'd'" convention. +StartdAttrs = "StartdAttrs" +## Other one-off identifiers that do not need fixing. +sentinel_dne = "sentinel_dne" # server_utils/origin_test.go + +[files] +extend-exclude = [ + ## Ignore configuration files and the like. + "go.mod", + "xrootd/resources/osdf-authfile", + ## Ignore this script because of its inline certificates. + "github_scripts/osx_install.sh", +] diff --git a/broker/client.go b/broker/client.go index 81064c0b8..6acc7853f 100644 --- a/broker/client.go +++ b/broker/client.go @@ -163,7 +163,7 @@ func ConnectToOrigin(ctx context.Context, brokerUrl, prefix, originName string) if err = config.GenerateCACert(); err != nil { return } - caCert, err := config.LoadCertficate(param.Server_TLSCACertificateFile.GetString()) + caCert, err := config.LoadCertificate(param.Server_TLSCACertificateFile.GetString()) if err != nil { return } @@ -529,7 +529,7 @@ func doCallback(ctx context.Context, brokerResp reversalRequest) (listener net.L hj.realConn.Close() newConn, err := net.FileConn(fp) if err != nil { - err = errors.Wrap(err, "Failure when making scoket from duplicated connection") + err = errors.Wrap(err, "Failure when making socket from duplicated connection") return } fp.Close() diff --git a/cache/cache_api.go b/cache/cache_api.go index 110034024..bcd8964d1 100644 --- a/cache/cache_api.go +++ b/cache/cache_api.go @@ -85,7 +85,7 @@ func LaunchDirectorTestFileCleanup(ctx context.Context) { } directorItems = append(directorItems, item) } - if len(directorItems) <= 2 { // At mininum there are the test file and .cinfo file, and we don't want to remove the last two + if len(directorItems) <= 2 { // At minimum there are the test file and .cinfo file, and we don't want to remove the last two return nil } for idx, item := range directorItems { diff --git a/client/acquire_token.go b/client/acquire_token.go index 40269e62e..5e30dd32b 100644 --- a/client/acquire_token.go +++ b/client/acquire_token.go @@ -211,7 +211,7 @@ func (tci *tokenContentIterator) discoverHTCondorTokenLocations(tokenName string func (tci *tokenContentIterator) next() (string, bool) { /* - Search for the location of the authentiction token. It can be set explicitly on the command line, + Search for the location of the authentication token. It can be set explicitly on the command line, with the environment variable "BEARER_TOKEN", or it can be searched in the standard HTCondor directory pointed to by the environment variable "_CONDOR_CREDS". */ diff --git a/client/director_test.go b/client/director_test.go index ca6ea540e..2db60eaba 100644 --- a/client/director_test.go +++ b/client/director_test.go @@ -182,7 +182,7 @@ func TestGetDirectorInfoForPath(t *testing.T) { expectedError: "", }, { - name: "PUT request changes verb", // also generates 405, although this is a feauture of the director + name: "PUT request changes verb", // also generates 405, although this is a feature of the director resourcePath: "/test", directorUrl: ts.URL, httpMethod: http.MethodPut, @@ -190,7 +190,7 @@ func TestGetDirectorInfoForPath(t *testing.T) { expectedError: "the director returned status code 405", }, { - name: "Queries are propagated", // also generates 405, although this is a feauture of the director + name: "Queries are propagated", // also generates 405, although this is a feature of the director resourcePath: "/test", directorUrl: ts.URL, httpMethod: http.MethodGet, diff --git a/client/handle_http.go b/client/handle_http.go index 74cd7499b..b233ff747 100644 --- a/client/handle_http.go +++ b/client/handle_http.go @@ -116,7 +116,7 @@ type ( err error } - // StatusCodeError is a wrapper around grab.StatusCodeErorr that indicates the server returned + // StatusCodeError is a wrapper around grab.StatusCodeError that indicates the server returned // a non-200 code. // // The wrapper is done to provide a Pelican-based error hierarchy in case we ever decide to have @@ -1119,7 +1119,7 @@ func (tj *TransferJob) GetLookupStatus() (ok bool, err error) { // Submit the transfer job to the client for processing func (tc *TransferClient) Submit(tj *TransferJob) error { // Ensure that a tj.Wait() immediately after Submit will always block. - log.Debugln("Submiting transfer job", tj.uuid.String()) + log.Debugln("Submitting transfer job", tj.uuid.String()) select { case <-tc.ctx.Done(): return tc.ctx.Err() @@ -1878,7 +1878,7 @@ func downloadHTTP(ctx context.Context, te *TransferEngine, callback TransferCall if ageSec, err := strconv.Atoi(ageStr); err == nil { cacheAge = time.Duration(ageSec) * time.Second } else { - log.WithFields(fields).Debugf("Server at %s gave unparseable Age header (%s) in response: %s", transfer.Url.Host, ageStr, err.Error()) + log.WithFields(fields).Debugf("Server at %s gave unparsable Age header (%s) in response: %s", transfer.Url.Host, ageStr, err.Error()) } } if cacheAge == 0 { @@ -1917,7 +1917,7 @@ func downloadHTTP(ctx context.Context, te *TransferEngine, callback TransferCall callback(dest, 0, totalSize, false) } - stoppedTransferTimeout := compatToDuration(param.Client_StoppedTransferTimeout.GetDuration(), "Client.StoppedTranferTimeout") + stoppedTransferTimeout := compatToDuration(param.Client_StoppedTransferTimeout.GetDuration(), "Client.StoppedTransferTimeout") slowTransferRampupTime := compatToDuration(param.Client_SlowTransferRampupTime.GetDuration(), "Client.SlowTransferRampupTime") slowTransferWindow := compatToDuration(param.Client_SlowTransferWindow.GetDuration(), "Client.SlowTransferWindow") stoppedTransferDebugLine.Do(func() { @@ -2096,7 +2096,7 @@ func (pr *ProgressReader) Read(p []byte) (n int, err error) { return n, err } -// Close implments the close function of io.Closer +// Close implements the close function of io.Closer func (pr *ProgressReader) Close() error { err := pr.reader.Close() // Also, send the closed channel a message diff --git a/client/main_test.go b/client/main_test.go index daacc05a7..7483dff2b 100644 --- a/client/main_test.go +++ b/client/main_test.go @@ -105,7 +105,7 @@ func TestGenerateSortedObjectServers(t *testing.T) { }) // Test our prepend works with multiple preferred caches - t.Run("testMutliPreferredCachesPrepend", func(t *testing.T) { + t.Run("testMultiPreferredCachesPrepend", func(t *testing.T) { preferredOServers := []*url.URL{ {Scheme: "https", Host: "preferred1.com", Path: "/foo"}, {Scheme: "https", Host: "preferred2.com", Path: "/foo"}, diff --git a/cmd/config_printer/utils.go b/cmd/config_printer/utils.go index 05b0e073e..ffee4f510 100644 --- a/cmd/config_printer/utils.go +++ b/cmd/config_printer/utils.go @@ -53,11 +53,11 @@ func initClientAndServerConfig(v *viper.Viper) *param.Config { config.SetFederation(globalFedInfo) } - exapandedConfig, err := param.UnmarshalConfig(v) + expandedConfig, err := param.UnmarshalConfig(v) if err != nil { - log.Errorf("Error unmarshaling config: %v", err) + log.Errorf("Error unmarshalling config: %v", err) } - return exapandedConfig + return expandedConfig } // printConfig is used to print a config. diff --git a/cmd/plugin_stage.go b/cmd/plugin_stage.go index 4d47f9bcd..5fb83b0ce 100644 --- a/cmd/plugin_stage.go +++ b/cmd/plugin_stage.go @@ -118,7 +118,7 @@ func stagePluginMain(cmd *cobra.Command, args []string) { var sources, extraSources []string var exitCode int - // If not a condor hook, our souces come from our args + // If not a condor hook, our sources come from our args if !isHook { log.Debugln("Len of source:", len(args)) if len(args) < 1 { diff --git a/config/config.go b/config/config.go index d2aa66a26..7afbb0b6c 100644 --- a/config/config.go +++ b/config/config.go @@ -537,7 +537,7 @@ func setupTransport() { if param.TLSSkipVerify.GetBool() { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } - if caCert, err := LoadCertficate(param.Server_TLSCACertificateFile.GetString()); err == nil { + if caCert, err := LoadCertificate(param.Server_TLSCACertificateFile.GetString()); err == nil { systemPool, err := x509.SystemCertPool() if err == nil { systemPool.AddCert(caCert) @@ -594,7 +594,7 @@ func GetTransport() *http.Transport { return transport } -// Get singleton global validte method for field validation +// Get singleton global validate method for field validation func GetValidate() *validator.Validate { return validate } @@ -1036,7 +1036,7 @@ func SetServerDefaults(v *viper.Viper) error { v.SetDefault(param.Origin_StorageType.GetName(), "posix") v.SetDefault(param.Origin_SelfTest.GetName(), true) v.SetDefault(param.Origin_DirectorTest.GetName(), true) - // Set up the default S3 URL style to be path-style here as opposed to in the defaults.yaml becase + // Set up the default S3 URL style to be path-style here as opposed to in the defaults.yaml because // we want to be able to check if this is user-provided (which we can't do for defaults.yaml) v.SetDefault(param.Origin_S3UrlStyle.GetName(), "path") diff --git a/config/csrf.go b/config/csrf.go index 2ae42624d..2d974e991 100644 --- a/config/csrf.go +++ b/config/csrf.go @@ -31,8 +31,8 @@ import ( var ( // Global CSRF handler that shares the same auth key - csrfHanlder gin.HandlerFunc - onceCSRFHanlder sync.Once + csrfHandler gin.HandlerFunc + onceCSRFHandler sync.Once ) func setupCSRFHandler() { @@ -52,15 +52,15 @@ func setupCSRFHandler() { } })), ) - csrfHanlder = adapter.Wrap(CSRF) + csrfHandler = adapter.Wrap(CSRF) } func GetCSRFHandler() (gin.HandlerFunc, error) { - onceCSRFHanlder.Do(func() { + onceCSRFHandler.Do(func() { setupCSRFHandler() }) - if csrfHanlder == nil { + if csrfHandler == nil { return nil, errors.New("Error setting up the CSRF handler") } - return csrfHanlder, nil + return csrfHandler, nil } diff --git a/config/init_server_creds.go b/config/init_server_creds.go index 97b5bec8c..8d2772311 100644 --- a/config/init_server_creds.go +++ b/config/init_server_creds.go @@ -313,10 +313,10 @@ func GenerateCACert() error { return nil } -// Read a PEM-encoded TLS certficate file, parse and return the first +// Read a PEM-encoded TLS certificate file, parse and return the first // certificate appeared in the chain. Return error if there's no cert // present in the file -func LoadCertficate(certFile string) (*x509.Certificate, error) { +func LoadCertificate(certFile string) (*x509.Certificate, error) { rest, err := os.ReadFile(certFile) if err != nil { return nil, err @@ -343,7 +343,7 @@ func LoadCertficate(certFile string) (*x509.Certificate, error) { } // Generate a TLS certificate (host certificate) and its private key -// for non-production environment if the requied TLS files are not present +// for non-production environment if the required TLS files are not present func GenerateCert() error { gid, err := GetDaemonGID() if err != nil { @@ -373,7 +373,7 @@ func GenerateCert() error { if _, err := os.Open(caCert); err == nil { file.Close() // Check that the CA is a valid CA - if _, err := LoadCertficate(caCert); err != nil { + if _, err := LoadCertificate(caCert); err != nil { return errors.Wrap(err, "Failed to load CA cert") } else { // TODO: Check that the private key is a pair of the server cert @@ -399,7 +399,7 @@ func GenerateCert() error { if err := GenerateCACert(); err != nil { return err } - caCert, err := LoadCertficate(param.Server_TLSCACertificateFile.GetString()) + caCert, err := LoadCertificate(param.Server_TLSCACertificateFile.GetString()) if err != nil { return err } @@ -407,7 +407,7 @@ func GenerateCert() error { // However, if only CA is missing but TLS cert and private key are present, we simply // generate the CA and return if tlsCertPrivateKeyExists { - log.Debug("TLS Certficiate and its private key are present. Generated a CA and returns.") + log.Debug("TLS Certificate and its private key are present. Generated a CA and returns.") return nil } diff --git a/dev/dev_pelican.yaml b/dev/dev_pelican.yaml index 3a6570058..e50203956 100644 --- a/dev/dev_pelican.yaml +++ b/dev/dev_pelican.yaml @@ -1,4 +1,4 @@ -TLSSkipVerify: true # Turn off the TLS check for developmetn +TLSSkipVerify: true # Turn off the TLS check for development Logging: Level: "debug" # Debug level will log more verbose messages Federation: diff --git a/director/advertise_test.go b/director/advertise_test.go index 3cd3ddb5f..d63efd1ac 100644 --- a/director/advertise_test.go +++ b/director/advertise_test.go @@ -303,7 +303,7 @@ func mockTopoDowntimeXMLHandler(w http.ResponseWriter, r *http.Request) { downtimeInfo := server_structs.TopoCurrentDowntimes{ Downtimes: []server_structs.TopoServerDowntime{ { - // Current time falls in start-end window. SHould be filtered + // Current time falls in start-end window. Should be filtered ResourceName: "BOISE_INTERNET2_OSDF_CACHE", ResourceFQDN: "dtn-pas.bois.nrp.internet2.edu", StartTime: time.Now().Add(-24 * time.Hour).Format("Jan 2, 2006 03:04 PM MST"), diff --git a/director/director.go b/director/director.go index 57adbd30f..fcde21f91 100644 --- a/director/director.go +++ b/director/director.go @@ -264,9 +264,9 @@ func generateXNamespaceHeader(ginCtx *gin.Context, namespaceAd server_structs.Na ginCtx.Writer.Header()["X-Pelican-Namespace"] = []string{xPelicanNamespace} } -func getFinalRedirectURL(rurl url.URL, requstParams url.Values) string { +func getFinalRedirectURL(rurl url.URL, requestParams url.Values) string { rQuery := rurl.Query() - for key, vals := range requstParams { + for key, vals := range requestParams { for _, val := range vals { rQuery.Add(key, val) } @@ -924,7 +924,7 @@ func ShortcutMiddleware(defaultResponse string) gin.HandlerFunc { } } - // Check for the DirectRead query paramater and redirect to the origin if it's set if the origin allows DirectReads + // Check for the DirectRead query parameter and redirect to the origin if it's set if the origin allows DirectReads if c.Request.URL.Query().Has(pelican_url.QueryDirectRead) { log.Debugln("directread query parameter detected, redirecting to origin") // We'll redirect to origin here and the origin will decide if it can serve the request (if direct reads are enabled) @@ -1194,7 +1194,7 @@ func serverAdMetricMiddleware(ctx *gin.Context) { if len(namespacePath) == 0 { continue } - metrics.PelicanDirectorAdvertisementsRecievedTotal.With( + metrics.PelicanDirectorAdvertisementsReceivedTotal.With( prometheus.Labels{ "server_name": serverName, "server_web_url": serverWebUrl, @@ -1370,9 +1370,9 @@ func collectClientVersionMetric(reqVer *version.Version, service string) { fmt.Sprintf("%d", versionSegments[1]), } - shortendVersion := strings.Join(strSegments, ".") + shortenedVersion := strings.Join(strSegments, ".") - metrics.PelicanDirectorClientVersionTotal.With(prometheus.Labels{"version": shortendVersion, "service": service}).Inc() + metrics.PelicanDirectorClientVersionTotal.With(prometheus.Labels{"version": shortenedVersion, "service": service}).Inc() } func collectDirectorRedirectionMetric(ctx *gin.Context, destination string) { diff --git a/director/director_api.go b/director/director_api.go index a427c92c2..9236da86e 100644 --- a/director/director_api.go +++ b/director/director_api.go @@ -224,7 +224,7 @@ func hookServerAdsCache() { } // Populate internal filteredServers map using Director.FilteredServers param and director db -func ConfigFilterdServers() { +func ConfigFilteredServers() { filteredServersMutex.Lock() defer filteredServersMutex.Unlock() diff --git a/director/director_db.go b/director/director_db.go index 47a22ce69..1a5065359 100644 --- a/director/director_db.go +++ b/director/director_db.go @@ -115,7 +115,7 @@ func getAllServerDowntimes() ([]ServerDowntime, error) { // Set the downtime info (filterType) of a given server func setServerDowntime(serverName string, filterType filterType) error { var serverDowntime ServerDowntime - // slience the logger for this query because there's definitely an ErrRecordNotFound when a new downtime info entry inserted + // silence the logger for this query because there's definitely an ErrRecordNotFound when a new downtime info entry inserted err := db.Session(&gorm.Session{Logger: db.Logger.LogMode(logger.Silent)}).First(&serverDowntime, "name = ?", serverName).Error // If the server doesn't exist in director db, create a new entry for it diff --git a/director/director_test.go b/director/director_test.go index 31597d9ac..77440023d 100644 --- a/director/director_test.go +++ b/director/director_test.go @@ -236,9 +236,9 @@ func TestDirectorRegistration(t *testing.T) { return tok } - setupRequest := func(c *gin.Context, r *gin.Engine, bodyByt []byte, token string, stype server_structs.ServerType) { + setupRequest := func(c *gin.Context, r *gin.Engine, bodyByte []byte, token string, stype server_structs.ServerType) { r.POST("/", func(gctx *gin.Context) { registerServeAd(ctx, gctx, stype) }) - c.Request, _ = http.NewRequest(http.MethodPost, "/", bytes.NewBuffer(bodyByt)) + c.Request, _ = http.NewRequest(http.MethodPost, "/", bytes.NewBuffer(bodyByte)) c.Request.Header.Set("Authorization", "Bearer "+token) c.Request.Header.Set("Content-Type", "application/json") // Hard code the current min version. When this test starts failing because of new stuff in the Director, @@ -1515,7 +1515,7 @@ func TestRedirects(t *testing.T) { router := gin.Default() router.GET("/api/v1.0/director/origin/*any", redirectToOrigin) - // Check that the checkkHostnameRedirects uses the pre-configured hostnames to redirect + // Check that the checkHostnameRedirects uses the pre-configured hostnames to redirect // requests that come in at the default paths, but not if the request is made // specifically for an object or a cache via the API. t.Run("redirect-check-hostnames", func(t *testing.T) { @@ -1979,7 +1979,7 @@ func TestHandleFilterServer(t *testing.T) { resB, err := io.ReadAll(w.Body) require.NoError(t, err) - assert.Contains(t, string(resB), "Can't filter a server that already has been fitlered") + assert.Contains(t, string(resB), "Can't filter a server that already has been filtered") }) t.Run("filter-server-w-tempFiltered", func(t *testing.T) { // Create a request to the endpoint @@ -2008,7 +2008,7 @@ func TestHandleFilterServer(t *testing.T) { resB, err := io.ReadAll(w.Body) require.NoError(t, err) - assert.Contains(t, string(resB), "Can't filter a server that already has been fitlered") + assert.Contains(t, string(resB), "Can't filter a server that already has been filtered") }) t.Run("filter-server-w-tempAllowed", func(t *testing.T) { // Create a request to the endpoint diff --git a/director/director_ui.go b/director/director_ui.go index 79e343d83..1a8c5eef8 100644 --- a/director/director_ui.go +++ b/director/director_ui.go @@ -463,7 +463,7 @@ func handleFilterServer(ctx *gin.Context) { if filtered { ctx.JSON(http.StatusBadRequest, server_structs.SimpleApiResp{ Status: server_structs.RespFailed, - Msg: fmt.Sprint("Can't filter a server that already has been fitlered with type ", filterType), + Msg: fmt.Sprint("Can't filter a server that already has been filtered with type ", filterType), }) return } diff --git a/director/prom_query_test.go b/director/prom_query_test.go index 9cb26654d..1808034ed 100644 --- a/director/prom_query_test.go +++ b/director/prom_query_test.go @@ -83,7 +83,7 @@ func TestParsePromRes(t *testing.T) { t.Run("error-when-unixtime-is-wrong", func(t *testing.T) { mockPromQLRes := promQLRes{Data: promQLResData{ ResultType: "string", - Result: []interface{}{"misformed-unixtime", "mock string"}, + Result: []interface{}{"malformed-unixtime", "mock string"}, }} _, err := parsePromRes(mockPromQLRes) require.Error(t, err) diff --git a/director/sort.go b/director/sort.go index b0450f355..981ee4374 100644 --- a/director/sort.go +++ b/director/sort.go @@ -85,7 +85,7 @@ var ( // Constants for the director sorting algorithm const ( - souceServerAdsLimit = 6 // Number of servers under consideration + sourceServerAdsLimit = 6 // Number of servers under consideration distanceHalvingThreshold = 10 // Threshold where the distance havling factor kicks in, in miles distanceHalvingFactor = 200 // Halving distance for the GeoIP weight, in miles objAvailabilityFactor = 2 // Multiplier for knowing whether an object is present diff --git a/director/sort_algorithms.go b/director/sort_algorithms.go index efbd14f93..38874a636 100644 --- a/director/sort_algorithms.go +++ b/director/sort_algorithms.go @@ -96,7 +96,7 @@ func gatedHalvingMultiplier(val float64, threshold float64, halvingFactor float6 } } -// Given a SwapMaps struct, stochasticlly sort the weights based on the folliwng procedure: +// Given a SwapMaps struct, stochasticlly sort the weights based on the following procedure: // // 1. Create ranges [0, weight_1), [weight_1, weight_1 + weight_2), ... for each weight. // diff --git a/director/stat.go b/director/stat.go index 5c249d4f6..5b6000ae1 100644 --- a/director/stat.go +++ b/director/stat.go @@ -78,12 +78,12 @@ type ( // // dataUrl: the base url to access data on the server. This is usually the url pointed at the XRootD instance on the server // - // digest: requst digest for object checkusm. XRootD responds with 403 if digest feature is turned off on the server + // digest: request digest for object checksum. XRootD responds with 403 if digest feature is turned off on the server // // token: a bearer token to be used when issuing the request ReqHandler func(maxCancelCtx context.Context, objectName string, dataUrl url.URL, digest bool, token string, timeout time.Duration) (*objectMetadata, error) // Manage a `stat` request to origin servers given an objectName - Query func(cancelContext context.Context, objectName string, sType server_structs.ServerType, mininum, maximum int, options ...queryOption) queryResult + Query func(cancelContext context.Context, objectName string, sType server_structs.ServerType, minimum, maximum int, options ...queryOption) queryResult } ) @@ -225,11 +225,11 @@ func (stat *ObjectStat) sendHeadReq(ctx context.Context, objectName string, data } else { cLenStr := res.Header.Get("Content-Length") checksumStr := res.Header.Get("Digest") - clen, err := strconv.Atoi(cLenStr) + cLen, err := strconv.Atoi(cLenStr) if err != nil { return nil, errors.New(fmt.Sprintf("error parsing content-length header from response. Header was: %s", cLenStr)) } - return &objectMetadata{ContentLength: clen, Checksum: checksumStr, URL: *dataUrl.JoinPath(objectName)}, nil + return &objectMetadata{ContentLength: cLen, Checksum: checksumStr, URL: *dataUrl.JoinPath(objectName)}, nil } } @@ -440,7 +440,7 @@ func (stat *ObjectStat) queryServersForObject(ctx context.Context, objectName st return nil default: negativeReqChan <- err - totalLabels["result"] = string(metrics.StatUnkownErr) + totalLabels["result"] = string(metrics.StatUnknownErr) metrics.PelicanDirectorStatTotal.With(totalLabels).Inc() return nil } diff --git a/docs/error_codes.yaml b/docs/error_codes.yaml index 482ddfd44..b5ae6679b 100644 --- a/docs/error_codes.yaml +++ b/docs/error_codes.yaml @@ -125,7 +125,7 @@ code: 5011 clientExitCode: 8 description: >- If the client successfully contacted the server but the desired file does not exist for download. - The user might have enterred the wrong URL or the file might not yet be at the specified origin. + The user might have entered the wrong URL or the file might not yet be at the specified origin. retryable: false --- type: Specification.FileNotCreated @@ -158,5 +158,5 @@ type: Transfer.SlowTransfer code: 6002 clientExitCode: 11 description: >- - The client started transferring data but the transfer was slower than the minumum configured timeout rate. + The client started transferring data but the transfer was slower than the minimum configured timeout rate. retryable: true diff --git a/docs/pages/getting-data-with-pelican/client.mdx b/docs/pages/getting-data-with-pelican/client.mdx index f989afd61..ca40dc2b6 100644 --- a/docs/pages/getting-data-with-pelican/client.mdx +++ b/docs/pages/getting-data-with-pelican/client.mdx @@ -237,7 +237,7 @@ The Pelican client supports a variety of command line flags that modify the clie - **-c or --cache:** Takes a cache URL and indicates to Pelican that only the specified cache should be used. When used, Pelican will not attempt to use other caches if the provided cache cannot provide the file. - **--caches:** Takes the path to a JSON file containing a list of caches. Similar to the `-c` flag, Pelican will attempt to use only these caches in the order they are listed. - **-h or --help:** Gives additional information on how to use the command as well as lists these flags with short descriptions for the `object copy` command. -- **--methods:** Takes a comma seperated list of methods to try for downloads/uploads, the default is just http. +- **--methods:** Takes a comma separated list of methods to try for downloads/uploads, the default is just http. - **-r or --recursive:** Takes no argument and indicates to Pelican that all sub paths at the level of the provided namespace should be copied recursively. This option is only supported if the origin supports the WebDav protocol. - **-t or --token:** Takes a path to a file containing a signed JWT, and is used to download protected objects. diff --git a/docs/pages/install/macos.mdx b/docs/pages/install/macos.mdx index b6f7e5185..d0972636a 100644 --- a/docs/pages/install/macos.mdx +++ b/docs/pages/install/macos.mdx @@ -10,7 +10,7 @@ Pelican provides a binary executable file instead of a `DMG` installer for MacOS > **Note:** If you don't know your computer's architecture, click the **Apple menu**  in the top-left corner of your screen, then click **About This Mac** and check the **Chip** or **Processor** field. If it mentions **Intel** your computer needs Pelican's **X86_64** executable, and if it mentions Apple M1, M2, or later, you'll need the **ARM64** executable. Intel Macs (x86_64) should see the file `pelican_Darwin_x86_64.tar.gz` and Apple Silicon Macs (ARM64) should see `pelican_Darwin_arm64.tar.gz`. -1. Open a terminal and navigate to a directory where you can download, extract and store the Pelican executable. Then use your command line tools of choice to download and extract the link you copied in the previous step. The rest of these intructions assume `curl` for downloading and `tar` for extraction: +1. Open a terminal and navigate to a directory where you can download, extract and store the Pelican executable. Then use your command line tools of choice to download and extract the link you copied in the previous step. The rest of these instructions assume `curl` for downloading and `tar` for extraction: ```bash curl -LO diff --git a/docs/pages/operating-a-federation/director.mdx b/docs/pages/operating-a-federation/director.mdx index a28a40a0d..2031881c7 100644 --- a/docs/pages/operating-a-federation/director.mdx +++ b/docs/pages/operating-a-federation/director.mdx @@ -80,7 +80,7 @@ A Pelican director by default redirects object request from clients to the geosp ### `GeoIPOverrides` -The MaxMind database may fail to return a valid longitute/latitute pair given a server IP. For example, the database does not support IPV6 addresses. In such cases, you may pass a list of IP addresses to `GeoIPOverrides` parameter whose GeoIP resolution should be overridden with the supplied Lat/Long coordinates (in decimal form). This affects both server ads (for determining the location of origins and caches) and incoming client requests (for determing where a client request is coming from). +The MaxMind database may fail to return a valid longitute/latitute pair given a server IP. For example, the database does not support IPV6 addresses. In such cases, you may pass a list of IP addresses to `GeoIPOverrides` parameter whose GeoIP resolution should be overridden with the supplied Lat/Long coordinates (in decimal form). This affects both server ads (for determining the location of origins and caches) and incoming client requests (for determining where a client request is coming from). ### `Director.CacheResponseHostnames` and `Director.OriginResponseHostnames` diff --git a/docs/parameters.yaml b/docs/parameters.yaml index f086ca5ac..ccbb1633f 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -126,7 +126,7 @@ components: ["client", "registry", "origin"] name: GeoIPOverrides description: |+ A list of IP addresses whose GeoIP resolution should be overridden with the supplied Lat/Long coordinates (in decimal form). This affects - both server ads (for determining the location of origins and caches) and incoming client requests (for determing where a client request is + both server ads (for determining the location of origins and caches) and incoming client requests (for determining where a client request is coming from). Configuration takes an IP address (both regular and CIDR) and a Coordinate made up of a lat/long pair in decimal format. For example: @@ -1349,9 +1349,9 @@ components: ["cache"] --- name: Cache.BlocksToPrefetch description: |+ - The number of 128 kilobyte blocks the cache will read ahead when recieving requests. This will put the data in the cache + The number of 128 kilobyte blocks the cache will read ahead when receiving requests. This will put the data in the cache potentially before it is needed and reduce the latency to the client when a request is made. However, it can also cause - many extra requests to an origin and potentially overload it when unnessesary. As such, this is turned off by default. + many extra requests to an origin and potentially overload it when unnecessary. As such, this is turned off by default. type: int default: 0 components: ["cache"] @@ -1407,7 +1407,7 @@ components: ["director"] --- name: Director.CacheSortMethod description: |+ - When the director recieves a client request that needs to be redirected to a cache, it will use this method to + When the director receives a client request that needs to be redirected to a cache, it will use this method to determine the ordering of the caches. The default method is "distance", which sorts caches by their spherical distance from the client. @@ -1708,7 +1708,7 @@ description: |+ - `name` must be snake case with underline connecting words, i.e. department_name. The name displayed in the registration table will be converted from this field - into a human-readble, space-separated name with the first letter(s) capitalized. i.e. department_name -> Department Name + into a human-readable, space-separated name with the first letter(s) capitalized. i.e. department_name -> Department Name - `type` must be one of `string`, `int`, `bool`, `datetime` (Unix time in seconds), or `enum`. - `options` must be a non-empty yaml array for field with type `enum`. `optionsUrl` will be ignored if `options` is set. @@ -2586,7 +2586,7 @@ name: Shoveler.StompCert description: |+ For stomp only. - A filepath to the location of the TLS certifcate. + A filepath to the location of the TLS certificate. type: filename default: none components: ["origin", "cache"] diff --git a/docs/public/origin-dashboard-template.json b/docs/public/origin-dashboard-template.json index be53be0c4..6237538df 100644 --- a/docs/public/origin-dashboard-template.json +++ b/docs/public/origin-dashboard-template.json @@ -788,7 +788,7 @@ "properties": [ { "id": "displayName", - "value": "Recieved" + "value": "Received" } ] }, diff --git a/docs/scopes.yaml b/docs/scopes.yaml index 023f37194..fcc861da8 100644 --- a/docs/scopes.yaml +++ b/docs/scopes.yaml @@ -14,11 +14,11 @@ # limitations under the License. # -# This file contains structured documentaion about the scopes of JWTs +# This file contains structured documentation about the scopes of JWTs # that will be issued and exchanged for Pelican servers to communicate with # each other as well as for users to access functions in Pelican server Web UI -# Naming covention: . snake case for naming +# Naming convention: . snake case for naming ############################ # Top-level Scopes # diff --git a/github_scripts/x509_test.sh b/github_scripts/x509_test.sh index f0b5ff18a..4375cb117 100755 --- a/github_scripts/x509_test.sh +++ b/github_scripts/x509_test.sh @@ -15,10 +15,10 @@ # limitations under the License. # -# This test the functionaliy of the x509 defer check +# This test the functionally of the x509 defer check # Some prefixes allow for x509 authentication rather than using tokens, this tests -# that a file that requires authorization is retreivable when using either x509 authentication or a token -# and also tests that files that aren't allowed to use x509 authentication are not retreivable +# that a file that requires authorization is retrievable when using either x509 authentication or a token +# and also tests that files that aren't allowed to use x509 authentication are not retrievable mkdir -p x509/config chmod 777 x509/config @@ -167,7 +167,7 @@ else exit 1 fi -# Run a curl with an x509 value on a non defered namespace prefix +# Run a curl with an x509 value on a non deferred namespace prefix curl -v -k -L https://localhost:8444/test/input.txt --tlsv1.3 --cert x509/config/certificates/tls.crt --key x509/config/certificates/tls.key &> x509/badCurlX509Output.txt # Check output of command diff --git a/launcher_utils/advertise.go b/launcher_utils/advertise.go index 4ca803ccd..e51d1b488 100644 --- a/launcher_utils/advertise.go +++ b/launcher_utils/advertise.go @@ -19,7 +19,7 @@ // Package launcher_utils contains utility functions for the [github.com/pelicanplatform/pelican/launcher] package. // // It should only be imported by the launchers package -// It should NOT be imported to any server pacakges (origin/cache/registry) or other lower level packages (config/utils/etc) +// It should NOT be imported to any server packages (origin/cache/registry) or other lower level packages (config/utils/etc) package launcher_utils import ( diff --git a/launchers/director_serve.go b/launchers/director_serve.go index 4fde00fc8..43f06401f 100644 --- a/launchers/director_serve.go +++ b/launchers/director_serve.go @@ -42,13 +42,13 @@ func DirectorServe(ctx context.Context, engine *gin.Engine, egrp *errgroup.Group if err := director.InitializeDB(); err != nil { return errors.Wrap(err, "failed to initialize director sqlite database") } - director.ConfigFilterdServers() + director.ConfigFilteredServers() director.LaunchTTLCache(ctx, egrp) director.LaunchMapMetrics(ctx, egrp) - director.ConfigFilterdServers() + director.ConfigFilteredServers() director.LaunchServerIOQuery(ctx, egrp) diff --git a/local_cache/local_cache.go b/local_cache/local_cache.go index 1cfd77dfb..7b372f19f 100644 --- a/local_cache/local_cache.go +++ b/local_cache/local_cache.go @@ -656,7 +656,7 @@ func (lc *LocalCache) purge() (err error) { // Given a URL, return a reader from the disk cache // -// If there is no sentinal $NAME.DONE file, then returns nil +// If there is no sentinel $NAME.DONE file, then returns nil func (sc *LocalCache) getFromDisk(localPath string) *os.File { localPath = filepath.Join(sc.basePath, path.Clean(localPath)) fp, err := os.Open(localPath + ".DONE") diff --git a/lotman/lotman_linux.go b/lotman/lotman_linux.go index 93086e6f9..3fc071348 100644 --- a/lotman/lotman_linux.go +++ b/lotman/lotman_linux.go @@ -64,7 +64,7 @@ var ( LotmanUpdateLot func(updateJSON string, errMsg *[]byte) int32 LotmanDeleteLotsRecursive func(lotName string, errMsg *[]byte) int32 - // Auxilliary functions + // Auxiliary functions LotmanLotExists func(lotName string, errMsg *[]byte) int32 LotmanSetContextStr func(contextKey string, contextValue string, errMsg *[]byte) int32 LotmanGetContextStr func(key string, output *[]byte, errMsg *[]byte) int32 @@ -962,7 +962,7 @@ func InitLotman(adsFromFed []server_structs.NamespaceAdV2) bool { // D purego.RegisterLibFunc(&LotmanDeleteLotsRecursive, lotmanLib, "lotman_remove_lots_recursive") - // Auxilliary functions + // Auxiliary functions purego.RegisterLibFunc(&LotmanLotExists, lotmanLib, "lotman_lot_exists") purego.RegisterLibFunc(&LotmanSetContextStr, lotmanLib, "lotman_set_context_str") purego.RegisterLibFunc(&LotmanGetContextStr, lotmanLib, "lotman_get_context_str") @@ -1168,7 +1168,7 @@ func CreateLot(newLot *Lot, caller string) error { // Given a lot name, get the lot from the lot database. If recursive is true, we'll also // determine all hierarchical restrictions on the lot. For example, if the lot "foo" has // dedicated_GB = 2.0 but its parent lot "bar" has dedicated_GB = 1.0, then calling this -// with recusrive = true will indicate the restricting value and the lot it comes from. +// with recursive = true will indicate the restricting value and the lot it comes from. func GetLot(lotName string, recursive bool) (*Lot, error) { // Haven't given much thought to these buff sizes yet outputBuf := make([]byte, 4096) diff --git a/lotman/lotman_test.go b/lotman/lotman_test.go index d872d4b02..685964281 100644 --- a/lotman/lotman_test.go +++ b/lotman/lotman_test.go @@ -345,11 +345,11 @@ func TestUpdateLot(t *testing.T) { require.True(t, success) // Update the test-1 lot - dedGB := float64(999.0) + dedicatedGB := float64(999.0) lotUpdate := LotUpdate{ LotName: "test-1", MPA: &MPA{ - DedicatedGB: &dedGB, + DedicatedGB: &dedicatedGB, MaxNumObjects: &Int64FromFloat{ Value: 84, }, @@ -370,7 +370,7 @@ func TestUpdateLot(t *testing.T) { lot, err := GetLot("test-1", true) require.NoError(t, err, "Failed to get lot") require.Equal(t, "test-1", lot.LotName) - require.Equal(t, dedGB, *(lot.MPA.DedicatedGB)) + require.Equal(t, dedicatedGB, *(lot.MPA.DedicatedGB)) require.Equal(t, int64(84), lot.MPA.MaxNumObjects.Value) require.Equal(t, "/test-1-updated", lot.Paths[0].Path) require.False(t, lot.Paths[0].Recursive) diff --git a/lotman/lotman_ui.go b/lotman/lotman_ui.go index b5dad97b8..68de47ae6 100644 --- a/lotman/lotman_ui.go +++ b/lotman/lotman_ui.go @@ -343,7 +343,7 @@ func uiCreateLot(ctx *gin.Context) { extraInfo += "NOTE: New lot owner fields are ignored. The owner will be set to the issuer of the token used to create the lot. " } if len(lot.Parents) > 0 { - extraInfo += "NOTE: New lot parent fields are ignored. The parent will be determined by the namespace heirarchy associated with the lot's path. " + extraInfo += "NOTE: New lot parent fields are ignored. The parent will be determined by the namespace hierarchy associated with the lot's path. " } // TODO: Figure out the best way to inform the user that we ignore any owner or parent they set, because we handle that internally. @@ -478,7 +478,7 @@ func uiUpdateLot(ctx *gin.Context) { // because LotMan assumes a path can be held by only one lot (hierarchical ownership not withstanding). // 2: The new path is not tied to another lot. In this case, what we should really do is create a new lot for that namespace, assuming // one exists. But then why not create a new lot? - // Thus, until we've sorted out multi-path lots, we should probably just error out in both of these cases. An adminstrator at the cache + // Thus, until we've sorted out multi-path lots, we should probably just error out in both of these cases. An administrator at the cache // can get access to the system and update things however they choose anyway (albeit that means writing C to do it). if lotUpdate.Paths != nil { extraInfo += "NOTE: Lot update path fields are ignored. Pelican does not yet support this feature. " diff --git a/metrics/director.go b/metrics/director.go index 7be3927a8..bcfd309e4 100644 --- a/metrics/director.go +++ b/metrics/director.go @@ -38,7 +38,7 @@ const ( StatTimeout DirectorStatResult = "Timeout" StatCancelled DirectorStatResult = "Cancelled" StatForbidden DirectorStatResult = "Forbidden" - StatUnkownErr DirectorStatResult = "UnknownErr" + StatUnknownErr DirectorStatResult = "UnknownErr" ) var ( @@ -54,10 +54,10 @@ var ( PelicanDirectorFileTransferTestsRuns = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "pelican_director_total_ftx_test_runs", - Help: "The number of file transfer test runs the director issued. A test run is a cycle of upload/download/delete test file, which is executed per 15s per origin (by defult)", + Help: "The number of file transfer test runs the director issued. A test run is a cycle of upload/download/delete test file, which is executed per 15s per origin (by default)", }, []string{"server_name", "server_web_url", "server_type", "status", "report_status"}) - PelicanDirectorAdvertisementsRecievedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ + PelicanDirectorAdvertisementsReceivedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "pelican_director_advertisements_received_total", Help: "The total number of advertisement the director received from the origin and cache servers. Labelled by status_code, server_name, serve_type: Origin|Cache, server_web_url", }, []string{"server_name", "server_web_url", "server_type", "status_code", "namespace_prefix"}) diff --git a/metrics/xrootd_metrics.go b/metrics/xrootd_metrics.go index c256b0e0c..525eef6a9 100644 --- a/metrics/xrootd_metrics.go +++ b/metrics/xrootd_metrics.go @@ -506,7 +506,7 @@ func ParseXrdUserId(userid string) (xrdUserId XrdUserId, err error) { } pid, err := strconv.Atoi(protUserIdInfo[1][lastIdx+1 : len(protUserIdInfo[1])]) if err != nil { - err = errors.Wrap(err, "Unsable to parse PID as integer") + err = errors.Wrap(err, "Unable to parse PID as integer") return } @@ -731,7 +731,7 @@ func HandlePacket(packet []byte) error { if fileHdr.RecFlag&0x01 == 0x01 { // hasLFN lfnSize := uint32(fileHdr.RecSize - 20) lfn := NullTermToString(packet[offset+20 : offset+lfnSize+20]) - // path has been difined + // path has been defined path = computePrefix(lfn, monitorPaths) log.Debugf("MonPacket: User LFN %v matches prefix %v", lfn, path) @@ -1108,7 +1108,7 @@ func HandleSummaryPacket(packet []byte) error { correctedData := re.ReplaceAll(packet, []byte(``)) if err := xml.Unmarshal(correctedData, &summaryStats); err != nil { - return errors.Wrap(err, "error unmarshaling summary packet") + return errors.Wrap(err, "error unmarshalling summary packet") } log.Debug("Received a summary statistics packet") @@ -1125,7 +1125,7 @@ func HandleSummaryPacket(packet []byte) error { // stat.In: Bytes received // stat.Out: Bytes sent - // Note that stat.Total is the total connections since the start-up of the servcie + // Note that stat.Total is the total connections since the start-up of the service // So we just want to make sure here that no negative value is present incBy := float64(stat.Total - lastStats.Total) if stat.Total < lastStats.Total { diff --git a/metrics/xrootd_metrics_test.go b/metrics/xrootd_metrics_test.go index 8254d124d..99a37f8e7 100644 --- a/metrics/xrootd_metrics_test.go +++ b/metrics/xrootd_metrics_test.go @@ -105,7 +105,7 @@ func mockFileOpenPacket(pseq int, fileId, userId uint32, SID int64, path string) return bytePacket, nil } -func mockFileXfrPacket(pseq int, fileId uint32, SID int64, read, readv, wrtie int64) ([]byte, error) { +func mockFileXfrPacket(pseq int, fileId uint32, SID int64, read, readv, write int64) ([]byte, error) { // f-stream file transfer event mockMonHeader := XrdXrootdMonHeader{ // 8B Code: 'f', @@ -135,7 +135,7 @@ func mockFileXfrPacket(pseq int, fileId uint32, SID int64, read, readv, wrtie in Xfr: XrdXrootdMonStatXFR{ // 24B Read: read, Readv: readv, - Write: wrtie, + Write: write, }, } mockMonHeader.Plen = uint16(8 + mockMonFileTOD.Hdr.RecSize + mockMonFileXfr.Hdr.RecSize) @@ -358,7 +358,7 @@ func TestHandlePacket(t *testing.T) { expectedLinkConnectIncDup := strings.NewReader(mockPromLinkConnectInc) expectedLinkByteXferIncDup := strings.NewReader(mockPromLinkByteXferInc) - // First time received a summmary packet + // First time received a summary packet err = HandlePacket(mockLinkSummaryBaseBytes) require.NoError(t, err, "Error handling the packet") if err := testutil.CollectAndCompare(Connections, expectedLinkConnectBase, "xrootd_server_connection_count"); err != nil { @@ -368,7 +368,7 @@ func TestHandlePacket(t *testing.T) { require.NoError(t, err, "Collected metric is different from expected") } - // Second time received a summmary packet, with numbers more than first time + // Second time received a summary packet, with numbers more than first time // And metrics should be updated to the max number // Have one CMSD summary packets which should be ignored @@ -587,7 +587,7 @@ func TestHandlePacket(t *testing.T) { // it seems to return "/" all the time as the length of monitorPaths is // never changed assert.Equal(t, "/", transferEntry.Path, "Path in transfer cache entry doesn't match expected") - // TODO: Figure out why there's such discrepency here and the d-stream (where userid == sid), + // TODO: Figure out why there's such discrepancy here and the d-stream (where userid == sid), // but for other tests to run, just change to what returns to me for now assert.Equal(t, mockUserID, transferEntry.UserId.Id, "UserID in transfer cache entry doesn't match expected") transfers.DeleteAll() @@ -632,7 +632,7 @@ func TestHandlePacket(t *testing.T) { assert.Equal(t, mockReadV, int64(transferEntry.ReadvBytes)) assert.Equal(t, mockWrite, int64(transferEntry.WriteBytes)) assert.Equal(t, "/", transferEntry.Path, "Path in transfer cache entry doesn't match expected") - // TODO: Figure out why there's such discrepency here and the d-stream (where userid == sid), + // TODO: Figure out why there's such discrepancy here and the d-stream (where userid == sid), // but for other tests to run, just change to what returns to me for now assert.Equal(t, mockUserID, transferEntry.UserId.Id, "UserID in transfer cache entry doesn't match expected") transfers.DeleteAll() diff --git a/origin/globus.go b/origin/globus.go index 3f8bec48f..b1308e421 100644 --- a/origin/globus.go +++ b/origin/globus.go @@ -72,7 +72,7 @@ var ( ) // InitGlobusBackend does the following things to initialize Globus-related logic -// 1. It initializes the global map strcuture globusExports to store collection information in-memory +// 1. It initializes the global map structure globusExports to store collection information in-memory // 2. It checks and setup location for Globus access tokens after user activates the collection // 3. It loads the Globus OAuth client for OAuth-based authorization to access collection data // 4. It populates the global map by the exported Origin prefixes/collections. It reads the persisted credentials diff --git a/origin/globus_client.go b/origin/globus_client.go index f32b97432..f1f07010a 100644 --- a/origin/globus_client.go +++ b/origin/globus_client.go @@ -437,7 +437,7 @@ func handleGlobusCallback(ctx *gin.Context) { return } - // We have all the data in place, let's create/update related data strcutures: + // We have all the data in place, let's create/update related data structures: // 1. Pesist access token to disk for XRootD to read // 2. Update in-memory globusExports struct with the OAuth token (both access and refresh token), // HttpsServer, and display name (from Globus API) diff --git a/origin/origin_db_test.go b/origin/origin_db_test.go index 2e2a4d19f..eda64c907 100644 --- a/origin/origin_db_test.go +++ b/origin/origin_db_test.go @@ -65,7 +65,7 @@ func setupMockOriginDB(t *testing.T) { keyName := filepath.Join(tmp, "issuer.key") viper.Set(param.IssuerKey.GetName(), keyName) - // Also update the refresh token to be encrpted + // Also update the refresh token to be encrypted for idx := range mockGC { encrypted, err := config.EncryptString(mockGC[idx].RefreshToken) require.NoError(t, err) diff --git a/origin/reg_status.go b/origin/reg_status.go index d176d5ac4..5ba8f5737 100644 --- a/origin/reg_status.go +++ b/origin/reg_status.go @@ -65,7 +65,7 @@ var registrationsStatus = ttlcache.New( ttlcache.WithDisableTouchOnHit[string, RegistrationStatus](), ) -var RegistryNotImplErr = errors.New("the running version of the registry didn't implmenet this function") +var RegistryNotImplErr = errors.New("the running version of the registry didn't implement this function") const ( RegStatusNotSupported regStatusEnum = "Not Supported" // Registry does not support this function diff --git a/registry/registry.go b/registry/registry.go index 077ba917e..2482b26f1 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -392,7 +392,7 @@ func keySignChallengeCommit(ctx *gin.Context, data *registrationData) (bool, map } } -// Handle the namespace registration with nonce generation and verifcation, regardless of +// Handle the namespace registration with nonce generation and verification, regardless of // using OIDC Authorization or not func keySignChallenge(ctx *gin.Context, data *registrationData) (bool, map[string]interface{}, error) { if data.ClientNonce != "" && data.ClientPayload != "" && data.ClientSignature != "" && diff --git a/registry/registry_db_test.go b/registry/registry_db_test.go index 402887f0e..f65a86aae 100644 --- a/registry/registry_db_test.go +++ b/registry/registry_db_test.go @@ -276,7 +276,7 @@ func TestAddNamespace(t *testing.T) { require.NoError(t, err) require.Equal(t, 1, len(got)) assert.Equal(t, mockNs.Prefix, got[0].Prefix) - // We can do this because we pass the pointer of mockNs to addNamespce which + // We can do this because we pass the pointer of mockNs to addNamespace which // then modify the fields and insert into database assert.Equal(t, mockNs.AdminMetadata.CreatedAt.Unix(), got[0].AdminMetadata.CreatedAt.Unix()) assert.Equal(t, mockNs.AdminMetadata.UpdatedAt.Unix(), got[0].AdminMetadata.UpdatedAt.Unix()) @@ -297,7 +297,7 @@ func TestAddNamespace(t *testing.T) { assert.NotEqual(t, mockCreateAt.Unix(), mockNs.AdminMetadata.CreatedAt.Unix()) assert.NotEqual(t, mockUpdatedAt.Unix(), mockNs.AdminMetadata.UpdatedAt.Unix()) - // We can do this because we pass the pointer of mockNs to addNamespce which + // We can do this because we pass the pointer of mockNs to addNamespace which // then modify the fields and insert into database assert.Equal(t, mockNs.AdminMetadata.CreatedAt.Unix(), got[0].AdminMetadata.CreatedAt.Unix()) assert.Equal(t, mockNs.AdminMetadata.UpdatedAt.Unix(), got[0].AdminMetadata.UpdatedAt.Unix()) diff --git a/registry/registry_ui.go b/registry/registry_ui.go index 598314a41..513432799 100644 --- a/registry/registry_ui.go +++ b/registry/registry_ui.go @@ -95,7 +95,7 @@ func populateRegistrationFields(prefix string, data interface{}) []registrationF for i := 0; i < val.NumField(); i++ { field := typ.Field(i) - // Check for the "post" tag, it can be "exlude" or "required" + // Check for the "post" tag, it can be "exclude" or "required" if tag := field.Tag.Get("post"); tag == "exclude" { continue } @@ -509,7 +509,7 @@ func createUpdateNamespace(ctx *gin.Context, isUpdate bool) { return } - // Then check if the user has previlege to update + // Then check if the user has privilege to update belongsTo := false if !isAdmin { // Not admin, need to check if the namespace belongs to the user @@ -522,7 +522,7 @@ func createUpdateNamespace(ctx *gin.Context, isUpdate bool) { return } if !belongsTo { - // If the user doen's own the namespace, they can't edit it + // If the user doesn's own the namespace, they can't edit it // but if they have an access token generated by the private key // that corresponds to the public key of the namespace they are trying to access, // we allow them to do it so that admin can fill out the rest of the registration if the user_id is empty @@ -616,7 +616,7 @@ func createUpdateNamespace(ctx *gin.Context, isUpdate bool) { } } - // If the user has previlege to udpate, go ahead + // If the user has privilege to update, go ahead if err := updateNamespace(&ns); err != nil { log.Errorf("Failed to update namespace with id %d. %v", ns.ID, err) ctx.JSON(http.StatusInternalServerError, server_structs.SimpleApiResp{ @@ -672,7 +672,7 @@ func getNamespace(ctx *gin.Context) { return } if !belongsTo { - // If the user doen's own the namespace, they can't view it + // If the user doesn's own the namespace, they can't view it // but if they have an access token generated by the private key // that corresponds to the public key of the namespace they are trying to access, // we allow them to do it so that admin can fill out the rest of the registration if the user_id is empty diff --git a/registry/registry_ui_test.go b/registry/registry_ui_test.go index d680b9210..7b28167c2 100644 --- a/registry/registry_ui_test.go +++ b/registry/registry_ui_test.go @@ -1388,7 +1388,7 @@ func TestUpdateNamespaceHandler(t *testing.T) { }) } -func TestListInsitutions(t *testing.T) { +func TestListInstitutions(t *testing.T) { server_utils.ResetTestState() router := gin.Default() router.GET("/institutions", listInstitutions) diff --git a/registry/registry_validation.go b/registry/registry_validation.go index 5b07b22dc..6e1bdf10a 100644 --- a/registry/registry_validation.go +++ b/registry/registry_validation.go @@ -161,7 +161,7 @@ func validateJwks(jwksStr string) (jwk.Key, error) { // Let's check that we can convert to JSON and get the right thing... jsonbuf, err := json.Marshal(clientJwks) if err != nil { - return nil, errors.Wrap(err, "failed to marshal the reuqest pubKey's keyset into JSON") + return nil, errors.Wrap(err, "failed to marshal the request pubKey's keyset into JSON") } log.Debugln("Client JWKS as seen by the registry server:", string(jsonbuf)) } @@ -175,7 +175,7 @@ func validateJwks(jwksStr string) (jwk.Key, error) { */ key, exists := clientJwks.Key(0) if !exists { - return nil, errors.New("There was no key at index 0 in the reuqest pubKey's JWKS. Something is wrong") + return nil, errors.New("There was no key at index 0 in the request pubKey's JWKS. Something is wrong") } return key, nil } diff --git a/server_structs/director.go b/server_structs/director.go index 1d0c78a14..ece105bb9 100644 --- a/server_structs/director.go +++ b/server_structs/director.go @@ -327,7 +327,7 @@ func (ad *Advertisement) GetIOLoad() float64 { func ConvertNamespaceAdsV2ToV1(nsV2 []NamespaceAdV2) []NamespaceAdV1 { // Converts a list of V2 namespace ads to a list of V1 namespace ads. // This is for backwards compatibility in the case an old version of a client calls - // out to a newer verion of the director + // out to a newer version of the director nsV1 := []NamespaceAdV1{} for _, nsAd := range nsV2 { @@ -360,7 +360,7 @@ func ConvertNamespaceAdsV2ToV1(nsV2 []NamespaceAdV2) []NamespaceAdV1 { func ConvertNamespaceAdsV1ToV2(nsAdsV1 []NamespaceAdV1, oAd *OriginAdvertiseV1) []NamespaceAdV2 { //Convert a list of V1 namespace ads to a list of V2 namespace ads, note that this - //isn't the most efficient way of doing so (an interative search as opposed to some sort + //isn't the most efficient way of doing so (an interactive search as opposed to some sort //of index or hash based search) var wr bool diff --git a/server_structs/generic_server.go b/server_structs/generic_server.go index 8429532ea..c48a1b265 100644 --- a/server_structs/generic_server.go +++ b/server_structs/generic_server.go @@ -64,7 +64,7 @@ func NewServerType() ServerType { } // Get the string representation of a ServerType instance. This is intended -// for getting the string form of a single ServerType contant, such as CacheType +// for getting the string form of a single ServerType constant, such as CacheType // OriginType, etc. To get a string slice of enabled servers, use EnabledServerString() func (sType ServerType) String() string { switch sType { diff --git a/server_utils/origin.go b/server_utils/origin.go index 02963b1f1..095053804 100644 --- a/server_utils/origin.go +++ b/server_utils/origin.go @@ -42,7 +42,7 @@ import ( var originExports []OriginExport type ( - // TODO: pull stoage-specific fields into a separate struct and mixin + // TODO: pull storage-specific fields into a separate struct and mixin OriginExport struct { StoragePrefix string `json:"storagePrefix"` FederationPrefix string `json:"federationPrefix"` diff --git a/server_utils/server_utils.go b/server_utils/server_utils.go index 1e5606de3..8100ec8a0 100644 --- a/server_utils/server_utils.go +++ b/server_utils/server_utils.go @@ -16,12 +16,12 @@ * ***************************************************************/ -// Package server_utils shares utility functions used across multiple server pacakges (origin, cache, registry, director). +// Package server_utils shares utility functions used across multiple server packages (origin, cache, registry, director). // // It should only import lower level packages (config, param, etc), or server_structs package. -// It should never import any server pacakges (origin, cache, registry, director) or upeer level packages (launcher_utils, cmd, etc). +// It should never import any server packages (origin, cache, registry, director) or upper level packages (launcher_utils, cmd, etc). // -// For structs used across multiple server pacakges, put them in common package instead +// For structs used across multiple server packages, put them in common package instead package server_utils import ( diff --git a/server_utils/server_utils_test.go b/server_utils/server_utils_test.go index bc223e5e0..1bfbe25f7 100644 --- a/server_utils/server_utils_test.go +++ b/server_utils/server_utils_test.go @@ -86,7 +86,7 @@ func TestWaitUntilWorking(t *testing.T) { }) t.Run("server-returns-unexpected-status-code-json-body", func(t *testing.T) { - jsonRes := map[string]string{"error": "bad reqeust"} + jsonRes := map[string]string{"error": "bad request"} jsonBytes, err := json.Marshal(jsonRes) require.NoError(t, err) diff --git a/swagger/pelican-swagger.yaml b/swagger/pelican-swagger.yaml index 55dc1a258..ce072bf7e 100644 --- a/swagger/pelican-swagger.yaml +++ b/swagger/pelican-swagger.yaml @@ -14,7 +14,7 @@ info: The cookie is issued after a successful call to `/api/v1.0/auth/login`. However, OpenAPI 2.0 does not support specifying cookie-based security check. Therefore, as an alternative, we will add `Authentication Required` to the API description where needed. - For endpoint that is only accesible by users with admin privilege, we mark the endpoint as `Admin privilege Required`. + For endpoint that is only accessible by users with admin privilege, we mark the endpoint as `Admin privilege Required`. For how to set up Pelican servers, please refer to the documentation at [docs.pelicanplatform.org](https://docs.pelicanplatform.org/)" @@ -80,7 +80,7 @@ definitions: default: "" ErrorModel: type: object - description: The error reponse of a request + description: The error response of a request properties: error: type: string @@ -100,7 +100,7 @@ definitions: description: The response message SuccessModel: type: object - description: The successful reponse of a request + description: The successful response of a request properties: msg: type: string @@ -464,7 +464,7 @@ definitions: example: Origin latitude: type: number - description: The latitute of the server based on its IP address + description: The latitude of the server based on its IP address default: 0 longitude: type: number @@ -541,7 +541,7 @@ definitions: * "Not Supported": the Pelican registry is below v7.8.0 and does not support checking registration status. In this case, `edit_url` is empty. * "Completed": the registration is completed - * "Incomplete": the registration is not completed. `edit_url` will takes the user to the correspoding registration page + * "Incomplete": the registration is not completed. `edit_url` will takes the user to the corresponding registration page to finish the registration. `status_description` contains detail information of which field(s) are missing. * "Registration Error": there is an error registering the namespace. `edit_url` is empty and the user cannot edit the registration. example: Incomplete @@ -604,7 +604,7 @@ definitions: * "Not Supported": the Pelican registry is below v7.8.0 and does not support checking registration status. In this case, `edit_url` is empty. * "Completed": the registration is completed - * "Incomplete": the registration is not completed. `edit_url` will takes the user to the correspoding registration page + * "Incomplete": the registration is not completed. `edit_url` will takes the user to the corresponding registration page to finish the registration. `status_description` contains detail information of which field(s) are missing. * "Registration Error": there is an error registering the origin. `edit_url` is empty and the user cannot edit the registration. example: Incomplete @@ -650,7 +650,7 @@ definitions: type: string example: "Inactive" description: >- - The activation status of the Globus colleciton. + The activation status of the Globus collection. Can be either "Inactive" or "Activated". description: type: string @@ -761,7 +761,7 @@ paths: type: object $ref: "#/definitions/ErrorModelV2" "403": - description: Permission denied. Admin privilige required. + description: Permission denied. Admin privilege required. schema: type: object $ref: "#/definitions/ErrorModelV2" @@ -816,7 +816,7 @@ paths: type: object $ref: "#/definitions/ErrorModelV2" "403": - description: Permission denied. Admin privilige required. + description: Permission denied. Admin privilege required. schema: type: object $ref: "#/definitions/ErrorModelV2" @@ -1194,7 +1194,7 @@ paths: description: The approval status of the namespaces, can be `pending`, `approved`, `denied`, or `unknown`. - If `status == unknown`, internally it will match any registration with `status == ""` or `stauts == "unknown"` + If `status == unknown`, internally it will match any registration with `status == ""` or `status == "unknown"` For unauthenticated users, filter with `status != approved` will result in a 403 error. - name: legacy @@ -1301,7 +1301,7 @@ paths: description: The approval status of the namespaces, can be `pending`, `approved`, `denied`, or `unknown`. - If `status == unknown`, internally it will match any registration with `status == ""` or `stauts == "unknown"` + If `status == unknown`, internally it will match any registration with `status == ""` or `status == "unknown"` type: string produces: - application/json @@ -1484,7 +1484,7 @@ paths: tags: - "registry_ui" summary: Returns the public key of the namespace by id, in JWK Set format - description: It returns the JWK set as a downloadable attachement. Refer to https://datatracker.ietf.org/doc/html/rfc7517#section-5 for the format of JWK set + description: It returns the JWK set as a downloadable attachment. Refer to https://datatracker.ietf.org/doc/html/rfc7517#section-5 for the format of JWK set operationId: getNamespacePubkeyById parameters: - name: id @@ -1496,7 +1496,7 @@ paths: - application/json responses: "200": - description: OK, an attachement is returned to download + description: OK, an attachment is returned to download schema: type: object "400": @@ -2010,7 +2010,7 @@ paths: get: summary: Returns the data exports of the origin server description: >- - `Authentication Required` `Admin Previlege Required` + `Authentication Required` `Admin Privilege Required` tags: - "origin_ui" produces: @@ -2042,7 +2042,7 @@ paths: - "origin_ui" summary: Get a list of Globus exports description: >- - `Authentication Required` `Admin Previlege Required` + `Authentication Required` `Admin Privilege Required` responses: "200": description: OK @@ -2070,7 +2070,7 @@ paths: get: summary: Start the OAuth2 code flow for authenticating a Globus collection description: >- - `Authentication Required` `Admin Previlege Required` + `Authentication Required` `Admin Privilege Required` tags: - "origin_ui" parameters: @@ -2110,7 +2110,7 @@ paths: get: summary: The callback endpoint for Globus OAuth2 code flow description: >- - `Authentication Required` `Admin Previlege Required` + `Authentication Required` `Admin Privilege Required` tags: - "origin_ui" parameters: diff --git a/utils/utils.go b/utils/utils.go index 3915f47f4..e496c4f9c 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -115,7 +115,7 @@ func ExtractAndMaskIP(ipStr string) (maskedIP string, ok bool) { // ExtractVersionAndServiceFromUserAgent will extract the Pelican version and service from // the user agent. -// It will return empty strings if the provided userAgent failes to match against the parser +// It will return empty strings if the provided userAgent fails to match against the parser func ExtractVersionAndServiceFromUserAgent(userAgent string) (reqVer, service string) { uaRegExp := regexp.MustCompile(`^pelican-[^\/]+\/\d+\.\d+\.\d+`) if matches := uaRegExp.MatchString(userAgent); !matches { diff --git a/web_ui/README.md b/web_ui/README.md index 5e2fdb153..65ead0467 100644 --- a/web_ui/README.md +++ b/web_ui/README.md @@ -1,4 +1,4 @@ -A short README explaining our authorization permissions, specifically regarding tokens recieved from the URL or Header vs the login cookie. +A short README explaining our authorization permissions, specifically regarding tokens received from the URL or Header vs the login cookie. Tokens that are part of the HTTP Request Header e.g. `{"Authorization": "Bearer +"}` and that are set in the URL Query via `Authz` are considered valid if they are signed by either the Federation jwk or the Origin jwk. diff --git a/web_ui/frontend/app/director/page.tsx b/web_ui/frontend/app/director/page.tsx index a9665b1f5..d1dda2ca9 100644 --- a/web_ui/frontend/app/director/page.tsx +++ b/web_ui/frontend/app/director/page.tsx @@ -50,7 +50,7 @@ export default function Page() { async () => await alertOnError( getDirectorNamespaces, - 'Faild to fetch Namespaces', + 'Failed to fetch Namespaces', dispatch ) ); diff --git a/web_ui/frontend/components/graphs/LineGraph.tsx b/web_ui/frontend/components/graphs/LineGraph.tsx index 09457a385..e0a596ab9 100644 --- a/web_ui/frontend/components/graphs/LineGraph.tsx +++ b/web_ui/frontend/components/graphs/LineGraph.tsx @@ -98,7 +98,7 @@ async function getData( datasetOptions: | Partial> | Partial>[], - datasetTranform?: (x: ChartDataset<'line'>) => ChartDataset<'line'> + datasetTransform?: (x: ChartDataset<'line'>) => ChartDataset<'line'> ) { let chartData: ChartData<'line', any, any> = { datasets: await Promise.all( @@ -131,8 +131,8 @@ async function getData( ...datasetOption, }; - if (datasetTranform) { - return datasetTranform(dataset); + if (datasetTransform) { + return datasetTransform(dataset); } return dataset; diff --git a/web_ui/session.go b/web_ui/session.go index e863c4816..e5e79506d 100644 --- a/web_ui/session.go +++ b/web_ui/session.go @@ -47,7 +47,7 @@ func setupSession() { } // Setup and return the session handler for web UI APIs. -// Calling mutiple times will only set up the handler once +// Calling multiple times will only set up the handler once func GetSessionHandler() (gin.HandlerFunc, error) { sessionHandlerOnce.Do(setupSession) if sessionSetupErr != nil { diff --git a/web_ui/ui_test.go b/web_ui/ui_test.go index a57c8e1e2..a65b457ba 100644 --- a/web_ui/ui_test.go +++ b/web_ui/ui_test.go @@ -177,8 +177,8 @@ func TestHandleWebUIAuth(t *testing.T) { assert.Equal(t, http.StatusOK, r.Result().StatusCode) }) - t.Run("no-redirect-to-login-with-db-initialzied", func(t *testing.T) { - // We let the frontend to handle unauthorized user (if the password is initialzied) + t.Run("no-redirect-to-login-with-db-initialized", func(t *testing.T) { + // We let the frontend to handle unauthorized user (if the password is initialized) setupTestAuthDB(t) t.Cleanup(cleanupAuthDB) @@ -210,7 +210,7 @@ func TestHandleWebUIAuth(t *testing.T) { t.Run("403-for-logged-in-non-admin-user", func(t *testing.T) { server_utils.ResetTestState() - // We let the frontend to handle unauthorized user (if the password is initialzied) + // We let the frontend to handle unauthorized user (if the password is initialized) setupTestAuthDB(t) t.Cleanup(func() { cleanupAuthDB() diff --git a/xrootd/authorization_test.go b/xrootd/authorization_test.go index 940d4014a..a5cc39e42 100644 --- a/xrootd/authorization_test.go +++ b/xrootd/authorization_test.go @@ -205,7 +205,7 @@ func TestOSDFAuthCreation(t *testing.T) { hostname: "cache-test", }, { - desc: "osdf-cach-auth-merge", + desc: "osdf-cache-auth-merge", authIn: cacheAuthfileMultilineInput, authOut: cacheMergedAuthfileEntries, server: &cache.CacheServer{}, diff --git a/xrootd/xrootd_config.go b/xrootd/xrootd_config.go index 1116f1e33..4fc5b6436 100644 --- a/xrootd/xrootd_config.go +++ b/xrootd/xrootd_config.go @@ -848,7 +848,7 @@ func ConfigXrootd(ctx context.Context, isOrigin bool) (string, error) { case "pelican": urlParsed.Host += ":443" default: - log.Warningf("The Director URL (%s) does not contain an explicit port number; XRootD 5.6.3 and earlier are known to segfault in thie case", xrdConfig.Cache.PSSOrigin) + log.Warningf("The Director URL (%s) does not contain an explicit port number; XRootD 5.6.3 and earlier are known to segfault in this case", xrdConfig.Cache.PSSOrigin) } xrdConfig.Cache.PSSOrigin = urlParsed.String() } From 29b3de63852361fe92e58e538ca0e5bd1b58a273 Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Thu, 5 Dec 2024 16:07:09 -0600 Subject: [PATCH 2/6] Run the 'shellcheck' linter as a 'pre-commit' hook --- .pre-commit-config.yaml | 5 +++++ github_scripts/citests.sh | 3 ++- github_scripts/osx_install.sh | 8 +++++--- images/entrypoint.sh | 6 +++--- web_ui/frontend/dev/image/entrypoint.sh | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d3d160c4..d0471a310 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,3 +42,8 @@ repos: # Override the default arguments, which include writing back all # suggested changes. We don't want false positives to mangle files. args: [--force-exclude, --sort] +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + args: [--severity=warning] diff --git a/github_scripts/citests.sh b/github_scripts/citests.sh index 00a590182..6f72f2c5d 100755 --- a/github_scripts/citests.sh +++ b/github_scripts/citests.sh @@ -38,6 +38,7 @@ fi plugin_output=$(./stash_plugin osdf:///ospool/uc-shared/public/OSG-Staff/validation/test.txt query1) rm query1 +# shellcheck disable=SC2076 if ! [[ $plugin_output =~ "TransferUrl = \"osdf:///ospool/uc-shared/public/OSG-Staff/validation/test.txt\"" ]]; then echo "TransferUrl not in plugin output" to_exit=1 @@ -73,7 +74,7 @@ cleanup() { } trap cleanup EXIT -for idx in {1..20}; do +for _idx in {1..20}; do if [ -e "$SOCKET_DIR/socket" ]; then break fi diff --git a/github_scripts/osx_install.sh b/github_scripts/osx_install.sh index 423a29c76..2a8ca97aa 100755 --- a/github_scripts/osx_install.sh +++ b/github_scripts/osx_install.sh @@ -1,4 +1,4 @@ -#!/bin/sh -ex +#!/bin/bash # Copyright (C) 2024, Pelican Project, Morgridge Institute for Research # # Licensed under the Apache License, Version 2.0 (the "License"); you @@ -14,6 +14,8 @@ # limitations under the License. # +set -ex + # # This script installs all the xrootd-related dependencies into the # Mac OS X instance in GitHub. @@ -25,7 +27,7 @@ brew install minio ninja coreutils # The new macos-latest runner has some issues with /usr/local/. Adjust perms ahead of time sudo mkdir -p /usr/local/lib && sudo mkdir -p /usr/local/include -sudo chmod -R 777 /usr/local && sudo chown -R $(whoami):admin /usr/local +sudo chmod -R 777 /usr/local && sudo chown -R "$(whoami)":admin /usr/local mkdir dependencies pushd dependencies @@ -71,7 +73,7 @@ mkdir build cd build cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=$PWD/release_dir ninja install -xrootd_libdir=$(grealpath $(dirname $(grealpath `which xrootd`))/../lib/) +xrootd_libdir=$(grealpath "$(dirname "$(grealpath "$(which xrootd)")")"/../lib/) echo "Will install into: $xrootd_libdir" sudo mkdir -p $xrootd_libdir sudo ln -s $PWD/release_dir/lib/libXrdHTTPServer-5.so $xrootd_libdir diff --git a/images/entrypoint.sh b/images/entrypoint.sh index 984649330..128e8bece 100755 --- a/images/entrypoint.sh +++ b/images/entrypoint.sh @@ -45,7 +45,7 @@ if [ "$2" == "origin" ]; then shopt -s nullglob for fullfile in /opt/scitokens-server/etc/trusted-cas/*.pem; do - aliasname=$(basename "$file") + filename=$(basename "$fullfile") aliasname="${filename%.*}" keytool -cacerts -importcert -noprompt -storepass changeit -file "$fullfile" -alias "$aliasname" done @@ -56,7 +56,7 @@ if [ "$2" == "origin" ]; then # Tomcat requires us to provide the intermediate chain (which, in Kubernetes, is often in the same # file as the host certificate itself. If there wasn't one provided, try splitting it out. if [ ! -e /opt/tomcat/conf/chain.pem ]; then - pushd /tmp > /dev/null + pushd /tmp > /dev/null || { echo "pushd failed"; exit 1; } if csplit -f tls- -b "%02d.crt.pem" -s -z "/opt/tomcat/conf/hostcert.pem" '/-----BEGIN CERTIFICATE-----/' '{1}' 2>/dev/null ; then cp /tmp/tls-01.crt.pem /opt/tomcat/conf/chain.pem rm /tmp/tls-*.crt.pem @@ -64,7 +64,7 @@ if [ "$2" == "origin" ]; then # No intermediate CAs found. Create an empty file. touch /opt/tomcat/conf/chain.pem fi - popd > /dev/null + popd > /dev/null || { echo "popd failed"; exit 1; } fi fi diff --git a/web_ui/frontend/dev/image/entrypoint.sh b/web_ui/frontend/dev/image/entrypoint.sh index ddadb727b..97b25f4d4 100644 --- a/web_ui/frontend/dev/image/entrypoint.sh +++ b/web_ui/frontend/dev/image/entrypoint.sh @@ -13,5 +13,5 @@ echo "Starting cron" cron # Run the original Docker entrypoint script with any passed arguments -echo "Running original Docker entrypoint script with arguments: $@" +echo "Running original Docker entrypoint script with arguments: $*" /docker-entrypoint.sh "$@" From be214abd2c853c3fea60ed46ae43349c4e5ce53f Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Thu, 5 Dec 2024 21:29:42 -0600 Subject: [PATCH 3/6] Fix misspellings that weren't fully corrected by 'typos' --- github_scripts/x509_test.sh | 2 +- registry/registry_ui.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/github_scripts/x509_test.sh b/github_scripts/x509_test.sh index 4375cb117..f8cc471c1 100755 --- a/github_scripts/x509_test.sh +++ b/github_scripts/x509_test.sh @@ -15,7 +15,7 @@ # limitations under the License. # -# This test the functionally of the x509 defer check +# This test the functionality of the x509 defer check # Some prefixes allow for x509 authentication rather than using tokens, this tests # that a file that requires authorization is retrievable when using either x509 authentication or a token # and also tests that files that aren't allowed to use x509 authentication are not retrievable diff --git a/registry/registry_ui.go b/registry/registry_ui.go index 513432799..563b18a09 100644 --- a/registry/registry_ui.go +++ b/registry/registry_ui.go @@ -522,7 +522,7 @@ func createUpdateNamespace(ctx *gin.Context, isUpdate bool) { return } if !belongsTo { - // If the user doesn's own the namespace, they can't edit it + // If the user doesn't own the namespace, they can't edit it // but if they have an access token generated by the private key // that corresponds to the public key of the namespace they are trying to access, // we allow them to do it so that admin can fill out the rest of the registration if the user_id is empty @@ -672,7 +672,7 @@ func getNamespace(ctx *gin.Context) { return } if !belongsTo { - // If the user doesn's own the namespace, they can't view it + // If the user doesn't own the namespace, they can't view it // but if they have an access token generated by the private key // that corresponds to the public key of the namespace they are trying to access, // we allow them to do it so that admin can fill out the rest of the registration if the user_id is empty From e0ab1b85de2497ba69fd12a417937af1b8923be3 Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Thu, 5 Dec 2024 21:38:03 -0600 Subject: [PATCH 4/6] Fix 'gofmt' issue(?) --- metrics/director.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/metrics/director.go b/metrics/director.go index bcfd309e4..6a84f113f 100644 --- a/metrics/director.go +++ b/metrics/director.go @@ -33,11 +33,11 @@ const ( MetricSucceeded MetricSimpleStatus = "Succeeded" MetricFailed MetricSimpleStatus = "Failed" - StatSucceeded DirectorStatResult = "Succeeded" - StatNotFound DirectorStatResult = "NotFound" - StatTimeout DirectorStatResult = "Timeout" - StatCancelled DirectorStatResult = "Cancelled" - StatForbidden DirectorStatResult = "Forbidden" + StatSucceeded DirectorStatResult = "Succeeded" + StatNotFound DirectorStatResult = "NotFound" + StatTimeout DirectorStatResult = "Timeout" + StatCancelled DirectorStatResult = "Cancelled" + StatForbidden DirectorStatResult = "Forbidden" StatUnknownErr DirectorStatResult = "UnknownErr" ) From a03ab5b7f4eb691b2cff8b435a112c132e9d5ce7 Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Fri, 6 Dec 2024 11:04:33 -0600 Subject: [PATCH 5/6] Update the 'typos' ignore config for 'dne' --- _typos.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_typos.toml b/_typos.toml index e86c36807..e40174067 100644 --- a/_typos.toml +++ b/_typos.toml @@ -5,6 +5,8 @@ extend-ignore-identifiers-re = [ ## Ignore TLAs. Two and three letter acronyms are not worth fixing. "^[A-Za-z]{2,3}$", + ## Ignore the 'dne' identifiers in server_utils/origin_test.go. + "(.*)_dne$", ] [default.extend-identifiers] @@ -12,8 +14,6 @@ extend-ignore-identifiers-re = [ NewCFBEncrypter = "NewCFBEncrypter" ## HTCondor's daemon names follow the usual "{word} + 'd'" convention. StartdAttrs = "StartdAttrs" -## Other one-off identifiers that do not need fixing. -sentinel_dne = "sentinel_dne" # server_utils/origin_test.go [files] extend-exclude = [ From 5672ebd6a35fcfc52e3498c4bacee26d13f5a306 Mon Sep 17 00:00:00 2001 From: Brian Aydemir Date: Thu, 26 Dec 2024 10:34:24 -0600 Subject: [PATCH 6/6] Re-run 'typos' after rebasing for v7.12-related commits --- .github/workflows/enforce-PR-labelling.yml | 2 +- .goreleaser.yml | 2 +- _typos.toml | 7 +++++-- config/config.go | 2 +- docs/parameters.yaml | 2 +- images/entrypoint.sh | 8 ++++---- launchers/cache_serve.go | 2 +- lotman/lotman_linux.go | 4 ++-- lotman/lotman_ui.go | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/enforce-PR-labelling.yml b/.github/workflows/enforce-PR-labelling.yml index e9d7f9ae7..97cdb80be 100644 --- a/.github/workflows/enforce-PR-labelling.yml +++ b/.github/workflows/enforce-PR-labelling.yml @@ -30,7 +30,7 @@ jobs: REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH) TIMELINE_JSON=$(curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/timeline") - # Count the number of times the timeline sees a "connected" event and subract the number of "disconnected" events + # Count the number of times the timeline sees a "connected" event and subtract the number of "disconnected" events # We might also consider using the "cross-referenced" event in the future if actual connecting/disconnecting is too heavy-handed LINKED_ISSUES=$(echo "$TIMELINE_JSON" | jq ' reduce .[] as $event ( diff --git a/.goreleaser.yml b/.goreleaser.yml index 60ecdad01..3c72baa7f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -51,7 +51,7 @@ builds: - goos: darwin goarch: ppc64le # Set things up to build a second server binary that enables Lotman. Eventually - # we'll also use this to filter which moduels are built into the binary. + # we'll also use this to filter which modules are built into the binary. - env: - CGO_ENABLED=0 goos: diff --git a/_typos.toml b/_typos.toml index e40174067..84434e8bb 100644 --- a/_typos.toml +++ b/_typos.toml @@ -5,8 +5,11 @@ extend-ignore-identifiers-re = [ ## Ignore TLAs. Two and three letter acronyms are not worth fixing. "^[A-Za-z]{2,3}$", - ## Ignore the 'dne' identifiers in server_utils/origin_test.go. - "(.*)_dne$", + ## Ignore lotman's use of 'ded' for 'dedicated'. + "^ded[A-Z]", + "^[a-z]+Ded", + ## Ignore server_utils's use of 'dne' for 'does not exist'. + "_dne$", ] [default.extend-identifiers] diff --git a/config/config.go b/config/config.go index 7afbb0b6c..b44aa1910 100644 --- a/config/config.go +++ b/config/config.go @@ -797,7 +797,7 @@ func InitConfigDir(v *viper.Viper) { configDir := v.GetString("ConfigDir") if configDir == "" { if IsRootExecution() { - configDir = "/etc/pelican" // We currently don't handle this case in windows, will be revisted in the future + configDir = "/etc/pelican" // We currently don't handle this case in windows, will be revisited in the future } else { configDir = getConfigBase() } diff --git a/docs/parameters.yaml b/docs/parameters.yaml index ccbb1633f..7e3bbba75 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2773,7 +2773,7 @@ description: |+ - `CreationTime`: REQUIRED. A unix timestamp indicating when the lot should begin being considered valid. Times in the future indicate the lot should not be considered valid until that time. - `ExpirationTime`: REQUIRED. A unix timestamp indicating when the lot expires. Lots may continue to function after expiration, but lot - data owners should recognize the storage is at-will and may be pre-empted at any time. + data owners should recognize the storage is at-will and may be preempted at any time. - `DeletionTime`: REQUIRED. A unix timestamp indicating when the lot and its associated data should be deleted. For example, Lotman could be configured with the "my-policy" policy with the following: diff --git a/images/entrypoint.sh b/images/entrypoint.sh index 128e8bece..7251ddf62 100755 --- a/images/entrypoint.sh +++ b/images/entrypoint.sh @@ -84,7 +84,7 @@ if [ $# -ne 0 ]; then case "$program_selector" in pelican) # Run pelican with the rest of the arguments - echo "Running pelican with arguments: $@" + echo "Running pelican with arguments: $*" exec tini -- /usr/local/bin/pelican "$@" # we shouldn't get here echo >&2 "Exec of tini failed!" @@ -93,7 +93,7 @@ if [ $# -ne 0 ]; then pelican-server) # Our server-specific binary which may come with additional # features/system requirements (like Lotman) - echo "Running pelican-server with arguments: $@" + echo "Running pelican-server with arguments: $*" exec tini -- /usr/local/sbin/pelican-server "$@" # we shouldn't get here echo >&2 "Exec of tini failed!" @@ -101,14 +101,14 @@ if [ $# -ne 0 ]; then ;; osdf) # Run osdf with the rest of the arguments - echo "Running osdf with arguments: $@" + echo "Running osdf with arguments: $*" exec tini -- /usr/local/bin/osdf "$@" # we shouldn't get here echo >&2 "Exec of tini failed!" exit 1 ;; osdf-server) - echo "Running osdf-server with arguments: $@" + echo "Running osdf-server with arguments: $*" exec tini -- /usr/local/sbin/osdf-server "$@" # we shouldn't get here echo >&2 "Exec of tini failed!" diff --git a/launchers/cache_serve.go b/launchers/cache_serve.go index 3c78d2d77..ec88f880d 100644 --- a/launchers/cache_serve.go +++ b/launchers/cache_serve.go @@ -78,7 +78,7 @@ func CacheServe(ctx context.Context, engine *gin.Engine, egrp *errgroup.Group, m // Until https://github.com/PelicanPlatform/lotman/issues/24 is closed, we can only really logic over // top-level prefixes because enumerating all object "directories" under a given federation prefix is // infeasible, but is currently the only way to nest namespaces in Lotman such that a sub namespace - // can be assosciated with a top-level prefix. + // can be associated with a top-level prefix. // To that end, we need to filter out any nested namespaces from the cache server's namespace ads. uniqueTopPrefixes := server_utils.FilterTopLevelPrefixes(cacheServer.GetNamespaceAds()) diff --git a/lotman/lotman_linux.go b/lotman/lotman_linux.go index 3fc071348..19fa5f0e8 100644 --- a/lotman/lotman_linux.go +++ b/lotman/lotman_linux.go @@ -464,7 +464,7 @@ func getPolicyMap() (map[string]PurgePolicy, error) { var policies []PurgePolicy // Use custom decoder hook to validate fields. This validates all the way down to the bottom of the lot object. if err := viper.UnmarshalKey(param.Lotman_PolicyDefinitions.GetName(), &policies, viper.DecodeHook(validateFieldsHook())); err != nil { - return policyMap, errors.Wrap(err, "error unmarshaling Lotman policy definitions") + return policyMap, errors.Wrap(err, "error unmarshalling Lotman policy definitions") } for _, policy := range policies { @@ -655,7 +655,7 @@ func divideRemainingSpace(lotMap *map[string]Lot, totalDiskSpaceB uint64) error if lot.MPA != nil && lot.MPA.DedicatedGB != nil { dedicatedGBBytes := gigabytesToBytes(*lot.MPA.DedicatedGB) // While we check that lot config is valid later, we can't finish dividing space if - // remainintToHwmB dips negative. Can't check for < 0 after subraction because the uint64 will wrap + // remainintToHwmB dips negative. Can't check for < 0 after subtraction because the uint64 will wrap if remainingToHwmB < dedicatedGBBytes { return errors.New(fmt.Sprintf("the sum of all lots' dedicatedGB values exceeds the high watermark of %s. This would allow the cache to purge namespaces using less than their dedicated quota", hwmStr)) } diff --git a/lotman/lotman_ui.go b/lotman/lotman_ui.go index 68de47ae6..257cb2fa7 100644 --- a/lotman/lotman_ui.go +++ b/lotman/lotman_ui.go @@ -201,7 +201,7 @@ func VerifyNewLotToken(lot *Lot, strToken string) (bool, error) { // and cut out a lot of this cruft // Get the namespace by querying the director and checking the headers - errMsgPrefix := "the provided token is acceptible, but no owner could be determined because " + errMsgPrefix := "the provided token is acceptable, but no owner could be determined because " fedInfo, err := config.GetFederation(context.Background()) if err != nil {