Bug 1230581 - Shouldn't update resource label with empty or invalid value
Summary: Shouldn't update resource label with empty or invalid value
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.0.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-11 08:05 UTC by DeShuai Ma
Modified: 2015-08-03 20:17 UTC (History)
7 users (show)

Fixed In Version: openshift-3.0.1.0-0.git.133.b1c1f03.el7ose.x86_64.rpm
Doc Type: Bug Fix
Doc Text:
Previously using the CLI, labels could be set to empty values, and setting labels to invalid values produced an unfriendly error. This bug fix updates the CLI to no longer allow setting labels to empty values, and setting labels to invalid values produces a better error message.
Clone Of:
Environment:
Last Closed: 2015-08-03 20:17:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1540 0 normal SHIPPED_LIVE Red Hat OpenShift Enterprise 3.0.1.0 bug fix and enhancement update 2015-08-04 00:17:18 UTC

Description DeShuai Ma 2015-06-11 08:05:31 UTC
Description of problem:
In online this bug is fixed, https://bugzilla.redhat.com/show_bug.cgi?id=1223252
1.when use "oc 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-0.6.0.0-0.git.55.733cf86.el7ose.x86_64
openshift-master-0.6.0.0-0.git.55.733cf86.el7ose.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a pod
# oc create -f hello-openshift/hello-pod.json

2. Update the pod label with empty value.
# oc label pods hello-openshift status=

3. Add label with invalid value
# oc label pods hello-openshift status=$%@#

4.Check the pod label info
[root@dhcp-128-7 examples]# oc describe pod hello-openshift
Name:				hello-openshift
Image(s):			openshift/hello-openshift
Host:				minion2.cluster.local/10.14.6.141
Labels:				name=hello-openshift,status=
Status:				Running
Replication Controllers:	<none>
Containers:
  hello-openshift:
    Image:		openshift/hello-openshift
    State:		Running
      Started:		Thu, 11 Jun 2015 15:36:40 +0800
    Ready:		True
    Restart Count:	0

Actual results:
2.Update the label successfully
# oc label pods hello-openshift status=
NAME              READY     REASON    RESTARTS   AGE
hello-openshift   1/1       Running   0          1m

3.# oc label pods hello-openshift status=$%@#
Error from server: Pod "hello-openshift" 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
3.When use invalid value, the tip should be friendly.

Additional info:

Comment 2 Fabiano Franz 2015-06-11 17:21:34 UTC
Putting on MODIFIED, will be fixed in the next OSE branch.

Comment 3 DeShuai Ma 2015-06-12 07:22:26 UTC
In the latest ose env, can't fix this issue. Waiting for the next OSE branch.

Comment 4 DeShuai Ma 2015-06-15 08:29:44 UTC
Test on latest ose env again. Still have this issue.
[root@dhcp-128-7 sample-app]# oc version
oc v0.6.0.1-78-g1c816ed
kubernetes v0.17.1-804-g496be63

openshift master version:
openshift-master-0.6.0.1-0.git.78.1c816ed.el7ose.x86_64

Step:
1. Set the label with empty value.
[root@dhcp-128-7 sample-app]# oc label pods database-1-deploy status= -n dma1
NAME                READY     REASON    RESTARTS   AGE
database-1-deploy   1/1       Running   0          2h
2. Check the lavel
[root@dhcp-128-7 sample-app]# oc describe pods database-1-deploy -n dma1
Name:				database-1-deploy
Image(s):			registry.access.redhat.com/openshift3/ose-deployer:v0.6.0.1
Host:				minion2.cluster.local/10.14.6.134
Labels:				openshift.io/deployer-pod-for.name=database-1,status=
Status:				Running
IP:				10.1.1.19
Replication Controllers:	<none>
Containers:
  deployment:
    Image:		registry.access.redhat.com/openshift3/ose-deployer:v0.6.0.1
    State:		Running
      Started:		Mon, 15 Jun 2015 13:49:13 +0800
    Ready:		True
    Restart Count:	0
Conditions:
  Type		Status
  Ready 	True 
No events.

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

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

Comment 7 DeShuai Ma 2015-06-30 07:56:40 UTC
This is a bug about ose not origin bug. We should merge the pull request to ose code repo too, not just only on origin.

[root@master tmp]# rpm -qa|grep openshift
openshift-3.0.0.1-1.git.4.eab4c86.el7ose.x86_64
tuned-profiles-openshift-node-3.0.0.1-1.git.4.eab4c86.el7ose.x86_64
openshift-master-3.0.0.1-1.git.4.eab4c86.el7ose.x86_64
openshift-node-3.0.0.1-1.git.4.eab4c86.el7ose.x86_64
openshift-sdn-ovs-3.0.0.1-1.git.4.eab4c86.el7ose.x86_64


1. Set label with empty value.
[root@master tmp]# oc label pods hello-openshift status= -n dma1
NAME              READY     REASON    RESTARTS   AGE
hello-openshift   1/1       Running   0          54s

2. Set label with invalid value.
[root@master tmp]# oc label pods hello-openshift color=%$#@ -n dma1
Error from server: Pod "hello-openshift" is invalid: [metadata.labels: invalid value '%0@': 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 '%0@': must have at most 63 characters, matching regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?: e.g. "MyValue" or ""]

Comment 8 Scott Dodson 2015-07-08 19:25:42 UTC
The referenced pull request is in openshift-3.0.1.0-0.git.133.b1c1f03.el7ose.x86_64.rpm

Puddle: http://buildvm-devops.usersys.redhat.com/puddle/build/OpenShiftEnterprise/3.0/2015-07-07.1/RH7-RHOSE-3.0/x86_64/os/

Comment 10 DeShuai Ma 2015-07-09 02:04:44 UTC
Test on ose env. this bug is fixed.
Version:
openshift-3.0.1.0-0.git.133.b1c1f03.el7ose.x86_64
openshift-master-3.0.1.0-0.git.133.b1c1f03.el7ose.x86_64

Steps:
[root@master tmp]# oc label pods hello-openshift status= -n dma1
error: invalid label spec: status=
see 'oc label -h' for help.
[root@master tmp]# oc label pods hello-openshift status=$%@#
error: invalid label spec: status=$%!@(MISSING)#
see 'oc label -h' for help.

Comment 12 errata-xmlrpc 2015-08-03 20:17:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2015:1540


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