From 58f8ac860f0b8d176c37b434da669e325aa10569 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sat, 23 Aug 2014 14:33:24 -0400 Subject: [PATCH] Set creation timestamp on services --- pkg/registry/service/storage.go | 4 +++- pkg/registry/service/storage_test.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/registry/service/storage.go b/pkg/registry/service/storage.go index 785c78c8b48..d5b4103dce6 100644 --- a/pkg/registry/service/storage.go +++ b/pkg/registry/service/storage.go @@ -50,6 +50,9 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { if errs := api.ValidateService(srv); len(errs) > 0 { return nil, fmt.Errorf("Validation errors: %v", errs) } + + srv.CreationTimestamp = util.Now() + return apiserver.MakeAsync(func() (interface{}, error) { // TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers // correctly no matter what http operations happen. @@ -78,7 +81,6 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { return nil, err } } - // TODO actually wait for the object to be fully created here. err := rs.registry.CreateService(*srv) if err != nil { return nil, err diff --git a/pkg/registry/service/storage_test.go b/pkg/registry/service/storage_test.go index e86f499efac..b9304360127 100644 --- a/pkg/registry/service/storage_test.go +++ b/pkg/registry/service/storage_test.go @@ -43,6 +43,9 @@ func TestServiceRegistryCreate(t *testing.T) { if created_service.ID != "foo" { t.Errorf("Expected foo, but got %v", created_service.ID) } + if created_service.CreationTimestamp.IsZero() { + t.Errorf("Expected timestamp to be set, got %:v", created_service.CreationTimestamp) + } if len(fakeCloud.Calls) != 0 { t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) }