@ -701,6 +701,7 @@ func getCpObjMetadataFromHeader(ctx context.Context, r *http.Request, userMeta m
// getRemoteInstanceTransport contains a singleton roundtripper.
// getRemoteInstanceTransport contains a singleton roundtripper.
var getRemoteInstanceTransport http . RoundTripper
var getRemoteInstanceTransport http . RoundTripper
var getRemoteInstanceTransportLongTO http . RoundTripper
var getRemoteInstanceTransportOnce sync . Once
var getRemoteInstanceTransportOnce sync . Once
// Returns a minio-go Client configured to access remote host described by destDNSRecord
// Returns a minio-go Client configured to access remote host described by destDNSRecord
@ -715,11 +716,31 @@ var getRemoteInstanceClient = func(r *http.Request, host string) (*miniogo.Core,
}
}
getRemoteInstanceTransportOnce . Do ( func ( ) {
getRemoteInstanceTransportOnce . Do ( func ( ) {
getRemoteInstanceTransport = NewGatewayHTTPTransport ( )
getRemoteInstanceTransport = NewGatewayHTTPTransport ( )
getRemoteInstanceTransportLongTO = newGatewayHTTPTransport ( time . Hour )
} )
} )
core . SetCustomTransport ( getRemoteInstanceTransport )
core . SetCustomTransport ( getRemoteInstanceTransport )
return core , nil
return core , nil
}
}
// Returns a minio-go Client configured to access remote host described by destDNSRecord
// Applicable only in a federated deployment.
// The transport does not contain any timeout except for dialing.
func getRemoteInstanceClientLongTimeout ( r * http . Request , host string ) ( * miniogo . Core , error ) {
cred := getReqAccessCred ( r , globalServerRegion )
// In a federated deployment, all the instances share config files
// and hence expected to have same credentials.
core , err := miniogo . NewCore ( host , cred . AccessKey , cred . SecretKey , globalIsSSL )
if err != nil {
return nil , err
}
getRemoteInstanceTransportOnce . Do ( func ( ) {
getRemoteInstanceTransport = NewGatewayHTTPTransport ( )
getRemoteInstanceTransportLongTO = newGatewayHTTPTransport ( time . Hour )
} )
core . SetCustomTransport ( getRemoteInstanceTransportLongTO )
return core , nil
}
// Check if the destination bucket is on a remote site, this code only gets executed
// Check if the destination bucket is on a remote site, this code only gets executed
// when federation is enabled, ie when globalDNSConfig is non 'nil'.
// when federation is enabled, ie when globalDNSConfig is non 'nil'.
//
//
@ -1166,7 +1187,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
}
}
// Send PutObject request to appropriate instance (in federated deployment)
// Send PutObject request to appropriate instance (in federated deployment)
client , rerr := getRemoteInstanceClient ( r , getHostFromSrv ( dstRecords ) )
client , rerr := getRemoteInstanceClientLongTimeout ( r , getHostFromSrv ( dstRecords ) )
if rerr != nil {
if rerr != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
return
return
@ -1181,7 +1202,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
ServerSideEncryption : dstOpts . ServerSideEncryption ,
ServerSideEncryption : dstOpts . ServerSideEncryption ,
UserTags : tag . ToMap ( ) ,
UserTags : tag . ToMap ( ) ,
}
}
remoteObjInfo , rerr := client . PutObject ( dstBucket , dstObject , srcInfo . Reader ,
remoteObjInfo , rerr := client . PutObjectWithContext ( ctx , dstBucket , dstObject , srcInfo . Reader ,
srcInfo . Size , "" , "" , opts )
srcInfo . Size , "" , "" , opts )
if rerr != nil {
if rerr != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
@ -1858,13 +1879,13 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt
}
}
// Send PutObject request to appropriate instance (in federated deployment)
// Send PutObject request to appropriate instance (in federated deployment)
client , rerr := getRemoteInstanceClient ( r , getHostFromSrv ( dstRecords ) )
client , rerr := getRemoteInstanceClientLongTimeout ( r , getHostFromSrv ( dstRecords ) )
if rerr != nil {
if rerr != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , rerr ) , r . URL , guessIsBrowserReq ( r ) )
return
return
}
}
partInfo , err := client . PutObjectPart ( dstBucket , dstObject , uploadID , partID ,
partInfo , err := client . PutObjectPartWithContext ( ctx , dstBucket , dstObject , uploadID , partID ,
srcInfo . Reader , srcInfo . Size , "" , "" , dstOpts . ServerSideEncryption )
srcInfo . Reader , srcInfo . Size , "" , "" , dstOpts . ServerSideEncryption )
if err != nil {
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )