Skip to content

Commit

Permalink
add stacktrace flag
Browse files Browse the repository at this point in the history
Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
  • Loading branch information
yuntanghsu committed Aug 1, 2022
1 parent 3b301ff commit ffa2b41
Show file tree
Hide file tree
Showing 20 changed files with 396 additions and 231 deletions.
2 changes: 2 additions & 0 deletions ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TESTBED_CMD=$(dirname $0)"/kind-setup.sh"
YML_DIR=$(dirname $0)"/../../build/yamls"
FLOW_VISIBILITY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1"
FLOW_VISIBILITY_WITH_SPARK_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --no-grafana --spark-operator"
FLOW_VISIBILITY_CH_ONLY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --no-grafana"
CH_OPERATOR_YML=$(dirname $0)"/../../build/charts/theia/crds/clickhouse-operator-install-bundle.yaml"

make theia-linux
Expand Down Expand Up @@ -161,6 +162,7 @@ function run_test {
docker exec -i kind-control-plane dd of=/root/clickhouse-operator-install-bundle.yaml < $CH_OPERATOR_YML
$FLOW_VISIBILITY_CMD | docker exec -i kind-control-plane dd of=/root/flow-visibility.yml
$FLOW_VISIBILITY_WITH_SPARK_CMD | docker exec -i kind-control-plane dd of=/root/flow-visibility-with-spark.yml
$FLOW_VISIBILITY_CH_ONLY_CMD | docker exec -i kind-control-plane dd of=/root/flow-visibility-ch-only.yml

docker exec -i kind-control-plane dd of=/root/theia < $THEIACTL_BIN

Expand Down
91 changes: 89 additions & 2 deletions docs/theia-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ visibility capabilities.
<!-- toc -->
- [Installation](#installation)
- [Usage](#usage)
- [NetworkPolicy Recommendation feature](#networkpolicy-recommendation-feature)
- [ClickHouse](#clickhouse)
- [Disk usage information](#disk-usage-information)
- [Table Information](#table-information)
- [Insertion rate](#insertion-rate)
- [Stack trace](#stack-trace)
<!-- /toc -->

## Installation
Expand Down Expand Up @@ -36,8 +42,11 @@ theia help

## Usage

To see the list of available commands and options, run `theia help`. Currently,
we have 5 commands for the NetworkPolicy Recommendation feature:
To see the list of available commands and options, run `theia help`.

### NetworkPolicy Recommendation feature

We currently have 5 commands for NetworkPolicy Recommendation:

- `theia policy-recommendation run`
- `theia policy-recommendation status`
Expand All @@ -47,3 +56,81 @@ we have 5 commands for the NetworkPolicy Recommendation feature:

For details, please refer to [NetworkPolicy recommendation doc](
networkpolicy-recommendation.md)

### ClickHouse

From Theia v0.2, we introduce one command for ClickHouse:

- `theia clickhouse status [flags]`

#### Disk usage information

The `--diskInfo` flag will list disk usage information of each clickhouse shard. `Shard`, `DatabaseName`, `Path`, `Free`
, `Total` and `Used_Percentage`of each clickhouse shard will be displayed in table format. For example:

```bash
> theia clickhouse status --diskInfo
Shard DatabaseName Path Free Total Used_Percentage
1 default /var/lib/clickhouse/ 1.84 GiB 1.84 GiB 0.04 %
```

#### Table Information

The `--tableInfo` flag will list basic table information of each clickhouse shard. `Shard`, `DatabaseName`, `TableName`,
`TotalRows`, `TotalBytes` and `TotalCol`of tables in each clickhouse shard will be displayed in table format. For example:

```bash
> theia clickhouse status --tableInfo
Shard DatabaseName TableName TotalRows TotalBytes TotalCols
1 default .inner.flows_node_view 7 2.84 KiB 16
1 default .inner.flows_pod_view 131 5.00 KiB 20
1 default .inner.flows_policy_view 131 6.28 KiB 27
1 default flows 267 18.36 KiB 49
1 default flows_node_view
1 default flows_pod_view
1 default flows_policy_view
1 default recommendations 0 0.00 B 4
```

#### Insertion rate

The `--insertRate` flag will list the insertion rate of each clickhouse shard. `Shard`, `RowsPerSecond`, and
`BytesPerSecond` of each clickhouse shard will be displayed in table format. For example:

```bash
> theia clickhouse status --insertRate
Shard RowsPerSecond BytesPerSecond
1 230 6.31 KiB
```

#### Stack trace

If ClickHouse is busy with something, and you don’t know what’s happening, you can check the stacktraces of all
the thread which are working.

The `--stackTraces` flag will list the stacktraces of each clickhouse shard. `Shard`, `trace_function`, and
`count()` of each clickhouse shard will be displayed in table format. For example:

```bash
> theia clickhouse status --stackTraces
Row 1:
-------
Shard: 1
trace_functions: pthread_cond_timedwait@@GLIBC_2.3.2\nPoco::EventImpl::waitImpl(long)\nPoco::NotificationQueue::
waitDequeueNotification(long)\nDB::BackgroundSchedulePool::threadFunction()\n\nThreadPoolImpl<std::__1::thread>::
worker(std::__1::__list_iterator<std::__1::thread, void*>)\n\nstart_thread\n__clone
count(): 128

Row 2:
-------
Shard: 1
trace_functions: __poll\nPoco::Net::SocketImpl::pollImpl(Poco::Timespan&, int)\nPoco::Net::SocketImpl::poll(Poco::
Timespan const&, int)\nPoco::Net::TCPServer::run()\nPoco::ThreadImpl::runnableEntry(void*)\nstart_thread\n__clone
count(): 5
```






6 changes: 0 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/containernetworking/plugins v0.8.7
github.com/google/uuid v1.1.2
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
github.com/olekukonko/tablewriter v0.0.4
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.0
Expand Down Expand Up @@ -54,11 +53,6 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.0 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down Expand Up @@ -477,8 +476,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down Expand Up @@ -538,7 +535,6 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -643,7 +639,6 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
Expand Down Expand Up @@ -677,6 +672,10 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/ti-mo/conntrack v0.4.0/go.mod h1:L0vkIzG/TECsuVYMMlID9QWmZQLjyP9gDq8XKTlbg4Q=
github.com/ti-mo/netfilter v0.3.1/go.mod h1:t/5HvCCHA1LAYj/AZF2fWcJ23BQTA7lzTPCuwwi7xQY=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,33 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package clickhouse
package commands

import (
"fmt"

"github.com/spf13/cobra"

"antrea.io/theia/pkg/theia/commands/clickhouse/status"
)

var ClickHouseCmd = &cobra.Command{
var clickHouseCmd = &cobra.Command{
Use: "clickhouse",
Aliases: []string{"ch"},
Short: "Commands of Theia ClickHouse feature",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Error: must also specify a subcommand to run")
fmt.Println("Error: must also specify a subcommand to run like status")
},
}

func init() {
ClickHouseCmd.AddCommand(status.Command)
rootCmd.AddCommand(clickHouseCmd)
clickHouseCmd.PersistentFlags().String(
"clickhouse-endpoint",
"",
"The ClickHouse service endpoint.")
clickHouseCmd.PersistentFlags().Bool(
"use-cluster-ip",
false,
`Enable this option will use ClusterIP instead of port forwarding when connecting to the ClickHouse Service.
It can only be used when running in cluster.`,
)
}
Loading

0 comments on commit ffa2b41

Please sign in to comment.