Bug 1876535 - Instantiation of templates gives no positive (on success) or negative (on instantiation failure) feedback to user
Summary: Instantiation of templates gives no positive (on success) or negative (on ins...
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Dev Console
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.7.0
Assignee: cvogt
QA Contact: Gajanan More
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-07 12:27 UTC by Andreas Karis
Modified: 2020-11-23 21:52 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-23 21:52:58 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Andreas Karis 2020-09-07 12:27:38 UTC
Description of problem:

Instantiation of templates gives no positive (on success) or negative (on instantiation failure) feedback to user
For example, if a template's rendered resource contains a typo and cannot be applied, or if creation of a resource is not allowed

Connect to the console

Version-Release number of selected component (if applicable):
4.4
4.5

How reproducible:


Steps to Reproduce:

0. All under the "default" project (but it's the same under other projects)

1. Create the following templates:
~~~
cat <<'EOF' | oc apply -f -
apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: deployment-template-working
  annotations:
    description: "Create a new deployment from image"
objects:
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: ${IMAGE_NAME}-deployment
    labels:
      app: ${IMAGE_NAME}-deployment
  spec:
    replicas: ${{DEPLOYMENT_SCALE}}
    selector:
      matchLabels:
        app: ${IMAGE_NAME}-pod
    template:
      metadata:
        labels:
          app: ${IMAGE_NAME}-pod
      spec:
        containers:
        - name: ${IMAGE_NAME}
          image: ${IMAGE_NAME}
          command:
            - sleep
            - infinity
          imagePullPolicy: IfNotPresent
parameters:
- description: Image name - sets image to pull and also sets the deployment and pod name
  required: true
  name: IMAGE_NAME
- description: Image name - sets image to pull and also sets the deployment and pod name
  from: '[1-3]{1}'
  generate: expression
  name: DEPLOYMENT_SCALE
EOF

cat <<'EOF' | oc apply -f -
apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: deployment-template-failing
  annotations:
    description: "Create a new deployment from image"
objects:
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: ${IMAGE_NAME}-deployment
    labels:
      app: ${IMAGE_NAME}-deployment
  spec:
    replicas: ${DEPLOYMENT_SCALE}
    selector:
      matchLabels:
        app: ${IMAGE_NAME}-pod
    template:
      metadata:
        labels:
          app: ${IMAGE_NAME}-pod
      spec:
        containers:
        - name: ${IMAGE_NAME}
          image: ${IMAGE_NAME}
          command:
            - sleep
            - infinity
          imagePullPolicy: IfNotPresent
parameters:
- description: Image name - sets image to pull and also sets the deployment and pod name
  required: true
  name: IMAGE_NAME
- description: Image name - sets image to pull and also sets the deployment and pod name
  from: '[1-3]{1}'
  generate: expression
  name: DEPLOYMENT_SCALE
EOF

cat <<'EOF' | oc apply -f -
apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: namespace-template
  annotations:
    description: "Create a new namespace"
objects:
- apiVersion: project.openshift.io/v1
  description: "${SERVICE_NAME}"
  displayName: "${SERVICE_NAME}"
  kind: ProjectRequest
  metadata:
    name: ${SERVICE_NAME}
parameters:
- description: Service name - will set a namespace from it - must be the same than your gitlab repository
  from: '[A-Za-z\_\-]{60}'
  generate: expression
  name: SERVICE_NAME
EOF
~~~

~~~
[akaris@linux aws-env]$ oc get templates
NAME                          DESCRIPTION                          PARAMETERS        OBJECTS
deployment-template-failing   Create a new deployment from image   2 (1 blank)       1
deployment-template-working   Create a new deployment from image   2 (1 blank)       1
namespace-template            Create a new namespace               1 (1 generated)   1
~~~

2. Instantiate the templates via CLI:
~~~
[akaris@linux aws-env]$ oc process deployment-template-working IMAGE_NAME=ubuntu DEPLOYMENT_SCALE=2  | oc create -f -
deployment.apps/ubuntu-deployment created
[akaris@linux aws-env]$ oc process deployment-template-failing IMAGE_NAME=fedora DEPLOYMENT_SCALE=2  | oc create -f -
Error from server (BadRequest): Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Replicas: readUint32: unexpected character: �, error found in #10 byte of ...|eplicas":"2","select|..., bigger context ...|yment","namespace":"default"},"spec":{"replicas":"2","selector":{"matchLabels":{"app":"fedora-pod"}}|...
[akaris@linux aws-env]$ oc process namespace-template SERVICE_NAME=test | oc apply -f -
project.project.openshift.io/test created
~~~

Verify:
~~~
[akaris@linux aws-env]$ oc projects | grep test
    test
[akaris@linux aws-env]$ 
[akaris@linux aws-env]$ 
[akaris@linux aws-env]$ oc delete project test
project.project.openshift.io "test" deleted
~~~

~~~
[akaris@linux aws-env]$ oc delete project test
project.project.openshift.io "test" deleted
[akaris@linux aws-env]$ oc get deployments
NAME                READY   UP-TO-DATE   AVAILABLE   AGE
ubuntu-deployment   2/2     2            2           2m27s
[akaris@linux aws-env]$ oc delete deployment ubuntu-deployment
deployment.apps "ubuntu-deployment" deleted
[akaris@linux aws-env]$ 
~~~

Up to here, everything as expected.

3. Go to the developer console, "Add": under $URL/add/ns/default
   Select "From Catalog": under $URL/catalog/ns/default
   Filter for "namespace-template": under $URL/catalog/ns/default?keyword=namespace-template
   Click on the item and select "Instantiate template": under $URL/catalog/instantiate-template?template=namespace-template&template-ns=default&preselected-ns=default
   Under "SERVIE_NAME", type "test" and then click "Create"
   You will be dropped back to "Topology" with  message:
---
Topology
No workloads found

To add content to your project, create an application, component or service using one of these options.
---
   No new namespace will be created. No message to the user about why this did not work.

   Repeat the steps for deployment-template-working: under $URL/catalog/ns/default?keyword=deployment-template-working
   Click on "Instantiate template": under $URL/catalog/instantiate-template?template=deployment-template-working&template-ns=default&preselected-ns=default
   Under IMAGE_NAME: "ubuntu" and under DEPLOYMENT_SCALE: 2
   Click "Create". You will be dropped at the "Deployment" view under: $URL/topology/ns/default/graph
   And the deployment is created

   Repeat the steps for deployment-template-failing: under $URL/catalog/ns/default?keyword=deployment-template-failing
   Click on "Instantiate template": under $URL/catalog/instantiate-template?template=deployment-template-failing&template-ns=default&preselected-ns=default
   Under IMAGE_NAME: "fedora" and under DEPLOYMENT_SCALE: 2
   Click "Create". You will be dropped at the "Deployment" view under: $URL/topology/ns/default/graph
   The deployment will not be created, nothing happens

Actual results:

See above


Expected results:

An error message.  For deployment-template-failing, the same message as from the CLI should be reported to the end user via the GUI
~~~
akaris@linux aws-env]$ oc process deployment-template-failing IMAGE_NAME=fedora DEPLOYMENT_SCALE=2  | oc create -f -
Error from server (BadRequest): Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Replicas: readUint32: unexpected character: �, error found in #10 byte of ...|eplicas":"2","select|..., bigger context ...|yment","namespace":"default"},"spec":{"replicas":"2","selector":{"matchLabels":{"app":"fedora-pod"}}|...
~~~

For the namespace-template, we must relay an error message to the user, too.

Additional info:

Comment 1 Andreas Karis 2020-09-07 12:48:25 UTC
One can see all template instances and their errors:

Just for visibility in my lab, do not run this in a prod environment in case you might delete something important:
~~~
oc delete templateinstances --all
~~~

~~~
$ oc get templateinstances
No resources found in default namespace.
~~~

I then repeated these steps:

3. Go to the developer console, "Add": under $URL/add/ns/default
   Select "From Catalog": under $URL/catalog/ns/default
   Filter for "namespace-template": under $URL/catalog/ns/default?keyword=namespace-template
   Click on the item and select "Instantiate template": under $URL/catalog/instantiate-template?template=namespace-template&template-ns=default&preselected-ns=default
   Under "SERVIE_NAME", type "test" and then click "Create"
   You will be dropped back to "Topology" with  message:
---
Topology
No workloads found

To add content to your project, create an application, component or service using one of these options.
---
   No new namespace will be created. No message to the user about why this did not work.

   Repeat the steps for deployment-template-working: under $URL/catalog/ns/default?keyword=deployment-template-working
   Click on "Instantiate template": under $URL/catalog/instantiate-template?template=deployment-template-working&template-ns=default&preselected-ns=default
   Under IMAGE_NAME: "ubuntu" and under DEPLOYMENT_SCALE: 2
   Click "Create". You will be dropped at the "Deployment" view under: $URL/topology/ns/default/graph
   And the deployment is created

   Repeat the steps for deployment-template-failing: under $URL/catalog/ns/default?keyword=deployment-template-failing
   Click on "Instantiate template": under $URL/catalog/instantiate-template?template=deployment-template-failing&template-ns=default&preselected-ns=default
   Under IMAGE_NAME: "fedora" and under DEPLOYMENT_SCALE: 2
   Click "Create". You will be dropped at the "Deployment" view under: $URL/topology/ns/default/graph
   The deployment will not be created, nothing happens



~~~
[akaris@linux aws-env]$ oc get templateinstances
NAME                                TEMPLATE
deployment-template-failing-tcrbj   deployment-template-failing
deployment-template-working-m7lxz   deployment-template-working
namespace-template-8cbmn            namespace-template
[akaris@linux aws-env]$ oc describe templateinstances deployment-template-failing-tcrbj
Name:		deployment-template-failing-tcrbj
Namespace:	default
Created:	25 seconds ago
Labels:		<none>
Annotations:	<none>

Conditions:		 
    Type:		InstantiateFailure
    Status:		True
    LastTransitionTime:	2020-09-07 14:45:57 +0200 CEST
    Reason:		Failed
    Message:		Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Replicas: readUint32: unexpected character: �, error found in #10 byte of ...|eplicas":"2","select|..., bigger context ...|},"name":"fedora-deployment"},"spec":{"replicas":"2","selector":{"matchLabels":{"app":"fedora-pod"}}|...


Objects:	 

Parameters:		 
    IMAGE_NAME:		6 bytes
    DEPLOYMENT_SCALE:	1 bytes

[akaris@linux aws-env]$ oc describe templateinstances deployment-template-working-m7lxz
Name:		deployment-template-working-m7lxz
Namespace:	default
Created:	52 seconds ago
Labels:		<none>
Annotations:	<none>

Conditions:		 
    Type:		Ready
    Status:		True
    LastTransitionTime:	2020-09-07 14:45:43 +0200 CEST
    Reason:		Created
    Message:		<none>


Objects:	 
    Deployment:	default/ubuntu-deployment

Parameters:		 
    IMAGE_NAME:		6 bytes
    DEPLOYMENT_SCALE:	1 bytes

[akaris@linux aws-env]$ oc describe templateinstances namespace-template-8cbmn
Name:		namespace-template-8cbmn
Namespace:	default
Created:	About a minute ago
Labels:		<none>
Annotations:	<none>

Conditions:		 
    Type:		InstantiateFailure
    Status:		True
    LastTransitionTime:	2020-09-07 14:45:27 +0200 CEST
    Reason:		Failed
    Message:		projectrequests.project.openshift.io is forbidden: User "system:serviceaccount:openshift-infra:template-instance-controller" cannot create resource "projectrequests" in API group "project.openshift.io" at the cluster scope


Objects:	 

Parameters:		 
    SERVICE_NAME:	4 bytes
~~~

The point is that the GUI / developer console should not just silently fail. It should report the above InstantiateFailures to the user via the web developer console.

Comment 4 Andrew Ballantyne 2020-11-23 21:52:58 UTC
Closing this in favour of an RFE https://issues.redhat.com/browse/RFE-1423

This functionality will be properly supported in a future release and not something as a bug for 4.7. Please see the RFE ticket for more status updates, closing out this BZ based on request of PM.


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