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

Switch traceflow CRD validation to webhook validation. #5230

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

shi0rik0
Copy link
Contributor

Currently, the traceflow CRD validation is executed in run-time, which is less user-friendly than the webhook validation. I moved most of the validation to the webhook validation.

Some of the validations in Agent is unchanged because they need the information of the Agent. Also, I found the current validation is insufficient, but I left the improvement as a future work.

pkg/controller/traceflow/validate.go Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
pkg/apiserver/apiserver.go Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
@shi0rik0 shi0rik0 requested a review from luolanzone July 12, 2023 06:38
@shi0rik0
Copy link
Contributor Author

shi0rik0 commented Jul 12, 2023

git pull --rebase upstream main polluted the comparision. Please compare commit a6aa6d9 with ec9d9ba

https://github.com/antrea-io/antrea/compare/ec9d9ba520bcc54b23001f55fa991e381ef468b0..a6aa6d9d03ca2f8fb90500690ab8c22f368f08c9

pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
@shi0rik0 shi0rik0 requested a review from tnqn July 12, 2023 12:21
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate_test.go Outdated Show resolved Hide resolved
pkg/controller/traceflow/validate.go Show resolved Hide resolved
@shi0rik0 shi0rik0 requested a review from tnqn July 13, 2023 04:10
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM. However, conflicts need to be resolved.

@tnqn
Copy link
Member

tnqn commented Jul 17, 2023

LGTM. However, conflicts need to be resolved.

Ignore it, I mistook other message as conflicts.

tnqn
tnqn previously approved these changes Jul 17, 2023
@tnqn tnqn added the action/release-note Indicates a PR that should be included in release notes. label Jul 17, 2023
@tnqn
Copy link
Member

tnqn commented Jul 17, 2023

Several unit tests and e2e tests failed. Their expectations should be updated according to the change.

@shi0rik0
Copy link
Contributor Author

shi0rik0 commented Jul 17, 2023

I've removed outdated unit tests. Interestingly, the unit test "timeoutHostnetworkTraceflow" in pkg/controller/traceflow/controller_test.go seems to be wrong before this patch. The timeout in the test case is 2 secs, so we need to wait for at least 2 secs to get the Failed status. I don't know why originally the test case can be passed.

@shi0rik0 shi0rik0 requested a review from tnqn July 17, 2023 13:15
@shi0rik0
Copy link
Contributor Author

shi0rik0 commented Jul 17, 2023

There's still a failed test in "Go / Unit test (windows-2019)", but this failure seems to have nothing to do with this patch?

https://github.com/antrea-io/antrea/actions/runs/5576066018/attempts/2?pr=523

Update: the test is OK again on another try. Related to issue #5261.

@tnqn
Copy link
Member

tnqn commented Jul 18, 2023

I've removed outdated unit tests. Interestingly, the unit test "timeoutHostnetworkTraceflow" in pkg/controller/traceflow/controller_test.go seems to be wrong before this patch. The timeout in the test case is 2 secs, so we need to wait for at least 2 secs to get the Failed status. I don't know why originally the test case can be passed.

It's correct before the patch. It can fail immediately once it finds out the source Pod is in hostnetwork, instead of waiting 2s. Since you removed the source Pod hostnetwork check in it, it then waits until timeout, which is actually the same as the timeoutTraceflow, and it's no longer a possible use case. I think it should be removed.

@luolanzone luolanzone requested a review from gran-vmv July 18, 2023 02:16
@shi0rik0
Copy link
Contributor Author

I've removed outdated unit tests. Interestingly, the unit test "timeoutHostnetworkTraceflow" in pkg/controller/traceflow/controller_test.go seems to be wrong before this patch. The timeout in the test case is 2 secs, so we need to wait for at least 2 secs to get the Failed status. I don't know why originally the test case can be passed.

It's correct before the patch. It can fail immediately once it finds out the source Pod is in hostnetwork, instead of waiting 2s. Since you removed the source Pod hostnetwork check in it, it then waits until timeout, which is actually the same as the timeoutTraceflow, and it's no longer a possible use case. I think it should be removed.

I've removed it.

@shi0rik0 shi0rik0 requested a review from luolanzone July 18, 2023 02:59
@gran-vmv
Copy link
Contributor

/test-e2e

@shi0rik0 shi0rik0 force-pushed the tf-webhook-valid branch 2 times, most recently from 0d1a2d4 to ccbbb7a Compare July 18, 2023 08:32
@shi0rik0 shi0rik0 changed the title Switch traceflow CRD validation to webhook validation. [WIP] Switch traceflow CRD validation to webhook validation. Jul 18, 2023
@shi0rik0 shi0rik0 force-pushed the tf-webhook-valid branch 2 times, most recently from 20d2833 to d2d0699 Compare July 19, 2023 00:34
@shi0rik0 shi0rik0 changed the title [WIP] Switch traceflow CRD validation to webhook validation. Switch traceflow CRD validation to webhook validation. Jul 19, 2023
@shi0rik0 shi0rik0 requested a review from gran-vmv July 19, 2023 06:04
gran-vmv
gran-vmv previously approved these changes Jul 19, 2023
Copy link
Contributor

@gran-vmv gran-vmv left a comment

Choose a reason for hiding this comment

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

LGTM

@luolanzone
Copy link
Contributor

@shi0rik0 please help to resolve code conflicts.

@shi0rik0
Copy link
Contributor Author

Sorry for the late reply. The conflicts are caused by the Traceflow API version promotion. I've solved the conflicts. There's a failed e2e test, but this seems to be not related to this PR because recent PRs also have this failure (#5380). @luolanzone

tnqn
tnqn previously approved these changes Aug 15, 2023
Copy link
Member

@tnqn tnqn 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 nit

test/e2e/traceflow_test.go Outdated Show resolved Hide resolved
Currently, the traceflow CRD validation is executed in run-time, which is less
user-friendly than the webhook validation. I moved most of the validation to
the webhook validation.

Signed-off-by: shi0rik0 <anguuan@outlook.com>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Aug 16, 2023

/test-all

1 similar comment
@shi0rik0
Copy link
Contributor Author

/test-all

@tnqn tnqn merged commit faf8fb3 into antrea-io:main Aug 21, 2023
@antoninbas
Copy link
Contributor

This PR broke e2e tests on IPv6-only clusters, as the new e2e test assumes that Pods always have a valid IPv4 address. I have opened a PR to fix it: #5415

When doing any non-trivial change to e2e Traceflow tests, it's probably a good idea to always run IPv6-only and dual-stack e2e test jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants