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

Fix(cli): avoid incorrect addon name when using dot as local addon path #4126

Merged
merged 8 commits into from
Jun 9, 2022

Conversation

charlie0129
Copy link
Member

Signed-off-by: Charlie Chiang charlie_c_0129@outlook.com

Description of your changes

When we use . to enable local addons, cli will use . as the addon name to print endpoints, which will cause errors.
Example: vela addon enable . or vela addon enable ./some/path/.

Notice the last three (or five) lines. (. is used as addon name, and addon-. invalid labels)

$ vela addon enable .
enable addon by local dir: . 
I0607 22:14:37.470277  705624 apply.go:107] "creating object" name="canary-rollout" resource="core.oam.dev/v1beta1, Kind=WorkflowStepDefinition"
I0607 22:14:37.535854  705624 apply.go:107] "creating object" name="istio-gateway" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:14:37.597845  705624 apply.go:107] "creating object" name="canary-rollback" resource="core.oam.dev/v1beta1, Kind=WorkflowStepDefinition"
I0607 22:14:37.659132  705624 apply.go:107] "creating object" name="canary-traffic" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:14:37.721066  705624 apply.go:107] "creating object" name="istio-destinationrule" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:14:37.787186  705624 apply.go:107] "creating object" name="istio-vs" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:14:37.849421  705624 apply.go:107] "creating object" name="addon-secret-istio" resource="/v1, Kind=Secret"
Addon: . enabled Successfully.
Please access the . from the following endpoints:
I0607 22:14:38.091826  705624 utils.go:156] find cluster gateway service vela-system/kubevela-cluster-gateway-service:9443
E0607 22:14:38.210538  705624 task.go:238] "do steps" err="step resources: run step(provider=query,do=collectServiceEndpoints): unable to parse requirement: values[0][app.oam.dev/name]: Invalid value: \"addon-.\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')" step_name="service-endpoints-view-status" step_type="service-endpoints-view" spanID="i-rkb7duwf"
Get application endpoints error: failed to query the view step resources: run step(provider=query,do=collectServiceEndpoints): unable to parse requirement: values[0][app.oam.dev/name]: Invalid value: "addon-.": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

This has been fixed by correctly finding out directory name. (Also fixed some typos.)

$ vela addon enable .
enable addon by local dir: . 
I0607 22:37:17.553323  751092 apply.go:107] "patching object" name="canary-rollout" resource="core.oam.dev/v1beta1, Kind=WorkflowStepDefinition"
I0607 22:37:17.617073  751092 apply.go:107] "patching object" name="istio-gateway" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:37:17.682554  751092 apply.go:107] "patching object" name="canary-rollback" resource="core.oam.dev/v1beta1, Kind=WorkflowStepDefinition"
I0607 22:37:17.746558  751092 apply.go:107] "patching object" name="canary-traffic" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:37:17.812260  751092 apply.go:107] "patching object" name="istio-destinationrule" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:37:17.881306  751092 apply.go:107] "patching object" name="istio-vs" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0607 22:37:17.945046  751092 apply.go:107] "patching object" name="addon-secret-istio" resource="/v1, Kind=Secret"
Addon istio enabled successfully.
Please access the istio from the following endpoints:
I0607 22:37:18.267096  751092 utils.go:156] find cluster gateway service vela-system/kubevela-cluster-gateway-service:9443
+---------+-----------+-------------------------------------------+------------------------+
| CLUSTER | COMPONENT |         REF(KIND/NAMESPACE/NAME)          |        ENDPOINT        |
+---------+-----------+-------------------------------------------+------------------------+
| local   | istio     | Service/istio-system/istio-ingressgateway | 123.57.xxx.xxx:15021   |
| local   | istio     | Service/istio-system/istio-ingressgateway | http://123.57.xxx.xxx  |
| local   | istio     | Service/istio-system/istio-ingressgateway | https://123.57.xxx.xxx |
+---------+-----------+-------------------------------------------+------------------------+

I have:

  • Read and followed KubeVela's contribution process.
  • Related Docs updated properly. In a new feature or configuration option, an update to the documentation is necessary.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

e2e tests have been added

Special notes for your reviewer

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
@charlie0129 charlie0129 changed the title Fix(cli): avoid issues when using dot as local addon path Fix(cli): avoid incorrect addon name when using dot as local addon path Jun 7, 2022
@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #4126 (37ded02) into master (910cb50) will increase coverage by 1.50%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4126      +/-   ##
==========================================
+ Coverage   58.69%   60.19%   +1.50%     
==========================================
  Files         330      330              
  Lines       31789    31789              
==========================================
+ Hits        18657    19136     +479     
+ Misses      10619    10149     -470     
+ Partials     2513     2504       -9     
Flag Coverage Δ
apiserver-unittests 35.43% <ø> (-0.01%) ⬇️
core-unittests 54.62% <ø> (-0.08%) ⬇️
e2e-multicluster-test 20.09% <ø> (+0.09%) ⬆️
e2e-rollout-tests 22.34% <ø> (ø)
e2etests 29.21% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/addon/registry.go 37.34% <0.00%> (-15.67%) ⬇️
...kg/apiserver/interfaces/api/assembler/v1/do2dto.go 58.86% <0.00%> (-6.39%) ⬇️
pkg/addon/helper.go 67.70% <0.00%> (-1.57%) ⬇️
pkg/apiserver/domain/service/authentication.go 49.07% <0.00%> (-1.12%) ⬇️
pkg/addon/utils.go 69.90% <0.00%> (-0.98%) ⬇️
...es/policydefinition/policydefinition_controller.go 64.21% <0.00%> (ø)
pkg/apiserver/domain/service/addon.go 59.42% <0.00%> (+0.72%) ⬆️
pkg/resourcekeeper/gc.go 77.35% <0.00%> (+0.94%) ⬆️
pkg/resourcetracker/app.go 88.88% <0.00%> (+1.01%) ⬆️
pkg/cue/model/sets/utils.go 80.85% <0.00%> (+1.06%) ⬆️
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 910cb50...37ded02. Read the comment docs.

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
e2e/addon/addon_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@wonderflow wonderflow left a comment

Choose a reason for hiding this comment

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

great job!

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
@charlie0129 charlie0129 marked this pull request as draft June 8, 2022 05:25
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
@charlie0129 charlie0129 marked this pull request as ready for review June 8, 2022 08:24
Copy link
Collaborator

@wangyikewxgm wangyikewxgm left a comment

Choose a reason for hiding this comment

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

LGTM

references/cli/addon.go Outdated Show resolved Hide resolved
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

Co-authored-by: Zheng Xi Zhou <zzxwill@gmail.com>
@StevenLeiZhang
Copy link
Collaborator

It is better to squash the 8 commits

@wonderflow
Copy link
Collaborator

It is better to squash the 8 commits

Approver can merge with squash

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.

None yet

5 participants