Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#661 - Exposing creationTime and modificationTime #677

Merged
merged 32 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
665fd13
feature exposed creationTime & modificationTime in kuma
tharun208 Apr 14, 2020
5706587
feature exposed creationTime & modificationTime in kuma
tharun208 Apr 14, 2020
dd2e5b1
feature exposed creationTime & modificationTime for kuma get dataplanes
tharun208 Apr 14, 2020
cc845a1
feature exposed creationTime & modificationTime for kuma get fault in…
tharun208 Apr 14, 2020
af336c9
feature exposed creationTime & modificationTime for kuma get health c…
tharun208 Apr 14, 2020
fbc8468
feature exposed creationTime & modificationTime for kuma get meshes
tharun208 Apr 14, 2020
7f55289
feature exposed creationTime & modificationTime for kuma get proxy Te…
tharun208 Apr 14, 2020
a3198ed
feature exposed creationTime & modificationTime for kuma get traffic …
tharun208 Apr 14, 2020
e8a7445
feature exposed creationTime & modificationTime for kuma get traffic …
tharun208 Apr 14, 2020
6fe53f3
feature exposed creationTime & modificationTime for kuma get traffic …
tharun208 Apr 14, 2020
d8dc012
feature exposed creationTime & modificationTime for kuma get traffic …
tharun208 Apr 14, 2020
fd0ba3c
feature exposed creationTime & modificationTime for kuma inspect data…
tharun208 Apr 14, 2020
e104eb0
feature exposed creationTime & modificationTime for kuma
tharun208 Apr 14, 2020
6acce39
feature exposed creationTime & modificationTime for kuma
tharun208 Apr 14, 2020
0d80de7
feature exposed creationTime & modificationTime for kuma
tharun208 Apr 14, 2020
080c42e
* update api-server resource tests with proper dateTime
tharun208 Apr 14, 2020
1527053
* removed unwanted omitempty tag for creationTime and modificationTime
tharun208 Apr 14, 2020
99117f7
* updated apply dry-run to return noop date-time
tharun208 Apr 14, 2020
84162e1
Merge remote-tracking branch 'origin/master' into feat/#661
tharun208 Apr 15, 2020
522f1e8
Merge remote-tracking branch 'origin/master' into feat/#661
tharun208 Apr 15, 2020
f57aa4f
* updated get single resource test data
tharun208 Apr 15, 2020
e5ed83b
* added createdAt and modifiedAt params to upsert function in apply
tharun208 Apr 15, 2020
0df63c9
updated branch with upstream
tharun208 Apr 17, 2020
196d6ea
fiixed failing tests
tharun208 Apr 17, 2020
8589237
removed storing creation and modification time in client
tharun208 Apr 21, 2020
dc0c940
show default creationTime and modificationTime for all resources in k…
tharun208 Apr 21, 2020
a5b7ad4
Merge remote-tracking branch 'origin/master' into feat/#661
tharun208 Apr 21, 2020
93171c8
show default creationTime and modificationTime in store
tharun208 Apr 21, 2020
c072066
fix(kuma-ctl): reverted back creation and modification time to constant
tharun208 Apr 24, 2020
ac3636c
fix(kuma-ctl): unmarshalling check for creationtime and modification …
tharun208 Apr 24, 2020
64a28e7
rebased with upstream
tharun208 Apr 24, 2020
87cdfdc
updated tests
tharun208 Apr 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/kumactl/cmd/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ func parseResource(bytes []byte) (model.Resource, error) {
var _ model.ResourceMeta = &meta{}

type meta struct {
Name string
Mesh string
Name string
Mesh string
CreationTime time.Time
ModificationTime time.Time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed though? I think we can revert this file to master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but not sure if I revert it to master, GetCreationTime() is time.Unix and it will be different for each machine and the test will fail in ci.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.Unix(0, 0) indicates the constant time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

}

func (m meta) GetName() string {
Expand All @@ -220,9 +222,9 @@ func (m meta) GetMesh() string {
}

func (m meta) GetCreationTime() time.Time {
return time.Unix(0, 0) // the date doesn't matter since it is set on server side anyways
return m.CreationTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is still relevant. This should be set on the server-side.

}

func (m meta) GetModificationTime() time.Time {
return time.Unix(0, 0) // the date doesn't matter since it is set on server side anyways
return m.ModificationTime
}
4 changes: 3 additions & 1 deletion app/kumactl/cmd/apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ var _ = Describe("kumactl apply", func() {

// then
Expect(buf.String()).To(Equal(
`mesh: default
`creationTime: "0001-01-01T00:00:00Z"
mesh: default
modificationTime: "0001-01-01T00:00:00Z"
name: sample
networking:
address: 2.2.2.2
Expand Down
7 changes: 5 additions & 2 deletions app/kumactl/cmd/get/get_dataplanes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"path/filepath"
"strings"
"time"

"github.com/Kong/kuma/app/kumactl/cmd"

Expand All @@ -30,8 +31,10 @@ import (
var _ = Describe("kumactl get dataplanes", func() {

var dataplanes []*mesh_core.DataplaneResource

var t1 time.Time
BeforeEach(func() {
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert such files (I see a couple of them) with an empty line change to master?
It's easier to review and less potential conflicts

dataplanes = []*mesh_core.DataplaneResource{
{
Meta: &test_model.ResourceMeta{
Expand Down Expand Up @@ -111,7 +114,7 @@ var _ = Describe("kumactl get dataplanes", func() {
Mesh: pt.Meta.GetMesh(),
Name: pt.Meta.GetName(),
}
err := store.Create(context.Background(), pt, core_store.CreateBy(key))
err := store.Create(context.Background(), pt, core_store.CreateBy(key), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/get/get_fault_injections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ var _ = Describe("kumactl get fault-injections", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
Now: time.Now,
Expand All @@ -127,7 +128,7 @@ var _ = Describe("kumactl get fault-injections", func() {
store = memory_resources.NewStore()

for _, ds := range faultInjectionResources {
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())))
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
8 changes: 4 additions & 4 deletions app/kumactl/cmd/get/get_healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"path/filepath"
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand All @@ -29,7 +30,6 @@ import (
var _ = Describe("kumactl get healthchecks", func() {

var sampleHealthChecks []*mesh_core.HealthCheckResource

BeforeEach(func() {
sampleHealthChecks = []*mesh_core.HealthCheckResource{
{
Expand Down Expand Up @@ -62,10 +62,10 @@ var _ = Describe("kumactl get healthchecks", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup

t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
Expand All @@ -81,7 +81,7 @@ var _ = Describe("kumactl get healthchecks", func() {
Mesh: pt.Meta.GetMesh(),
Name: pt.Meta.GetName(),
}
err := store.Create(context.Background(), pt, core_store.CreateBy(key))
err := store.Create(context.Background(), pt, core_store.CreateBy(key), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/get/get_meshes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ var _ = Describe("kumactl get meshes", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
Now: time.Now,
Expand All @@ -177,7 +178,7 @@ var _ = Describe("kumactl get meshes", func() {
Mesh: ds.Meta.GetMesh(),
Name: ds.Meta.GetName(),
}
err := store.Create(context.Background(), ds, core_store.CreateBy(key))
err := store.Create(context.Background(), ds, core_store.CreateBy(key), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
7 changes: 4 additions & 3 deletions app/kumactl/cmd/get/get_proxytemplates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"path/filepath"
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down Expand Up @@ -60,10 +61,10 @@ var _ = Describe("kumactl get proxytemplates", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup

t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
Expand All @@ -79,7 +80,7 @@ var _ = Describe("kumactl get proxytemplates", func() {
Mesh: pt.Meta.GetMesh(),
Name: pt.Meta.GetName(),
}
err := store.Create(context.Background(), pt, core_store.CreateBy(key))
err := store.Create(context.Background(), pt, core_store.CreateBy(key), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/get/get_traffic_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ var _ = Describe("kumactl get traffic-logs", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
Now: time.Now,
Expand All @@ -105,7 +106,7 @@ var _ = Describe("kumactl get traffic-logs", func() {
store = memory_resources.NewStore()

for _, ds := range trafficLoggingResources {
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())))
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
7 changes: 4 additions & 3 deletions app/kumactl/cmd/get/get_traffic_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"path/filepath"
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down Expand Up @@ -62,10 +63,10 @@ var _ = Describe("kumactl get traffic-routes", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup

t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
Expand All @@ -81,7 +82,7 @@ var _ = Describe("kumactl get traffic-routes", func() {
Mesh: pt.Meta.GetMesh(),
Name: pt.Meta.GetName(),
}
err := store.Create(context.Background(), pt, core_store.CreateBy(key))
err := store.Create(context.Background(), pt, core_store.CreateBy(key), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/get/get_traffic_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ var _ = Describe("kumactl get traffic-traces", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
Now: time.Now,
Expand All @@ -89,7 +90,7 @@ var _ = Describe("kumactl get traffic-traces", func() {
store = memory_resources.NewStore()

for _, ds := range trafficTraceResources {
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())))
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/get/get_trafficpermissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ var _ = Describe("kumactl get traffic-permissions", func() {
var rootCmd *cobra.Command
var buf *bytes.Buffer
var store core_store.ResourceStore

var t1 time.Time
BeforeEach(func() {
// setup
t1, _ = time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
rootCtx = &kumactl_cmd.RootContext{
Runtime: kumactl_cmd.RootRuntime{
Now: time.Now,
Expand All @@ -99,7 +100,7 @@ var _ = Describe("kumactl get traffic-permissions", func() {
store = memory_resources.NewStore()

for _, ds := range trafficPermissionResources {
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())))
err := store.Create(context.Background(), ds, core_store.CreateBy(core_model.MetaToResourceKey(ds.GetMeta())), core_store.CreatedAt(t1))
Expect(err).ToNot(HaveOccurred())
}

Expand Down
4 changes: 4 additions & 0 deletions app/kumactl/cmd/get/testdata/get-dataplanes.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{
"mesh": "default",
"name": "experiment",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"networking": {
"address": "127.0.0.1",
"inbound": [
Expand All @@ -29,6 +31,8 @@
{
"mesh": "default",
"name": "example",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"networking": {
"address": "127.0.0.2",
"inbound": [
Expand Down
8 changes: 6 additions & 2 deletions app/kumactl/cmd/get/testdata/get-dataplanes.golden.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
items:
- mesh: default
- creationTime: 2018-07-17T16:05:36.995Z
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: experiment
networking:
address: 127.0.0.1
Expand All @@ -15,7 +17,9 @@ items:
service: metrics
version: v1
type: Dataplane
- mesh: default
- creationTime: 2018-07-17T16:05:36.995Z
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: example
networking:
address: 127.0.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"type": "FaultInjection",
"mesh": "default",
"name": "fi1",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"sources": [
{
"match": {
Expand Down Expand Up @@ -38,6 +40,8 @@
"type": "FaultInjection",
"mesh": "default",
"name": "fi2",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"sources": [
{
"match": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ items:
responseBandwidth:
limit: 50 mbps
percentage: 50
creationTime: 2018-07-17T16:05:36.995Z
destinations:
- match:
service: backend
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: fi1
sources:
- match:
Expand All @@ -29,10 +31,12 @@ items:
responseBandwidth:
limit: 50 mbps
percentage: 50
creationTime: 2018-07-17T16:05:36.995Z
destinations:
- match:
service: redis
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: fi2
sources:
- match:
Expand Down
8 changes: 6 additions & 2 deletions app/kumactl/cmd/get/testdata/get-healthchecks.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
{
"mesh": "default",
"name": "web-to-backend",
"type": "HealthCheck"
"type": "HealthCheck",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z"
},
{
"mesh": "default",
"name": "backend-to-db",
"type": "HealthCheck"
"type": "HealthCheck",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z"
}
]
}
10 changes: 7 additions & 3 deletions app/kumactl/cmd/get/testdata/get-healthchecks.golden.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
items:
- mesh: default
- creationTime: 2018-07-17T16:05:36.995Z
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: web-to-backend
type: HealthCheck
- mesh: default
- creationTime: 2018-07-17T16:05:36.995Z
mesh: default
modificationTime: 2018-07-17T16:05:36.995Z
name: backend-to-db
type: HealthCheck
type: HealthCheck
Loading