From 3be616de3f488f01104008190d1669bef7db004d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 18 Dec 2018 10:05:26 -0800 Subject: [PATCH] Send deployment ID in notification event response elements (#6991) --- cmd/generic-handlers.go | 4 +++- cmd/notification.go | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index 626a129ee..f58d28ba2 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -743,7 +743,9 @@ func (s customHeaderHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Set custom headers such as x-amz-request-id and x-minio-deployment-id // for each request. w.Header().Set(responseRequestIDKey, mustGetRequestID(UTCNow())) - w.Header().Set(responseDeploymentIDKey, globalDeploymentID) + if globalDeploymentID != "" { + w.Header().Set(responseDeploymentIDKey, globalDeploymentID) + } s.handler.ServeHTTP(logger.NewResponseWriter(w), r) } diff --git a/cmd/notification.go b/cmd/notification.go index 4027f3a2a..a04106642 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -22,6 +22,7 @@ import ( "encoding/json" "encoding/xml" "fmt" + "net" "net/url" "path" "strings" @@ -488,10 +489,10 @@ func (args eventArgs) ToEvent() event.Event { host := globalMinioHost if host == "" { // FIXME: Send FQDN or hostname of this machine than sending IP address. - host = localIP4.ToSlice()[0] + host = sortIPs(localIP4.ToSlice())[0] } - return fmt.Sprintf("%s://%s:%s", getURLScheme(globalIsSSL), host, globalMinioPort) + return fmt.Sprintf("%s://%s", getURLScheme(globalIsSSL), net.JoinHostPort(host, globalMinioPort)) } eventTime := UTCNow() @@ -501,6 +502,10 @@ func (args eventArgs) ToEvent() event.Event { "x-amz-request-id": args.RespElements["requestId"], "x-minio-origin-endpoint": getOriginEndpoint(), // Minio specific custom elements. } + // Add deployment as part of + if globalDeploymentID != "" { + respElements["x-minio-deployment-id"] = globalDeploymentID + } if args.RespElements["content-length"] != "" { respElements["content-length"] = args.RespElements["content-length"] }