-
Notifications
You must be signed in to change notification settings - Fork 89
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
When the branch name of devop is Chinese, an error will be reported #104
Comments
/cc @kubesphere/sig-devops |
/kind bug |
/area devops |
hi @yyt6200 thanks for reporting this issue to us. |
you are welcome . |
/milestone v3.2 |
The is the log output from the backend. │ devops-apiserver-5456ddd748-l6r4s I1015 07:42:44.592849 1 apiserver.go:295] 10.42.0.50 - "GET /v1alpha3/namespaces/testbfbp5/pipelines/multi-branch-g ││ it-footrapid/pipelineruns?page=1&limit=10&branch=%E6%B5%8B%E8%AF%95%E5%88%86%E6%94%AF&backward=false HTTP/1.1" 500 352 0ms ││ devops-apiserver-5456ddd748-l6r4s E1015 07:42:48.576139 1 utils.go:76] /workspace/pkg/kapis/devops/v1alpha3/pipelinerun/handler.go:58 invalid label v ││ alue: "测试分支": at key: "devops.kubesphere.io/scm-ref-name": 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- ││ _.[]*)?[A-Za-z0-9])?') Here are some clues. Please check it if you are interested to help us to fix it:
/good-first-issue |
@LinuxSuRen: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign |
hi @mangoGoForward, good to see that you are interested in this issue. Please don't hesitate to contact us if you have any questions about this. |
OK, Thank you for your advice, I will try to solve this issue. |
I have some questions, can you help me? @LinuxSuRen
|
|
How about randomly generate a valid string for the branch name when it is invalid, and add a label in |
Hi @mangoGoForward , I have a better solution here for reference. Because the branch name dose not always meet the naming requirements of label value, I don't recommend putting the branch name on the label. ks-devops/pkg/kapis/devops/v1alpha3/pipelinerun/handler.go Lines 65 to 70 in e20f3ba
When we query PipelineRuns, function But by default, Kubernetes only a few field selector are supported. So we need to create a custom indexer for branch name. I will put critical code here:
if err := o.cache.IndexField(context.Background(), &v1alpha3.PipelineRun{}, "scm_ref_name", func(o runtime.Object) []string {
pipelineRun, ok := o.(*v1alpha3.PipelineRun)
if !ok || pipelineRun.Spec.SCM == nil {
return []string{""}
}
return []string{pipelineRun.Spec.SCM.RefName}
}); err != nil {
klog.Errorf("failed to create index field (branch) for PipelineRun, err = %v", err)
}
if err := h.client.List(context.Background(), &prs,
client.InNamespace(pipeline.Namespace),
client.MatchingLabelsSelector{Selector: labelSelector},
client.MatchingFields{
"scm_ref_name": branchName,
}); err != nil {
api.HandleError(request, response, err)
return
}
ks-devops/controllers/jenkins/pipelinerun/pipelinerun_controller.go Lines 114 to 116 in e20f3ba
|
this branch name is '测试分支',click this branch,the ks is report error.
My running environment is as follows:
kubernets:1.9.10
kubesphere:3.1.0
The text was updated successfully, but these errors were encountered: