Add NTP retention time (#8548)

This commit is contained in:
Harshavardhana
2019-11-21 04:52:35 -08:00
committed by Nitish Tiwari
parent 4e9de58675
commit fd0fa4e5c5
4 changed files with 79 additions and 10 deletions

View File

@@ -35,6 +35,7 @@ import (
"strings"
"time"
"github.com/beevik/ntp"
xhttp "github.com/minio/minio/cmd/http"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/handlers"
@@ -314,6 +315,17 @@ func UTCNow() time.Time {
return time.Now().UTC()
}
// UTCNowNTP - is similar in functionality to UTCNow()
// but only used when we do not wish to rely on system
// time.
func UTCNowNTP() (time.Time, error) {
// ntp server is disabled
if ntpServer == "" {
return UTCNow(), nil
}
return ntp.Time(ntpServer)
}
// GenETag - generate UUID based ETag
func GenETag() string {
return ToS3ETag(getMD5Hash([]byte(mustGetUUID())))