Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1691460 - start-build fails when buildconfig name 63 character is non alphanumeric
Summary: start-build fails when buildconfig name 63 character is non alphanumeric
Keywords:
Status: NEW
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 3.9.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 3.9.z
Assignee: Adam Kaplan
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-21 16:15 UTC by Alberto Gonzalez de Dios
Modified: 2019-03-22 07:01 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:


Attachments (Terms of Use)

Description Alberto Gonzalez de Dios 2019-03-21 16:15:13 UTC
Description of problem:
When starting a build from a buildconfig (oc start-build), Openshift automatically creates the labels "buildconfig" and "openshift.io/build-config.name". If the buildconfig name has more than 63 characters, it truncates the name to 63 characters, and set this truncate name as the value of the labels "buildconfig" and "openshift.io/build-config.name". This is done because k8s labes cannot have more than 63 characters [1].

This works well, except when the 63 character of the name is a non-alphanumeric, because the build fails, as label cannot end with a non-alphanumeric.

The process to set the labels buildconfig and openshift.io/build-config.name should also check if last characters is non-alphanumeric. If it's not alphanumeric, it should truncate one more character and check again.

[1] https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ 

Version-Release number of selected component (if applicable):
3.9, 3.10, 3.11

How reproducible:
Create a buildconfig with a name of more than 63 characters, being the 63 character a non-alphanumeric character (for example, a "-").

Steps to Reproduce:
1. Create a test project
$ oc new-project build-test

2. Create a builconfig with a name of more than 63 characters, being the 63 character a non-alphanumeric (i.e. a "-"):
oc create -f - <<EOF
 apiVersion: v1
 kind: BuildConfig
 metadata:
   creationTimestamp: null
   labels:
     app: tst-personal-strategies-services
   name: tst-personal-strategies-services-asa-tests-order-async-service-pipeline
 spec:
   nodeSelector: null
   output: {}
   postCommit: {}
   resources: {}
   runPolicy: Serial
   source:
     type: None
   strategy:
     jenkinsPipelineStrategy:
       jenkinsfile: |-
         def app
     type: JenkinsPipeline
   triggers: []
 status:
   lastVersion: 0
EOF

buildconfig.build.openshift.io "tst-personal-strategies-services-asa-tests-order-async-service-pipeline" created

3. Start build:
$ oc start-build tst-personal-strategies-services-asa-tests-order-async-service-pipeline
The Build "tst-personal-strategies-services-asa-tests-order-async-service-pipeline-1" is invalid: metadata.labels: Invalid value: "tst-personal-strategies-services-asa-tests-order-async-service-": 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])?')


Actual results:
The Build "tst-personal-strategies-services-asa-tests-order-async-service-pipeline-1" is invalid: metadata.labels: Invalid value: "tst-personal-strategies-services-asa-tests-order-async-service-": 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])?')

Expected results:
Build successful. If replace "tst-personal-strategies-services-asa-tests-order-async-service-pipeline" to "tst-personal-strategies-services-asa-tests-order-async-servicepipeline":

buildconfig.build.openshift.io "tst-personal-strategies-services-asa-tests-order-async-servicepipeline" created
$ oc start-build tst-personal-strategies-services-asa-tests-order-async-servicepipeline
build "tst-personal-strategies-services-asa-tests-order-async-servicepipeline-1" started


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