mirror of
https://github.com/minio/minio.git
synced 2024-12-27 15:45:55 -05:00
Use UTC() everywhere
ref - https://github.com/golang/go/issues/1988, no standard function to set timeZone
This commit is contained in:
parent
b6d96335e7
commit
8e3d48bf35
@ -162,7 +162,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "key",
|
Key: "key",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
||||||
Size: 0,
|
Size: 0,
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ func (s *MySuite) TestBucket(c *C) {
|
|||||||
typedDriver := s.MockDriver
|
typedDriver := s.MockDriver
|
||||||
metadata := drivers.BucketMetadata{
|
metadata := drivers.BucketMetadata{
|
||||||
Name: "bucket",
|
Name: "bucket",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
|
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
|
||||||
@ -244,7 +244,7 @@ func (s *MySuite) TestObject(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "key",
|
Key: "key",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3",
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3",
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "object1",
|
Key: "object1",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
||||||
Size: 9,
|
Size: 9,
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "object2",
|
Key: "object2",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
||||||
Size: 9,
|
Size: 9,
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "object3",
|
Key: "object3",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ func (s *MySuite) TestHeader(c *C) {
|
|||||||
|
|
||||||
bucketMetadata := drivers.BucketMetadata{
|
bucketMetadata := drivers.BucketMetadata{
|
||||||
Name: "bucket",
|
Name: "bucket",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once()
|
typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once()
|
||||||
@ -498,7 +498,7 @@ func (s *MySuite) TestHeader(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "object",
|
Key: "object",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3", // TODO correct md5
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
@ -593,8 +593,8 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
c.Assert(err, Not(IsNil))
|
c.Assert(err, Not(IsNil))
|
||||||
|
|
||||||
// breaks on fs driver,// breaks on fs driver, so we subtract one second
|
// breaks on fs driver,// breaks on fs driver, so we subtract one second
|
||||||
// date1 := time.Now()
|
// date1 := time.Now().UTC()
|
||||||
date1 := time.Now().Add(-time.Second)
|
date1 := time.Now().UTC().Add(-time.Second)
|
||||||
|
|
||||||
// Put Bucket before - Put Object into a bucket
|
// Put Bucket before - Put Object into a bucket
|
||||||
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
|
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
|
||||||
@ -612,7 +612,7 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "two",
|
Key: "two",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3",
|
Md5: "5eb63bbbe01eeed093cb22bb8f5acdc3",
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
@ -626,7 +626,7 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
date2 := time.Now()
|
date2 := time.Now().UTC()
|
||||||
|
|
||||||
resources.Maxkeys = 1000
|
resources.Maxkeys = 1000
|
||||||
resources.Prefix = ""
|
resources.Prefix = ""
|
||||||
@ -687,7 +687,7 @@ func (s *MySuite) TestListBuckets(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
bucketMetadata := []drivers.BucketMetadata{
|
bucketMetadata := []drivers.BucketMetadata{
|
||||||
{Name: "foo", Created: time.Now()},
|
{Name: "foo", Created: time.Now().UTC()},
|
||||||
}
|
}
|
||||||
typedDriver.On("ListBuckets").Return(bucketMetadata, nil).Once()
|
typedDriver.On("ListBuckets").Return(bucketMetadata, nil).Once()
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/", nil)
|
request, err = http.NewRequest("GET", testServer.URL+"/", nil)
|
||||||
@ -709,7 +709,7 @@ func (s *MySuite) TestListBuckets(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
bucketMetadata = []drivers.BucketMetadata{
|
bucketMetadata = []drivers.BucketMetadata{
|
||||||
{Name: "bar", Created: time.Now()},
|
{Name: "bar", Created: time.Now().UTC()},
|
||||||
bucketMetadata[0],
|
bucketMetadata[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
|||||||
err := driver.CreateBucket("foo", "private")
|
err := driver.CreateBucket("foo", "private")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
typedDriver.On("ListBuckets").Return([]drivers.BucketMetadata{{Name: "foo", Created: time.Now()}}, nil)
|
typedDriver.On("ListBuckets").Return([]drivers.BucketMetadata{{Name: "foo", Created: time.Now().UTC()}}, nil)
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/", nil)
|
request, err := http.NewRequest("GET", testServer.URL+"/", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("Accept", "application/json")
|
request.Header.Add("Accept", "application/json")
|
||||||
@ -849,7 +849,7 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
|||||||
|
|
||||||
metadata := drivers.BucketMetadata{
|
metadata := drivers.BucketMetadata{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,7 +890,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
|
|
||||||
metadata := drivers.BucketMetadata{
|
metadata := drivers.BucketMetadata{
|
||||||
Name: "bucket",
|
Name: "bucket",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
// test head
|
// test head
|
||||||
@ -898,7 +898,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "one",
|
Key: "one",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
||||||
Size: 0,
|
Size: 0,
|
||||||
}
|
}
|
||||||
@ -944,7 +944,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
Key: "one",
|
Key: "one",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
// Fix MD5
|
// Fix MD5
|
||||||
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
Md5: "d41d8cd98f00b204e9800998ecf8427e",
|
||||||
Size: 0,
|
Size: 0,
|
||||||
@ -1003,7 +1003,7 @@ func (s *MySuite) TestPartialContent(c *C) {
|
|||||||
Bucket: "foo",
|
Bucket: "foo",
|
||||||
Key: "bar",
|
Key: "bar",
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "e81c4e4f2b7b93b481e13a8553c2ae1b", // TODO Determine if md5 of range or full object needed
|
Md5: "e81c4e4f2b7b93b481e13a8553c2ae1b", // TODO Determine if md5 of range or full object needed
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
@ -1127,7 +1127,7 @@ func (s *MySuite) TestListBucketsErrors(c *C) {
|
|||||||
|
|
||||||
metadata := drivers.BucketMetadata{
|
metadata := drivers.BucketMetadata{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,7 +1224,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
|
|||||||
|
|
||||||
metadata := drivers.BucketMetadata{
|
metadata := drivers.BucketMetadata{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
ACL: drivers.BucketACL("private"),
|
ACL: drivers.BucketACL("private"),
|
||||||
}
|
}
|
||||||
typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once()
|
typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once()
|
||||||
@ -1300,7 +1300,7 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) {
|
|||||||
Key: "bar",
|
Key: "bar",
|
||||||
|
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: "e81c4e4f2b7b93b481e13a8553c2ae1b",
|
Md5: "e81c4e4f2b7b93b481e13a8553c2ae1b",
|
||||||
Size: 11,
|
Size: 11,
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,13 @@ package logging
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/minio-io/minio/pkg/iodine"
|
|
||||||
"github.com/minio-io/minio/pkg/utils/log"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/minio-io/minio/pkg/iodine"
|
||||||
|
"github.com/minio-io/minio/pkg/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type logHandler struct {
|
type logHandler struct {
|
||||||
@ -56,13 +57,13 @@ func (w *LogWriter) WriteHeader(status int) {
|
|||||||
|
|
||||||
func (h *logHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (h *logHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
logMessage := &LogMessage{
|
logMessage := &LogMessage{
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
logWriter := &LogWriter{ResponseWriter: w, LogMessage: logMessage}
|
logWriter := &LogWriter{ResponseWriter: w, LogMessage: logMessage}
|
||||||
h.Handler.ServeHTTP(logWriter, req)
|
h.Handler.ServeHTTP(logWriter, req)
|
||||||
logMessage.ResponseHeaders = w.Header()
|
logMessage.ResponseHeaders = w.Header()
|
||||||
logMessage.Request = req
|
logMessage.Request = req
|
||||||
logMessage.Duration = time.Now().Sub(logMessage.StartTime)
|
logMessage.Duration = time.Now().UTC().Sub(logMessage.StartTime)
|
||||||
js, _ := json.Marshal(logMessage)
|
js, _ := json.Marshal(logMessage)
|
||||||
h.Logger <- string(js)
|
h.Logger <- string(js)
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ type quotaMap struct {
|
|||||||
func (q *quotaMap) CanExpire() {
|
func (q *quotaMap) CanExpire() {
|
||||||
q.Lock()
|
q.Lock()
|
||||||
defer q.Unlock()
|
defer q.Unlock()
|
||||||
currentMinute := time.Now().UnixNano() / q.segmentSize.Nanoseconds()
|
currentMinute := time.Now().UTC().UnixNano() / q.segmentSize.Nanoseconds()
|
||||||
// divide by segmentSize, otherwise expiredQuotas will always be negative
|
// divide by segmentSize, otherwise expiredQuotas will always be negative
|
||||||
expiredQuotas := currentMinute - (q.duration.Nanoseconds() / q.segmentSize.Nanoseconds())
|
expiredQuotas := currentMinute - (q.duration.Nanoseconds() / q.segmentSize.Nanoseconds())
|
||||||
for time := range q.data {
|
for time := range q.data {
|
||||||
@ -49,7 +49,7 @@ func (q *quotaMap) Add(ip uint32, size int64) {
|
|||||||
q.CanExpire()
|
q.CanExpire()
|
||||||
q.Lock()
|
q.Lock()
|
||||||
defer q.Unlock()
|
defer q.Unlock()
|
||||||
currentMinute := time.Now().UnixNano() / q.segmentSize.Nanoseconds()
|
currentMinute := time.Now().UTC().UnixNano() / q.segmentSize.Nanoseconds()
|
||||||
if _, ok := q.data[currentMinute]; !ok {
|
if _, ok := q.data[currentMinute]; !ok {
|
||||||
q.data[currentMinute] = make(map[uint32]int64)
|
q.data[currentMinute] = make(map[uint32]int64)
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,12 @@ func NewBucket(bucketName, aclType, donutName string, nodes map[string]Node) (Bu
|
|||||||
}
|
}
|
||||||
bucketMetadata := make(map[string]string)
|
bucketMetadata := make(map[string]string)
|
||||||
bucketMetadata["acl"] = aclType
|
bucketMetadata["acl"] = aclType
|
||||||
bucketMetadata["created"] = time.Now().Format(time.RFC3339Nano)
|
t := time.Now().UTC()
|
||||||
|
bucketMetadata["created"] = t.Format(time.RFC3339Nano)
|
||||||
b := bucket{}
|
b := bucket{}
|
||||||
b.name = bucketName
|
b.name = bucketName
|
||||||
b.acl = aclType
|
b.acl = aclType
|
||||||
b.time = time.Now()
|
b.time = t
|
||||||
b.donutName = donutName
|
b.donutName = donutName
|
||||||
b.objects = make(map[string]Object)
|
b.objects = make(map[string]Object)
|
||||||
b.nodes = nodes
|
b.nodes = nodes
|
||||||
@ -188,7 +189,7 @@ func (b bucket) PutObject(objectName string, objectData io.Reader, expectedMD5Su
|
|||||||
objectMetadata[k] = v
|
objectMetadata[k] = v
|
||||||
}
|
}
|
||||||
dataMd5sum := summer.Sum(nil)
|
dataMd5sum := summer.Sum(nil)
|
||||||
objectMetadata["created"] = time.Now().Format(time.RFC3339Nano)
|
objectMetadata["created"] = time.Now().UTC().Format(time.RFC3339Nano)
|
||||||
|
|
||||||
// keeping md5sum for the object in two different places
|
// keeping md5sum for the object in two different places
|
||||||
// one for object storage and another is for internal use
|
// one for object storage and another is for internal use
|
||||||
|
@ -136,7 +136,7 @@ func (d donutDriver) ListBuckets() (results []drivers.BucketMetadata, err error)
|
|||||||
result := drivers.BucketMetadata{
|
result := drivers.BucketMetadata{
|
||||||
Name: name,
|
Name: name,
|
||||||
// TODO Add real created date
|
// TODO Add real created date
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
results = append(results, result)
|
results = append(results, result)
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ func (memory *memoryDriver) createObject(bucket, key, contentType, expectedMD5Su
|
|||||||
Key: key,
|
Key: key,
|
||||||
|
|
||||||
ContentType: contentType,
|
ContentType: contentType,
|
||||||
Created: time.Now(),
|
Created: time.Now().UTC(),
|
||||||
Md5: md5Sum,
|
Md5: md5Sum,
|
||||||
Size: int64(totalLength),
|
Size: int64(totalLength),
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ func (memory *memoryDriver) CreateBucket(bucketName, acl string) error {
|
|||||||
newBucket.objectMetadata = make(map[string]drivers.ObjectMetadata)
|
newBucket.objectMetadata = make(map[string]drivers.ObjectMetadata)
|
||||||
newBucket.bucketMetadata = drivers.BucketMetadata{}
|
newBucket.bucketMetadata = drivers.BucketMetadata{}
|
||||||
newBucket.bucketMetadata.Name = bucketName
|
newBucket.bucketMetadata.Name = bucketName
|
||||||
newBucket.bucketMetadata.Created = time.Now()
|
newBucket.bucketMetadata.Created = time.Now().UTC()
|
||||||
newBucket.bucketMetadata.ACL = drivers.BucketACL(acl)
|
newBucket.bucketMetadata.ACL = drivers.BucketACL(acl)
|
||||||
memory.lock.Lock()
|
memory.lock.Lock()
|
||||||
defer memory.lock.Unlock()
|
defer memory.lock.Unlock()
|
||||||
@ -522,5 +522,5 @@ func (memory *memoryDriver) expireLRUObjects() {
|
|||||||
func (memory *memoryDriver) updateAccessTime(key string) {
|
func (memory *memoryDriver) updateAccessTime(key string) {
|
||||||
memory.lock.Lock()
|
memory.lock.Lock()
|
||||||
defer memory.lock.Unlock()
|
defer memory.lock.Unlock()
|
||||||
memory.lastAccessedObjects[key] = time.Now()
|
memory.lastAccessedObjects[key] = time.Now().UTC()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user