Bug 1223252 - [origin_devexp_553]Shouldn't update resource label with empty or invalid value
Summary: [origin_devexp_553]Shouldn't update resource label with empty or invalid value
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: Yan Du
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-20 08:37 UTC by DeShuai Ma
Modified: 2015-07-07 23:47 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-07-07 23:47:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description DeShuai Ma 2015-05-20 08:37:14 UTC
Description of problem:
1.when use "osc lable" command to update resource label with empty value, it can success. But when use this label to filter the resource, it tip the label invalid. So we shouldn't update resource label with empty value.
2.When use invalid characters as the label value, the tip should be friendly.

Version-Release number of selected component (if applicable):
openshift v0.5.1-230-g8bbf71f
kubernetes v0.17.0-441-g6b6b47a
devenv-fedora_1572 (ami-0c213864)

How reproducible:
Always

Steps to Reproduce:
1.Get the service under a namespace
$ osc get service -n test
NAME       LABELS                                          SELECTOR        IP(S)            PORT(S)
database   template=application-template-stibuild   name=database   172.30.247.87    5434/TCP

2.Add label with empty value for service
$ osc label service database color= -n test

3.Use the empty label to filter the resource
$ osc get service -l color= -n test
the provided selector "color=" is not valid: unable to parse requiremnt: found '', expected: identifier

4.Add label with empty value for service
$ osc label service database testlable=@#$% -n test

Actual results:
2.Update the label successfully
$ osc label service database color= -n test
NAME       LABELS                                          SELECTOR        IP(S)           PORT(S)
database   color=,template=application-template-stibuild   name=database   172.30.247.87   5434/TCP

3.$ osc get service -l color= -n test
the provided selector "color=" is not valid: unable to parse requiremnt: found '', expected: identifier

4.$ osc label service database testlable=@#$% -n test
Error from server: service "database" is invalid: [metadata.labels: invalid value '@#$%': must have at most 63 characters, matching regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?: e.g. "MyValue" or "", metadata.labels: invalid value '@#$%': must have at most 63 characters, matching regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?: e.g. "MyValue" or ""]

Expected results:
2.Can't update label with empty value
4.When use invalid value, the tip should be friendly.

Additional info:

Comment 1 openshift-github-bot 2015-05-26 12:20:42 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/50a64d912dd08ec9e0da18fe6ec81e4e7f95346d
Bug 1223252: UPSTREAM: label: Invalidate empty or invalid value labels

Comment 2 DeShuai Ma 2015-05-27 01:49:02 UTC
Test on devenv-fedora_1626. This bug is fixed.
1. Add label with empty value.
$ osc label service database color= -n test
error: invalid label spec: color=
see 'osc label -h' for help.
2.Add label with invalid value.
$ osc label service database testlable=@#$% -n test
error: invalid label spec: testlable=@#$%!(NOVERB)
see 'osc label -h' for help.

Comment 3 Fabiano Franz 2015-06-15 23:07:34 UTC
Fixed in https://github.com/openshift/origin/pull/3200

Comment 4 openshift-github-bot 2015-06-27 04:20:34 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/19f85548a34addccc7ff99bc5491018382281639
Bug 1223252: UPSTREAM: label: Invalidate empty or invalid value labels

Comment 5 Fabiano Franz 2015-06-29 14:41:21 UTC
Fixed in https://github.com/openshift/origin/pull/3200

Comment 6 DeShuai Ma 2015-06-30 01:45:51 UTC
Test on devenv-fedora_1896. verify this bug.
1.Set label with empty value.
[fedora@ip-10-138-107-235 examples]$ oc label pod hello-openshift color= -n dma1
error: invalid label spec: color=
see 'oc label -h' for help.

2.Set label with invalid value.
[fedora@ip-10-138-107-235 examples]$ oc label pod hello-openshift testlable=@#$% -n dma1
error: invalid label spec: testlable=@#$%!(NOVERB)
see 'oc label -h' for help.


Note You need to log in before you can comment on or make changes to this bug.