@@ -44,7 +44,7 @@ type Options struct {
4444 OriginPrefix string `long:"origin-prefix" short:"o" description:"Prefix corresponding to the local origin"`
4545
4646 // Shadow origin prefix; e.g., osdf://ospool/osgconnect-shadow/
47- ShadowOriginPrefix string `long:"shadow-prefix" short:"s" description:"Prefix corresponding to the shadow origin"`
47+ ShadowOriginPrefix string `long:"shadow-prefix" short:"s" description:"Prefix corresponding to the shadow origin" required:"true" `
4848
4949 // Sources to ingest
5050 Sources []string `positional-arg-name:"sources" short:"i" long:"input" description:"Source file(s)" default:"-"`
@@ -59,6 +59,22 @@ func main() {
5959 // Capture the start time of the transfer
6060 if _ , err := parser .Parse (); err != nil {
6161 if flagsErr , ok := err .(* flags.Error ); ok && flagsErr .Type == flags .ErrHelp {
62+ fmt .Fprintln (os .Stderr , `
63+ This utility parses a job ClassAd and, for each "osdf://" URL found in
64+ the input files that is in a locally-mounted origin, copies the file
65+ over to a "shadow origin". The files in the shadow origin are given a
66+ unique based on their last modification time; this means that local
67+ files can be modified without causing cache consistency issues.
68+
69+ Terminology:
70+ - Origin prefix: Where in the OSDF namespace the origin exports its
71+ files. Example: osdf://osg-connect/protected
72+ - Mount prefix: The location in the locally-mounted filesystem that
73+ correspondings to the files in the origin prefix. Example:
74+ /mnt/cephfs/protected
75+ - Shadow prefix: Where in the OSDF namespace the resulting files should
76+ be uploaded. Example: osdf://osg-connect-shadow/protected
77+ ` );
6278 os .Exit (0 )
6379 } else {
6480 log .Errorln (err )
@@ -89,7 +105,8 @@ func main() {
89105 log .Errorln ("Origin prefix scheme must be osdf://:" , originPrefixUri .Scheme )
90106 os .Exit (1 )
91107 }
92- originPrefixPath := path .Clean ("/" + originPrefixUri .Path )
108+ originPrefixPath := path .Clean ("/" + originPrefixUri .Host + "/" + originPrefixUri .Path )
109+ log .Debugln ("Local origin prefix:" , originPrefixPath )
93110
94111 if options .Version {
95112 fmt .Println ("Version:" , version )
@@ -126,7 +143,7 @@ func main() {
126143 os .Exit (1 )
127144 }
128145 inputList , err := classad .Get ("TransferInput" )
129- if err != nil {
146+ if err != nil || inputList == nil {
130147 // No TransferInput, no need to transform...
131148 os .Exit (0 )
132149 }
@@ -137,14 +154,15 @@ func main() {
137154 }
138155 re := regexp .MustCompile ("[,\\ s]+" )
139156 for _ , source := range re .Split (inputListStr , - 1 ) {
157+ log .Debugln ("Examining transfer input file" , source )
140158 if (strings .HasPrefix (source , options .MountPrefix )) {
141159 sources = append (sources , source )
142160 } else {
143161 // Replace the osdf:// prefix with the local mount path
144162 source_uri , err := url .Parse (source )
145163 source_uri_scheme := strings .SplitN (source_uri .Scheme , "+" , 2 )[0 ]
146- if err ! = nil && source_uri_scheme == "osdf" {
147- source_path := path .Clean ("/" + source_uri .Path )
164+ if err = = nil && source_uri_scheme == "osdf" {
165+ source_path := path .Clean ("/" + source_uri .Host + "/" + source_uri . Path )
148166 if (strings .HasPrefix (source_path , originPrefixPath )) {
149167 sources = append (sources , options .MountPrefix + source_path [len (originPrefixPath ):])
150168 continue
@@ -169,7 +187,14 @@ func main() {
169187 for _ , src := range sources {
170188 _ , newSource , result := stashcp .DoShadowIngest (src , options .MountPrefix , options .ShadowOriginPrefix )
171189 if result != nil {
172- break
190+ // What's the correct behavior on failure? For now, we silently put the transfer
191+ // back on the original list. This is arguably the wrong approach as it might
192+ // give the user surprising semantics -- but keeping this until we have a bit more
193+ // confidence in the approach.
194+ extraSources = append (extraSources , src )
195+ log .Errorf ("Failed to ingest %s: %s. Adding original back to the transfer list" ,
196+ src , result .Error ())
197+ continue
173198 }
174199 xformSources = append (xformSources , newSource )
175200 }
0 commit comments