From 13eb835f1adb5c9e6a5fa1d529fc8d48a3cff397 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 19 Jun 2020 14:16:13 -0400 Subject: [PATCH 1/2] Release notes for PayloadBuffer leak. Re-enable Xgress dialer retransmission in development/example config. --- doc/release-notes.md | 1 + etc/001.yml | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index 05e7f7def..48772cf1d 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -6,6 +6,7 @@ Ziti 0.15.0 includes the following: * Remove deprecated AppWan and Clusters - These have been replaced by service policies and service edge router policies respectively * cosmetic changes to the ziti-enroller binary * cosmetic changes to the ziti-tunnel binary when running the enroll subcommand +* Memory leak remediation in the `PayloadBuffer` subsystem. Corrects unbounded memory growth in `ziti-router`. ## Removal of deprecated code The code to migrate a Ziti instance from pre-0.9 releases has been removed. If you want to migrate from a pre-0.9 version you should first update to 0.14.12, then to new versions. diff --git a/etc/001.yml b/etc/001.yml index 602d0c5c4..0f26dde47 100644 --- a/etc/001.yml +++ b/etc/001.yml @@ -37,7 +37,7 @@ listeners: address: tcp:0.0.0.0:1122 service: ssh options: - mtu: 768 + retransmission: true # for iperf_tcp (iperf3) - binding: proxy @@ -65,6 +65,11 @@ listeners: randomDrops: true drop1InN: 5000 +dialers: + - binding: transport + options: + retransmission: true + # xctrl_example # #example: From 50fbd4d25713a4e214ae50719820eee10a1201a2 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Fri, 19 Jun 2020 14:19:28 -0400 Subject: [PATCH 2/2] More release updates (#125) * Add names to fabric service/routers. Add snapshot-db command --- doc/release-notes.md | 30 +++++++-- go.mod | 12 ++-- go.sum | 48 +++++++++----- ziti-fabric/subcmd/create_router.go | 10 ++- ziti-fabric/subcmd/create_service.go | 3 + ziti-fabric/subcmd/get_service.go | 6 +- ziti-fabric/subcmd/list_routers.go | 8 +-- ziti-fabric/subcmd/list_services.go | 6 +- .../cmd/edge_controller/create_snapshot.go | 65 +++++++++++++++++++ ziti/cmd/ziti/cmd/edge_controller/root.go | 1 + ziti/cmd/ziti/util/rest.go | 11 +++- 11 files changed, 155 insertions(+), 45 deletions(-) create mode 100644 ziti/cmd/ziti/cmd/edge_controller/create_snapshot.go diff --git a/doc/release-notes.md b/doc/release-notes.md index 48772cf1d..ed0530143 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -1,9 +1,16 @@ # Release 0.15.0 Ziti 0.15.0 includes the following: -* [Create fabric mgmt API to request database snapshot/backup be created](https://github.com/openziti/fabric/issues/99) -* [Remove postgres store code including migrations](https://github.com/openziti/edge/issues/195) -* Remove deprecated AppWan and Clusters - These have been replaced by service policies and service edge router policies respectively +* The ability to invoke a database snapshot/backup + * [Create fabric mgmt API to request database snapshot/backup be created](https://github.com/openziti/fabric/issues/99) + * [Add snapshot db REST API](https://github.com/openziti/edge/issues/206) +* Removal of deprecated code/migrations + * [Remove postgres store code including migrations](https://github.com/openziti/edge/issues/195) + * Remove deprecated AppWan and Clusters - These have been replaced by service policies and service edge router policies respectively +* Edge Routers are now a subtype of Fabric Routers + * see [Unverified Edge Routers Cannot Be Used For Terminators](https://github.com/openziti/edge/issues/144) +* Fabric services and routers now have names + * see [Add name to service and router](https://github.com/openziti/fabric/issues/101) * cosmetic changes to the ziti-enroller binary * cosmetic changes to the ziti-tunnel binary when running the enroll subcommand * Memory leak remediation in the `PayloadBuffer` subsystem. Corrects unbounded memory growth in `ziti-router`. @@ -12,11 +19,24 @@ Ziti 0.15.0 includes the following: The code to migrate a Ziti instance from pre-0.9 releases has been removed. If you want to migrate from a pre-0.9 version you should first update to 0.14.12, then to new versions. ## Database Snapshots -The ziti-fabric tool can now be used to trigger the creation of a dabase backup/snapshot. +Database snapshots can now be triggered in a variety of ways to cause the creation of a dabase backup/snapshot. This can be done from the ziti-fabric CLI, the ziti CLI and the REST API $ ziti-fabric snapshot-db + $ ziti edge snapshot-db -This will create a copy of the database file within a bolt transaction. The file name will have the data and time appended to it. Snapshotting can be done at most once per minute. Support to trigger this from the Edge REST API will be comming in a follow-up release. +The REST API is available by POSTing to `/edge/v1/database/snapshot`. This ability is only available to administrators. + +The snapshot will be a copy of the database file created within a bolt transaction. The file name will have the data and time appended to it. Snapshotting can be done at most once per minute. + +## Edge Routers/Fabric Router subtyping +Previously edge routers and fabric routers were closely related, but weren't actually the same entity. When an edge router was created, there was no corresponding fabric router until the edge router had been succesfully enrolled. + +Now, edge routers are a type of fabric router. When an edge router is created, it will be visible as a fabric router with no fingerprint. This means that the corresponding router application won't be able to connect until enrollment is complete. + +This simplifies some things, including allowing adding terminators to an edge router before enrollment is complete. + +## Fabric Router and Service Names +Previously fabric routers and services only had ids, which were assumed to be something user friendly. Now they also have a name. If no name is provided, the id will be used for the name as well. This was done primarily so that we have consistency between the fabric and the edge. Now when viewing a service or router you can be sure to find the label in the same place. # Release 0.14.13 Ziti 0.14.13 includes the following: diff --git a/go.mod b/go.mod index 043de756f..65da550c3 100644 --- a/go.mod +++ b/go.mod @@ -25,10 +25,10 @@ require ( github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc - github.com/openziti/edge v0.14.37 - github.com/openziti/fabric v0.11.41 - github.com/openziti/foundation v0.11.4 - github.com/openziti/sdk-golang v0.13.6 + github.com/openziti/edge v0.14.45 + github.com/openziti/fabric v0.11.48 + github.com/openziti/foundation v0.11.8 + github.com/openziti/sdk-golang v0.13.11 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 @@ -40,9 +40,9 @@ require ( github.com/spf13/cobra v0.0.7 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.5.0 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 github.com/urfave/negroni v1.0.0 - golang.org/x/net v0.0.0-20200226121028-0de0cce0169b + golang.org/x/net v0.0.0-20200602114024-627f9648deb9 google.golang.org/grpc v1.25.1 gopkg.in/AlecAivazis/survey.v1 v1.8.7 gopkg.in/resty.v1 v1.12.0 diff --git a/go.sum b/go.sum index 4336b9258..b43646946 100644 --- a/go.sum +++ b/go.sum @@ -205,6 +205,8 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -307,8 +309,8 @@ github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WT github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.1 h1:cCBH2gTD2K0OtLlv/Y5H01VQCqmlDxz30kS5Y5bqfLA= -github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/netfoundry/secretstream v0.1.1 h1:z6T7B5DuOtr9O+SmKaS9DzwOoGLYtgvyTzuPuR5FO7I= @@ -319,20 +321,19 @@ github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/openziti/edge v0.14.37 h1:zEFk+Wow2Htcb9iTr3lAnWwfFs2PkwlgmVhGdXjo3Gw= -github.com/openziti/edge v0.14.37/go.mod h1:/FD4nh2v1GAq6vsoEBRYfLKjyHSt+ouxu8pznfcEXVQ= -github.com/openziti/fabric v0.11.40 h1:IebmkMrAa7R216cBd1ROhON5RgiPFm9TVyqo7a2Aknk= -github.com/openziti/fabric v0.11.40/go.mod h1:LsIAeOvc0ygIPZ2QCuh2l/nWbt2pp2e431KAhNtixws= -github.com/openziti/fabric v0.11.41 h1:9nF3r7K76hNngDqEr1WkC7bTSZP08hhPCjeyAmvWYfY= -github.com/openziti/fabric v0.11.41/go.mod h1:5m9QZeM62MiHLo5/QyY121oRypPc9atu1W8DUzyhDpM= -github.com/openziti/foundation v0.11.2 h1:h6jsPLDkNzH1WTVPb8MPaECgYqEwzlXFwLRFeO1Aojk= -github.com/openziti/foundation v0.11.2/go.mod h1:E+z3Ne+G1IrApCxg/+kKLFg5hUubElHyylvfCLJg4fk= -github.com/openziti/foundation v0.11.3/go.mod h1:E+z3Ne+G1IrApCxg/+kKLFg5hUubElHyylvfCLJg4fk= -github.com/openziti/foundation v0.11.4 h1:3EZ+H1iJB/bdWnGTiQUoTQFp4vHYZ7oZWM2JkE7AQW4= -github.com/openziti/foundation v0.11.4/go.mod h1:E+z3Ne+G1IrApCxg/+kKLFg5hUubElHyylvfCLJg4fk= -github.com/openziti/sdk-golang v0.13.5/go.mod h1:SaHHvLkf4HnTqK4iOQmNmA23BsylRGc5Npb/x0g0hJc= -github.com/openziti/sdk-golang v0.13.6 h1:wlO+VljW4pNXwY8tANLWBLOOM91oRoZHvlBtv7JBbBI= -github.com/openziti/sdk-golang v0.13.6/go.mod h1:TM1BobbkOY7TOVMXlciKQJaZQlSgqap89MHi0AgmRMM= +github.com/openziti/edge v0.14.45 h1:P/bUFsDVMj3Eh9Rbqk1O9EjxJz51iWAW51LFr/jGnxI= +github.com/openziti/edge v0.14.45/go.mod h1:BMfLnzTjmdsZCudteTDEuZ2zO0Jv4oh5qBCwTssNo2o= +github.com/openziti/fabric v0.11.43/go.mod h1:va9H0K20ugtCsMj8/1vdRAWsWlFdy1T+OEdXm0e1LW4= +github.com/openziti/fabric v0.11.48 h1:1mFFeelzAKj+ZAMS4cX64z4WTHULZCyz+h6QpePLteo= +github.com/openziti/fabric v0.11.48/go.mod h1:DHTpBAV096+0d3T65IDNFwd/a+ht3IxqSbMNZbsd+2Q= +github.com/openziti/foundation v0.11.5 h1:RmhFzKgH9KdztsF1T/70s+ftPpMGu1X3A6RhmPlOFiY= +github.com/openziti/foundation v0.11.5/go.mod h1:jfnQ8WWFJGrDD2COPtQ/yX+gRlaiMdwUuXbvEBOpnLc= +github.com/openziti/foundation v0.11.7/go.mod h1:Qdd7eCuTrpRwEeDbvYy89sFbEY4+J7OuX8UygxNBsvY= +github.com/openziti/foundation v0.11.8 h1:fcJzxdtU1URLwPB6DHRLlod+by4TMXYmMPWxOKu2vEw= +github.com/openziti/foundation v0.11.8/go.mod h1:Qdd7eCuTrpRwEeDbvYy89sFbEY4+J7OuX8UygxNBsvY= +github.com/openziti/sdk-golang v0.13.10/go.mod h1:jXBekQvK4B9+w/JwN0uE9AAorFuqbph36uFGZHSmwkw= +github.com/openziti/sdk-golang v0.13.11 h1:VlaW8H2dOeq4LwZtc5VFObjcI9YJW+rNNVA43LYKAec= +github.com/openziti/sdk-golang v0.13.11/go.mod h1:CQFpRGd/+x/i5uHdnXaY7V1Eusb6siCmZcF7vVhUXKo= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= @@ -415,8 +416,12 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ75iPqWZc0HeJWFYNCvKsfpQwFpRNTA= +github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -436,8 +441,8 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= -go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.5-0.20200615073812-232d8fc87f50 h1:ASw9n1EHMftwnP3Az4XW6e308+gNsrHzmdhd0Olz9Hs= +go.etcd.io/bbolt v1.3.5-0.20200615073812-232d8fc87f50/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= @@ -488,6 +493,8 @@ golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -521,6 +528,9 @@ golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -577,6 +587,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/goversion v1.2.0 h1:SPn+NLTiAG7w30IRK/DKp1BjvpWabYgxlLp/+kx5J8w= diff --git a/ziti-fabric/subcmd/create_router.go b/ziti-fabric/subcmd/create_router.go index 7dc91a615..7ac4f6ae1 100644 --- a/ziti-fabric/subcmd/create_router.go +++ b/ziti-fabric/subcmd/create_router.go @@ -17,18 +17,21 @@ package subcmd import ( - "github.com/openziti/foundation/channel2" - "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/foundation/identity/certtools" "crypto/sha1" "errors" "fmt" "github.com/golang/protobuf/proto" + "github.com/openziti/fabric/pb/mgmt_pb" + "github.com/openziti/foundation/channel2" + "github.com/openziti/foundation/identity/certtools" "github.com/spf13/cobra" "time" ) +var createRouterName string + func init() { + createRouter.Flags().StringVar(&createServiceName, "name", "", "Router name. If not provided defaults to the router ID") createRouterClient = NewMgmtClient(createRouter) createCmd.AddCommand(createRouter) } @@ -43,6 +46,7 @@ var createRouter = &cobra.Command{ request := &mgmt_pb.CreateRouterRequest{ Router: &mgmt_pb.Router{ Id: cert[0].Subject.CommonName, + Name: createRouterName, Fingerprint: fmt.Sprintf("%x", sha1.Sum(cert[0].Raw)), }, } diff --git a/ziti-fabric/subcmd/create_service.go b/ziti-fabric/subcmd/create_service.go index 95bac26db..9b2ca9583 100644 --- a/ziti-fabric/subcmd/create_service.go +++ b/ziti-fabric/subcmd/create_service.go @@ -27,8 +27,10 @@ import ( var createServiceClient *mgmtClient var createServiceTerminatorStrategy string +var createServiceName string func init() { + createService.Flags().StringVar(&createServiceName, "name", "", "Service name. If not provided defaults to the ID") createService.Flags().StringVar(&createServiceTerminatorStrategy, "terminator-strategy", "", "Terminator strategy for service") createServiceClient = NewMgmtClient(createService) createCmd.AddCommand(createService) @@ -43,6 +45,7 @@ var createService = &cobra.Command{ request := &mgmt_pb.CreateServiceRequest{ Service: &mgmt_pb.Service{ Id: args[0], + Name: createServiceName, TerminatorStrategy: createServiceTerminatorStrategy, }, } diff --git a/ziti-fabric/subcmd/get_service.go b/ziti-fabric/subcmd/get_service.go index 977ab8183..9c690a77c 100644 --- a/ziti-fabric/subcmd/get_service.go +++ b/ziti-fabric/subcmd/get_service.go @@ -52,10 +52,10 @@ var getService = &cobra.Command{ response := &mgmt_pb.GetServiceResponse{} err := proto.Unmarshal(responseMsg.Body, response) if err == nil { - fmt.Printf("\n%10s | %30s\n", "Id", "Terminator Strategy") - fmt.Printf("-----------+--------------------------------+----------\n") + fmt.Printf("\n%10s | %30s | %30s\n", "Id", "Name", "Terminator Strategy") + fmt.Printf("-----------+--------------------------------+------------------------------\n") svc := response.Service - fmt.Printf("%10s | %30s\n\n", svc.Id, svc.TerminatorStrategy) + fmt.Printf("%10s | %30s | %30s\n\n", svc.Id, svc.Name, svc.TerminatorStrategy) fmt.Printf("Terminators (%v)\n", len(svc.Terminators)) fmt.Printf("\n%10s | %-12s| %v\n", "Id", "Binding", "Destination") for _, terminator := range svc.Terminators { diff --git a/ziti-fabric/subcmd/list_routers.go b/ziti-fabric/subcmd/list_routers.go index cd7692adf..6a14a05c7 100644 --- a/ziti-fabric/subcmd/list_routers.go +++ b/ziti-fabric/subcmd/list_routers.go @@ -17,11 +17,11 @@ package subcmd import ( - "github.com/openziti/foundation/channel2" - "github.com/openziti/fabric/pb/mgmt_pb" "errors" "fmt" "github.com/golang/protobuf/proto" + "github.com/openziti/fabric/pb/mgmt_pb" + "github.com/openziti/foundation/channel2" "github.com/spf13/cobra" "time" ) @@ -53,7 +53,7 @@ var listRouters = &cobra.Command{ err := proto.Unmarshal(responseMsg.Body, response) if err == nil { out := fmt.Sprintf("\nRouters: (%d)\n\n", len(response.Routers)) - out += fmt.Sprintf("%-12s | %-40s | %s\n", "Id", "Fingerprint", "Status") + out += fmt.Sprintf("%-12s | %-30s | %-40s | %s\n", "Id", "Name", "Fingerprint", "Status") for _, r := range response.Routers { status := "" if r.Connected { @@ -62,7 +62,7 @@ var listRouters = &cobra.Command{ if r.ListenerAddress != "" { status += " (" + r.ListenerAddress + ")" } - out += fmt.Sprintf("%-12s | %-40s | %s\n", r.Id, r.Fingerprint, status) + out += fmt.Sprintf("%-12s | %-30s | %-40s | %s\n", r.Id, r.Name, r.Fingerprint, status) } out += "\n" fmt.Print(out) diff --git a/ziti-fabric/subcmd/list_services.go b/ziti-fabric/subcmd/list_services.go index 4c0a605c5..dc5660e90 100644 --- a/ziti-fabric/subcmd/list_services.go +++ b/ziti-fabric/subcmd/list_services.go @@ -50,17 +50,17 @@ var listServices = &cobra.Command{ response := &mgmt_pb.ListServicesResponse{} if err := proto.Unmarshal(responseMsg.Body, response); err == nil { out := fmt.Sprintf("\nServices: (%d)\n\n", len(response.Services)) - out += fmt.Sprintf("%-12s | %-12s | %s\n", "Id", "Terminator Strategy", "Destination(s)") + out += fmt.Sprintf("%-12s | %-12s | %-12s | %s\n", "Id", "Name", "Terminator Strategy", "Destination(s)") for _, svc := range response.Services { if len(svc.Terminators) > 0 { - out += fmt.Sprintf("%-12s | %-12s | %s\n", svc.Id, svc.TerminatorStrategy, + out += fmt.Sprintf("%-12s | %-12s | %-12s | %s\n", svc.Id, svc.Name, svc.TerminatorStrategy, fmt.Sprintf("%-12s -> %s", svc.Terminators[0].RouterId, svc.Terminators[0].Address)) for _, terminator := range svc.Terminators[1:] { out += fmt.Sprintf("%-12s | %-12s | %s\n", "", "", fmt.Sprintf("%-12s -> %s", terminator.RouterId, terminator.Address)) } } else { - out += fmt.Sprintf("%-12s | %-12s | \n", svc.Id, svc.TerminatorStrategy) + out += fmt.Sprintf("%-12s | %-12s | %-12s \n", svc.Id, svc.Name, svc.TerminatorStrategy) } } out += "\n" diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_snapshot.go b/ziti/cmd/ziti/cmd/edge_controller/create_snapshot.go new file mode 100644 index 000000000..2ade159e9 --- /dev/null +++ b/ziti/cmd/ziti/cmd/edge_controller/create_snapshot.go @@ -0,0 +1,65 @@ +/* + Copyright NetFoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package edge_controller + +import ( + "github.com/openziti/ziti/ziti/cmd/ziti/cmd/common" + cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/openziti/ziti/ziti/cmd/ziti/util" + "github.com/spf13/cobra" + "io" + "net/http" +) + +type snapshotDbOptions struct { + commonOptions +} + +// newSnapshotDbCmd creates the 'edge controller create service-policy' command +func newSnapshotDbCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { + options := &snapshotDbOptions{ + commonOptions: commonOptions{ + CommonOptions: common.CommonOptions{Factory: f, Out: out, Err: errOut}, + }, + } + + cmd := &cobra.Command{ + Use: "snapshot-db", + Short: "creates a database snapshot", + Args: cobra.ExactArgs(0), + Run: func(cmd *cobra.Command, args []string) { + options.Cmd = cmd + options.Args = args + err := runSnapshotDb(options) + cmdhelper.CheckErr(err) + }, + SuggestFor: []string{}, + } + + // allow interspersing positional args and flags + cmd.Flags().SetInterspersed(true) + cmd.Flags().BoolVarP(&options.OutputJSONResponse, "output-json", "j", false, "Output the full JSON response from the Ziti Edge Controller") + + return cmd +} + +// runSnapshotDb create a new config on the Ziti Edge Controller +func runSnapshotDb(o *snapshotDbOptions) error { + _, err := util.EdgeControllerUpdate("database/snapshot", "", o.Out, http.MethodPost, false) + return err +} diff --git a/ziti/cmd/ziti/cmd/edge_controller/root.go b/ziti/cmd/ziti/cmd/edge_controller/root.go index e4bc7d64e..9e94fc49f 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/root.go +++ b/ziti/cmd/ziti/cmd/edge_controller/root.go @@ -57,6 +57,7 @@ func populateEdgeCommands(f cmdutil.Factory, out io.Writer, errOut io.Writer, cm cmd.AddCommand(newVersionCmd(f, out, errOut)) cmd.AddCommand(newPolicyAdivsorCmd(f, out, errOut)) cmd.AddCommand(newVerifyCmd(f, out, errOut)) + cmd.AddCommand(newSnapshotDbCmd(f, out, errOut)) return cmd } diff --git a/ziti/cmd/ziti/util/rest.go b/ziti/cmd/ziti/util/rest.go index 3b399f933..b204badce 100644 --- a/ziti/cmd/ziti/util/rest.go +++ b/ziti/cmd/ziti/util/rest.go @@ -609,6 +609,10 @@ func EdgeControllerUpdate(entityType string, body string, out io.Writer, method outputJson(out, resp.Body()) } + if len(resp.Body()) == 0 { + return nil, nil + } + jsonParsed, err := gabs.ParseJSON(resp.Body()) if err != nil { @@ -685,6 +689,10 @@ func EdgeControllerRequest(entityType string, out io.Writer, logJSON bool, doReq outputJson(out, resp.Body()) } + if resp.Body() == nil { + return nil, nil + } + jsonParsed, err := gabs.ParseJSON(resp.Body()) if err != nil { @@ -692,7 +700,4 @@ func EdgeControllerRequest(entityType string, out io.Writer, logJSON bool, doReq } return jsonParsed, nil - } - -//util.EdgeControllerRequest(session.Host, session.Cert, session.Token, entityType, options.Out, options.OutputJSONResponse, func(request *resty.Request) error {