openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)
https://openyurt.io
Apache License 2.0
1.68k stars 391 forks source link

feat: add yurtappset validation webhook and default nodepool label #1997

Closed vie-serendipity closed 3 months ago

vie-serendipity commented 3 months ago

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line: /kind bug /kind documentation /kind enhancement /kind good-first-issue /kind feature /kind question /kind design /sig ai /sig iot /sig network /sig storage

/kind feature

What this PR does / why we need it:

  1. Add yurtappset validation webhook
  2. Support {{nodepool-name}} for batch modifying
  3. Support statefulset

    Which issue(s) this PR fixes:

    Fixes #

    1966

    1969

    1970

    Special notes for your reviewer:

Does this PR introduce a user-facing change?

other Note

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 58.11966% with 98 lines in your changes are missing coverage. Please review.

Project coverage is 54.71%. Comparing base (3194f0b) to head (29920a4). Report is 2 commits behind head on master.

Files Patch % Lines
...ebhook/yurtappset/v1beta1/yurtappset_validation.go 46.03% 30 Missing and 4 partials :warning:
.../yurtappset/workloadmanager/statefulset_manager.go 60.49% 18 Missing and 14 partials :warning:
...er/controller/yurtappset/workloadmanager/tweaks.go 71.92% 9 Missing and 7 partials :warning:
...ger/controller/yurtappset/yurtappset_controller.go 25.00% 7 Missing and 2 partials :warning:
pkg/yurtmanager/controller/yurtappset/revision.go 60.00% 1 Missing and 3 partials :warning:
...r/yurtappset/workloadmanager/deployment_manager.go 60.00% 0 Missing and 2 partials :warning:
...r/webhook/yurtappset/v1beta1/yurtappset_handler.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1997 +/- ## ========================================== + Coverage 53.06% 54.71% +1.64% ========================================== Files 176 177 +1 Lines 21000 17271 -3729 ========================================== - Hits 11144 9450 -1694 + Misses 8902 6849 -2053 - Partials 954 972 +18 ``` | [Flag](https://app.codecov.io/gh/openyurtio/openyurt/pull/1997/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/openyurtio/openyurt/pull/1997/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | `54.71% <58.11%> (+1.64%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

vie-serendipity commented 3 months ago

/rerun

rambohe-ch commented 3 months ago

@vie-serendipity Thanks for posting pull request. A lot of files from kubernetes are imported, how about import k8s.io/kubernetes directly? it seems that we can avoid importing k8s.io/kubernetes directly.

vie-serendipity commented 3 months ago

/rerun

vie-serendipity commented 3 months ago

Error: Codecov: Failed to properly upload: The process '/home/runner/work/_actions/codecov/codecov-action/v3/dist/codecov' failed with exit code 255 It seems codecov encounter some problems. @rambohe-ch

rambohe-ch commented 3 months ago

@vie-serendipity please fix the following unit test error:

=== RUN TestDefault/nodepool_has_pool_type nodepool_default_test.go:111: expect &v1beta1.NodePool{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"foo", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), DeletionTimestamp:, DeletionGracePeriodSeconds:(int64)(nil), Labels:map[string]string{"nodepool.openyurt.io/type":"Cloud"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:v1beta1.NodePoolSpec{Type:"Cloud", HostNetwork:true, Labels:map[string]string(nil), Annotations:map[string]string(nil), Taints:[]v1.Taint(nil)}, Status:v1beta1.NodePoolStatus{ReadyNodeNum:0, UnreadyNodeNum:0, Nodes:[]string{}}}, got &v1beta1.NodePool{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"foo", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), DeletionTimestamp:, DeletionGracePeriodSeconds:(int64)(nil), Labels:map[string]string{"nodepool.openyurt.io/type":"cloud"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:v1beta1.NodePoolSpec{Type:"Cloud", HostNetwork:true, Labels:map[string]string(nil), Annotations:map[string]string(nil), Taints:[]v1.Taint(nil)}, Status:v1beta1.NodePoolStatus{ReadyNodeNum:0, UnreadyNodeNum:0, Nodes:[]string{}}} --- FAIL: TestDefault (0.00s) --- PASS: TestDefault/it_is_not_a_nodepool (0.00s) --- FAIL: TestDefault/nodepool_has_no_type (0.00s) --- FAIL: TestDefault/nodepool_has_pool_type (0.00s)

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

rambohe-ch commented 3 months ago

/lgtm

rambohe-ch commented 4 weeks ago

Fixes #1970