Bug 1454535

Summary: modifying project name in template doesn't work
Product: OpenShift Container Platform Reporter: Kenjiro Nakayama <knakayam>
Component: MasterAssignee: Michal Fojtik <mfojtik>
Status: CLOSED ERRATA QA Contact: Wang Haoran <haowang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.4.1CC: aos-bugs, erich, geliu, jforrest, jokerman, mfojtik, mmccomas, pweil, wewang
Target Milestone: ---Flags: knakayam: needinfo? (mfojtik)
Target Release: 3.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Creating project using project template does not use the substituted project name, but the namespace name. Consequence: Not able to use parametrized name as a project name as the generated suffix or prefix might be dropped. Fix: Use the substituted project name when creating the namespace. Result:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-28 21:55:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Kenjiro Nakayama 2017-05-23 01:06:07 UTC
Description of problem:
- We would like to create prefix namespace with requester name.
- The background of this request is that OCP's project/namespace has to be unique. But there are no good way to create the project uniquely atm. 

Version-Release number of selected component (if applicable):
- OCP 3.4

How reproducible:
- 100%

Steps to Reproduce:
1. Modify template like https://docs.openshift.com/container-platform/3.4/admin_guide/managing_projects.html#modifying-the-template-for-new-projects
(e.g)
~~~
  metadata:
    name: ${PROJECT_NAME}-${PROJECT_REQUESTING_USER}
~~~

Actual results:
- Failed to create the project.

  ]$ oc new-project aaa
  Error from server: Internal error occurred: namespaces "aaa" not found

Expected results:
- Create the project with requester name suffix.


Additional info:
- According to Jordan's internal mail, it was possible in previous version(?)

  http://post-office.corp.redhat.com/archives/openshift-sme/2016-September/msg01441.html
(However, as far as I tested on OCP 3.4, it doesn't work).

Comment 1 Michal Fojtik 2017-05-25 10:41:22 UTC
I think there are couple problems here:

1) Using the ${PROJECT_REQUESTING_USER} only for the project name won't work unless you do the same everywhere where ${PROJECT_NAME} parameter is used in the template (iow. RoleBindings, etc.)

2) https://github.com/openshift/origin/pull/14344 this has to be fixed

3) there is a bug in `new-project` that prevents the newly created project to be set.

Comment 2 openshift-github-bot 2017-05-27 02:01:57 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/96e068b56c1432cdcdf55895dcd22f37124df0eb
Bug 1454535 - Use created project name over namespace name in project template

Comment 8 ge liu 2017-06-05 07:54:19 UTC
Verified in OCP env:

openshift v3.6.94
kubernetes v1.6.1+5115d708d7
etcd 3.1.0

Steps:
1. login OCP cluster, and working as system:admin user
2. #oadm create-bootstrap-project-template -o yaml > template.yaml
3. Edit template.yaml:

     replace ALL  "name: ${PROJECT_NAME}" to "name: ${PROJECT_NAME}-lg", pay attention all items, but not project metadate name only.

4. modify master-config.yaml: projectRequestTemplate: "default/project-request"  and restart master service

5. # oc new-project ccc --description=lala1
6. # oc get project
NAME               DISPLAY NAME   STATUS
ccc-lg                            Active

Comment 9 wewang 2017-06-05 09:08:46 UTC
verified in 
openshift v3.6.94
kubernetes v1.6.1+5115d708d7
etcd 3.1.0
oc v3.6.94

[root@dhcp-128-91 Downloads]# ./usr/share/atomic-openshift/linux/oc  new-project wewang
Now using project "wewang-wewang" on server "https://host-xxxx:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.

Comment 19 errata-xmlrpc 2017-11-28 21:55:46 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/RHSA-2017:3188