Skip to content

Commit

Permalink
Configure pss.origin to use pelican:// protocol
Browse files Browse the repository at this point in the history
Switch to the new `pelican://` protocol scheme to enable new
metadata discovery functionality.
  • Loading branch information
bbockelm committed Jan 29, 2024
1 parent fc28b68 commit 69b10fc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xrootd/resources/xrootd-cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pfc.prefetch 20
pfc.writequeue 16 4
pfc.ram 4g
pfc.diskusage 0.90 0.95 purgeinterval 300s
pss.origin {{.Cache.DirectorUrl}}
pss.origin {{.Cache.PSSOrigin}}
# FIXME: the oss.space meta / data only works if the meta and data directories are different physical devices.
# Otherwise, no data space is setup and the cache simply doesn't write out data.
oss.localroot {{.Cache.DataLocation}}
Expand Down
57 changes: 50 additions & 7 deletions xrootd/xrootd_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -61,6 +62,20 @@ var (
errBadKeyPair error = errors.New("Bad X509 keypair")
)

const (
clientPluginDefault = `
url = pelican://*
lib = libXrdClPelican.so
enable = true
`

clientPluginMac = `
url = pelican://*
lib = libXrdClPelican.dylib
enable = true
`
)

type (
OriginConfig struct {
Multiuser bool
Expand All @@ -84,7 +99,7 @@ type (
EnableVoms bool
ExportLocation string
DataLocation string
DirectorUrl string
PSSOrigin string
}

XrootdOptions struct {
Expand Down Expand Up @@ -275,7 +290,18 @@ func CheckCacheXrootdEnv(exportPath string, uid int, gid int, nsAds []director.N
if err != nil {
return "", errors.Wrap(err, "Failed to pull information from the federation")
}
viper.Set("Cache.DirectorUrl", param.Federation_DirectorUrl.GetString())
viper.Set("Cache.PSSOrigin", param.Federation_DirectorUrl.GetString())
if discoveryUrlStr := param.Federation_DiscoveryUrl.GetString(); discoveryUrlStr != "" {
discoveryUrl, err := url.Parse(discoveryUrlStr)
if err == nil {
discoveryUrl.Scheme = "pelican"
discoveryUrl.Path = ""
discoveryUrl.RawQuery = ""
viper.Set("Cache.PSSOrigin", discoveryUrl.String())
} else {
return "", errors.Wrapf(err, "Failed to parse discovery URL %s", discoveryUrlStr)
}
}

if err := WriteCacheScitokensConfig(nsAds); err != nil {
return "", errors.Wrap(err, "Failed to create scitokens configuration for the cache")
Expand Down Expand Up @@ -330,6 +356,21 @@ func CheckXrootdEnv(server server_utils.XRootDServer) error {
return errors.Wrap(err, "Unable to set $XDG_CACHE_HOME for scitokens library")
}

if server.GetServerType().IsEnabled(config.CacheType) {
clientPluginsDir := filepath.Join(runtimeDir, "cache-client.plugins.d")
if err = os.MkdirAll(clientPluginsDir, os.FileMode(0755)); err != nil {
return errors.Wrap(err, "Unable to create cache client plugins directory")
}
if runtime.GOOS == "darwin" {
err = os.WriteFile(filepath.Join(clientPluginsDir, "pelican-plugin.conf"), []byte(clientPluginDefault), os.FileMode(0644))
} else {
err = os.WriteFile(filepath.Join(clientPluginsDir, "pelican-plugin.conf"), []byte(clientPluginMac), os.FileMode(0644))
}
if err != nil {
return errors.Wrap(err, "Unable to configure cache client plugin")
}
}

exportPath := filepath.Join(runtimeDir, "export")
if _, err := os.Stat(exportPath); err == nil {
if err = os.RemoveAll(exportPath); err != nil {
Expand Down Expand Up @@ -533,23 +574,25 @@ func ConfigXrootd(ctx context.Context, origin bool) (string, error) {
return "", errors.New("Origin.Multiuser is set to `true` but the command was run without sufficient privilege; was it launched as root?")
}
}
} else if xrdConfig.Cache.DirectorUrl != "" {
} else if xrdConfig.Cache.PSSOrigin != "" {
// Workaround for a bug in XRootD 5.6.3: if the director URL is missing a port number, then
// XRootD crashes.
urlParsed, err := url.Parse(xrdConfig.Cache.DirectorUrl)
urlParsed, err := url.Parse(xrdConfig.Cache.PSSOrigin)
if err != nil {
return "", errors.Errorf("Director URL (%s) does not parse as a URL", xrdConfig.Cache.DirectorUrl)
return "", errors.Errorf("Director URL (%s) does not parse as a URL", xrdConfig.Cache.PSSOrigin)
}
if !strings.Contains(urlParsed.Host, ":") {
switch urlParsed.Scheme {
case "http":
urlParsed.Host += ":80"
case "https":
urlParsed.Host += ":443"
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.DirectorUrl)
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)
}
xrdConfig.Cache.DirectorUrl = urlParsed.String()
xrdConfig.Cache.PSSOrigin = urlParsed.String()
}
}

Expand Down

0 comments on commit 69b10fc

Please sign in to comment.