-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add list and delete commands in policy recommendation CLI #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
policyRecommendationListCmd.Flags().Bool( | ||
"use-cluster-ip", | ||
false, | ||
`Enable this option will use Service ClusterIP instead of port forwarding when connecting to the ClickHouse service. | ||
It can only be used when running theia in cluster.`, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether it would be better to put this into global flags, as I think up to now all commands requires this flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both clickhouse-endpoint
and use-cluster-ip
might be added to glabal flags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Yanjun and Yuntang, yes there are some duplicates here, but status
command uses use-cluster-ip
only and is used for Spark Monitoring Service
instead of ClickHouse Service
in other commands.
Ultimately, I think the connection to Spark Monitoring Service
and ClickHouse Service
should be handled by the middle layer app theia manager. We could remove these flags then imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for ClickHouse service, we also need these two flags in order to setup clickhouse connection? Currently, I add these two flags when using theia clickhouse status
in PR #59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our theia pr status
command, we're fetching status from k8s api server and spark monitoring service, that's why it doesn't need to connect with clickhouse for now.
But I also realize that we could improve the status
command to let it can check completed jobs inside clickhouse only. In that case, all commands needs connection with clickhouse, I plan to create a separate PR for this improvement of status
command first.
docs/networkpolicy-recommendation.md
Outdated
The `theia policy-recommendation delete` command is used to delete a policy | ||
recommendation job. To delete the policy recommendation job created above, run: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice there is a rare case that if users try to delete a job before the driver pod is created, the job may still keep running till completion. And users will receive a message saying the job is successfully deleted. Not sure if we should deal with this case by returning another message or doc it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Yanjun, I have seen this corner case too during e2e test. In that case, the sparkapplication
cr has been deleted successfully but the deriver/exec pods will still be created later, maybe I should create an issue in the spark operator repo to hear their solutions.
Not introduced by this PR, I just recall previously there is a discussion on replacing the empty state string when we get a NewState by running |
No problem, I will take care of it. |
a4220e6
to
9fe60a8
Compare
Signed-off-by: Yongming Ding <dyongming@vmware.com>
11671a6
to
5bb4129
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
/theia-test-e2e |
docs/networkpolicy-recommendation.md
Outdated
@@ -36,17 +38,21 @@ CLI. `theia` is the command-line tool which provides access to Theia network | |||
flow visibility capabilities. To get more information about `theia`, please | |||
refer to its [user guide](theia-cli.md). | |||
|
|||
There are 3 `theia` commands for the NetworkPolicy Recommendation feature: | |||
There are 5 `theia` commands for the NetworkPolicy Recommendation feature: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's easier if we stop numbering them...
Something like
The following theia
commands for .... are available
} | ||
_, err = uuid.Parse(recoID) | ||
if err != nil { | ||
return fmt.Errorf("failed to decode input id %s into a UUID, err: %v", recoID, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider: "Input id ... does not seem a valid uuid, parsing error: ..."
if endpoint != "" { | ||
_, err := url.ParseRequestURI(endpoint) | ||
if err != nil { | ||
return fmt.Errorf("failed to decode input endpoint %s into a url, err: %v", endpoint, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as above)
Consider: "Input endpoint ... does not seem a valid URL, parsing error: ...."
if endpoint != "" { | ||
_, err := url.ParseRequestURI(endpoint) | ||
if err != nil { | ||
return fmt.Errorf("failed to decode input endpoint %s into a url, err: %v", endpoint, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above about endpoint parsing (not sure if we can have some utility functions to avoid code duplication for parsing parameters which are used by multiple commands)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, add two utility functions for parsing ID and endpoint.
} | ||
|
||
sparkApplicationTable := [][]string{ | ||
{"CreateTime", "CompleteTime", "ID", "Status"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using "CompletionTime" instead of "CompleteTime"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, to be consistent, I'm changing to use CreationTime
and CompletionTime
.
if err != nil { | ||
return err | ||
} | ||
query := "ALTER TABLE recommendations DELETE WHERE id = (?);" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it a clickhouse peculiarity that we need to use ALTER TABLE for deleting records?
Does DELETE FROM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Clickhouse doesn't have Update/Delete commands like Mysql database, reference doc: https://clickhouse.com/docs/en/sql-reference/statements/alter/delete/
Signed-off-by: Yongming Ding <dyongming@vmware.com>
/theia-test-e2e |
Fix #49
Signed-off-by: Yongming Ding dyongming@vmware.com