Bug 1455115

Summary: oc run valid image by dry run flag raises mess error
Product: OpenShift Container Platform Reporter: XiaochuanWang <xiaocwan>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.6.0CC: agoldste, aos-bugs, jokerman, jvallejo, mfojtik, mmccomas, pweil, wmeng
Target Milestone: ---   
Target Release: 3.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-28 21:56:17 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:
Embargoed:

Description XiaochuanWang 2017-05-24 10:02:21 UTC
Description of problem:
This is failed with mess error output "oc run mysql --image=mysql --dry-run"
This is succeed "oc run mysql --image=mysql "

Version-Release number of selected component (if applicable):
oc v3.6.76
kubernetes v1.6.1+5115d708d7

How reproducible:
Always

Steps to Reproduce:
1. # oc run mysql --image=mysql 
2. # oc run mysql --image=mysql --dry-run

Actual results:
2. # oc run mysql --image=mysql --dry-run
NAME      KIND
error: unknown type &v1.DeploymentConfig{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"mysql", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{sec:0, nsec:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string{"run":"mysql"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:""}, Spec:v1.DeploymentConfigSpec{Strategy:v1.DeploymentStrategy{Type:"", CustomParams:(*v1.CustomDeploymentStrategyParams)(nil), RecreateParams:(*v1.RecreateDeploymentStrategyParams)(nil), RollingParams:(*v1.RollingDeploymentStrategyParams)(nil), Resources:v1.ResourceRequirements{Limits:v1.ResourceList(nil), Requests:v1.ResourceList(nil)}, Labels:map[string]string(nil), Annotations:map[string]string(nil), ActiveDeadlineSeconds:(*int64)(nil)}, MinReadySeconds:0, Triggers:v1.DeploymentTriggerPolicies(nil), Replicas:1, RevisionHistoryLimit:(*int32)(nil), Test:false, Paused:false, Selector:map[string]string{"run":"mysql"}, Template:(*v1.PodTemplateSpec)(0xc4204b1680)}, Status:v1.DeploymentConfigStatus{LatestVersion:0, ObservedGeneration:0, Replicas:0, UpdatedReplicas:0, AvailableReplicas:0, UnavailableReplicas:0, Details:(*v1.DeploymentDetails)(nil), Conditions:[]v1.DeploymentCondition(nil), ReadyReplicas:0}}

Expected results:
Step 3 should be succeed without error.

Additional info:

Comment 1 Michal Fojtik 2017-05-30 09:58:58 UTC
[@dev] .../openshift/origin # oc run mysql --image=mysql --dry-run
NAME      REVISION   DESIRED   CURRENT   TRIGGERED BY
mysql     0          1         0

What is the server version?

Comment 2 Tomáš Nožička 2017-06-07 14:10:22 UTC
I can reproduce it and also with kubectl.

There is a bug when selecting a printer with dry-run. It select a wrong printer and that doesn't have a handler for generated types. I am working on a fix.

Comment 3 Tomáš Nožička 2017-06-12 11:00:16 UTC
As it showed this is because printers have real issues with objects in multiple versions (v1, v1beta, ...). This was caused by last rebase to upstream. Waiting for upstream decision here: https://github.com/kubernetes/kubernetes/issues/47180

Comment 4 Tomáš Nožička 2017-06-28 07:14:11 UTC
As this is a problem with HumanReadablPrinter the easiest workaround is to use '-o yaml'

oc run mysql --image=mysql --dry-run -o yaml

Comment 7 Juan Vallejo 2017-08-29 18:29:06 UTC
It appears that there are already changes in the upstream humanreadable printer to handle the case seen in this bug without outputting a lengthy error [1].

These changes will be brought in with the next rebase. Closing PRs from comment 6, and tagging this bug as UpcomginRelease

1. https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L331

Comment 8 Juan Vallejo 2017-10-16 19:30:10 UTC
Picked patch from upstream [1] that adds the changes mentioned in comment 7 [2]

1. https://github.com/kubernetes/kubernetes/commit/6bd0c38908daed2d4e59a3b2540d3f0564f87068

2. https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L331

This patch should fix the output of any resource without a custom printer handler by adding a default printer handler that prints object metadata as a fallback.

Example:

```
$ oc run mysql --image=mysql --dry-run -o yaml
NAME      AGE
mysql     <unknown>
```

Comment 9 Juan Vallejo 2017-10-16 19:30:26 UTC
Origin PR: https://github.com/openshift/origin/pull/16892

Comment 11 XiaochuanWang 2017-10-23 02:43:08 UTC
$ oc run mysql --image=mysql --dry-run
NAME      AGE
mysql     <unknown>


Verified on OCP: oc v3.7.0-0.174.0

Comment 14 errata-xmlrpc 2017-11-28 21:56:17 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