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

Modify clickhouse statistic related func for theia-manager #132

Merged
merged 4 commits into from
Dec 1, 2022

Conversation

yuntanghsu
Copy link
Contributor

@yuntanghsu yuntanghsu commented Oct 24, 2022

This PR modifies and adds the clickhouse statistic related functions for Theia Manager:

  1. Define REST request and return payload struct for related API endpoints and add code generation under pkg/apis/stats
    a. REST endpoint apis/stats.theia.antrea.io/v1alpha1/clickhouse
  2. Adapt CLI to use Theia Manager
  3. Modify e2e test

The changes are split into two chunks (to hopefully help make reviews easier), with one commit focusing on adding status API, another one implementing the CLI changes and modifying the e2e test,

Signed-off-by: Yun-Tang Hsu [email protected]

@yuntanghsu yuntanghsu marked this pull request as draft October 24, 2022 18:04
@yuntanghsu
Copy link
Contributor Author

/theia-test-e2e

@yuntanghsu yuntanghsu force-pushed the clickhouse_status branch 4 times, most recently from 4017672 to 07468bc Compare October 25, 2022 20:31
@yuntanghsu
Copy link
Contributor Author

/theia-test-e2e

@yuntanghsu yuntanghsu marked this pull request as ready for review October 26, 2022 18:05
@yuntanghsu yuntanghsu added this to the Theia v0.4 release milestone Oct 26, 2022
Copy link
Contributor

@wsquan171 wsquan171 left a comment

Choose a reason for hiding this comment

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

overall lgtm. some nits.

pkg/util/utils.go Outdated Show resolved Hide resolved
pkg/controller/stats/controller.go Outdated Show resolved Hide resolved
pkg/controller/stats/controller.go Outdated Show resolved Hide resolved
pkg/apis/stats/v1alpha1/types.go Outdated Show resolved Hide resolved
@yuntanghsu yuntanghsu force-pushed the clickhouse_status branch 3 times, most recently from 5df9906 to a1c7d59 Compare November 17, 2022 22:15
Copy link
Contributor

@wsquan171 wsquan171 left a comment

Choose a reason for hiding this comment

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

LGTM. one simple nit.

pkg/apis/stats/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/controller/stats/clickhouse_stats.go Outdated Show resolved Hide resolved
pkg/util/utils.go Outdated Show resolved Hide resolved
@@ -0,0 +1,115 @@
// Copyright 2022 Antrea Authors.
Copy link
Contributor

@yanjunz97 yanjunz97 Nov 21, 2022

Choose a reason for hiding this comment

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

I also tried to move some utility functions to the common pkg in PR #138 . I think most of the functions are similar and the later merged PR can fix the conflicts, but I would like to get some feedbacks about if we prefer to put all these functions in one file like this one, or classify them into multiple pkgs like clickhouse, policyrecommendation, k8s as I do in PR #138

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have strong opinion regarding this, but I might prefer classifying them into multiple pkgs.

pkg/apis/stats/v1alpha1/types.go Outdated Show resolved Hide resolved
@yuntanghsu yuntanghsu force-pushed the clickhouse_status branch 2 times, most recently from 8f9232e to ea35d5c Compare November 28, 2022 22:35
Signed-off-by: Yun-Tang Hsu <[email protected]>
@yuntanghsu yuntanghsu force-pushed the clickhouse_status branch 4 times, most recently from 4769b15 to cded8f6 Compare November 29, 2022 03:50
@yuntanghsu
Copy link
Contributor Author

/theia-test-e2e

Copy link
Contributor

@salv-orlando salv-orlando left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just some nits inline

@@ -339,7 +339,7 @@ function deliver_antrea {

${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1 > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --no-grafana --spark-operator --theia-manager > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility-with-spark.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --no-grafana > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility-ch-only.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --no-grafana --theia-manager > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility-ch-only.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

were we lacking theia manager in the manifests we use for testing before this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We previously added theia manager at line #341 for NPR related functions in CLI. Line #342 is for the clickhouse related changes in this PR.

pkg/apiserver/utils/stats/clickhouse_stats.go Show resolved Hide resolved
pkg/apiserver/utils/stats/clickhouse_stats.go Show resolved Hide resolved
stats.StackTraces = append(stats.StackTraces, res)
}
if err != nil {
return fmt.Errorf("failed to parse the data returned by database: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just to make a little less ignorant... can this query return multiple rows?

In that case, would it better to skip and move to the next record if we fail to parse a record?

Copy link
Contributor Author

@yuntanghsu yuntanghsu Nov 30, 2022

Choose a reason for hiding this comment

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

The query returns multiple rows.
I think it is a good idea to skip the error row instead of throwing away the whole data?

cc @yanjunz97 and @wsquan171 for some feedbacks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree to skip the error row. It would be better if we could display the results retrieved successfully and the error regarding to the error row at the same 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.

I added a ErrorMsg, which is a []string, in ClickHouseStats. If we have an error row, we will skip it and add the error msg to ErrorMsg. On CLI side, it will show both ErrorMsgs and the results.

Copy link
Contributor

Choose a reason for hiding this comment

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

The new approach looks good to me.

Signed-off-by: Yun-Tang Hsu <[email protected]>
Copy link
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

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

LGTM

@yuntanghsu
Copy link
Contributor Author

/theia-test-e2e

@yuntanghsu yuntanghsu merged commit b6c1c1f into antrea-io:main Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants