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