Bug 1276564 - oc export will convert the file to v1 version when set --output-version to an invalid value
oc export will convert the file to v1 version when set --output-version to an...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
3.x
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: Juan Vallejo
Yan Du
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-30 03:20 EDT by Yan Du
Modified: 2016-12-09 16:51 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-12-09 16:51:33 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Yan Du 2015-10-30 03:20:30 EDT
Description of problem:
oc export will convert the file to v1 version when set --output-version to an invalid value


Version-Release number of selected component (if applicable):
oc v3.0.2.903-114-g2849767
kubernetes v1.2.0-alpha.1-1107-g4c8e6f4


How reproducible:
Always


Steps to Reproduce:
1. Convert the v1 version file to an non-exist version
# oc export -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/deployment/deployment1v1beta3.json  -o json --output-version=invalid



Acutal results:

The oc export cmd will convert the file to v1 version by default with any warning message.

$ oc export -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/deployment/deployment1v1beta3.json  -o json --output-version=invalid
{
    "kind": "DeploymentConfig",
    "apiVersion": "v1",
    "metadata": {
        "name": "hooks",
        "creationTimestamp": null,
        "labels": {
            "name": "mysql"
<--------------------snip------------------------>



Expected results:

It is better to inform user that the out-version is not valid.
Comment 1 Xingxing Xia 2015-12-02 04:39:57 EST
Hmm, "oc get" also has this problem with "--output-version" given invalid value.
Comment 2 Juan Vallejo 2016-10-05 18:18:51 EDT
Related PR: https://github.com/openshift/origin/pull/11239
Comment 3 Juan Vallejo 2016-10-06 14:51:40 EDT
Updated PR to glog an info message any time versioned objects fail to be converted to the version specified: https://github.com/openshift/origin/pull/11239
Comment 4 Yan Du 2016-11-08 21:33:01 EST
Test on latest origin, still not show any warning info when --output-version set to invalid 

# oc version
oc v1.4.0-alpha.1+64f88d7-121
kubernetes v1.4.0+776c994

[root@ip-172-18-11-67 ~]# oc get pod -o yaml --output-version=invalid
apiVersion: v1
items:
- apiVersion: v1
  kind: Pod
  metadata:
    annotations:
      openshift.io/scc: anyuid
    creationTimestamp: 2016-11-09T02:27:36Z
    labels:
      name: hello-pod
    name: hello-pod
    namespace: default
    resourceVersion: "509"
    selfLink: /api/v1/namespaces/default/pods/hello-pod
    uid: 1434ae69-a624-11e6-b9f5-0ee10c50d580
  spec:
    containers:
    - image: bmeng/hello-openshift
      imagePullPolicy: Always
      name: hello-pod
      resources: {}
      securityContext:
        capabilities:
          drop:
          - MKNOD
          - SYS_CHROOT
        privileged: false
        seLinuxOptions:
          level: s0:c5,c0
      terminationMessagePath: /dev/termination-log
      volumeMounts:
      - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
        name: default-token-qflf6
        readOnly: true
    dnsPolicy: ClusterFirst
    imagePullSecrets:
    - name: default-dockercfg-fcebv
    nodeName: ip-172-18-11-67.ec2.internal
    restartPolicy: Always
    securityContext:
      seLinuxOptions:
        level: s0:c5,c0
    serviceAccount: default
    serviceAccountName: default
    terminationGracePeriodSeconds: 30
    volumes:
    - name: default-token-qflf6
      secret:
        defaultMode: 420
        secretName: default-token-qflf6
  status:
    conditions:
    - lastProbeTime: null
      lastTransitionTime: 2016-11-09T02:27:36Z
      status: "True"
      type: Initialized
    - lastProbeTime: null
      lastTransitionTime: 2016-11-09T02:27:36Z
      message: 'containers with unready status: [hello-pod]'
      reason: ContainersNotReady
      status: "False"
      type: Ready
    - lastProbeTime: null
      lastTransitionTime: 2016-11-09T02:27:36Z
      status: "True"
      type: PodScheduled
    containerStatuses:
    - image: bmeng/hello-openshift
      imageID: ""
      lastState: {}
      name: hello-pod
      ready: false
      restartCount: 0
      state:
        waiting:
          reason: ContainerCreating
    hostIP: 172.18.11.67
    phase: Pending
    startTime: 2016-11-09T02:27:36Z
kind: List
metadata: {}
Comment 5 Juan Vallejo 2016-11-09 09:39:14 EST
yadu@redhat.com sorry about the confusion. The warning is printed in `--loglevel=1` or greater. Tried the command below and worked as expected:

```
$ oc get pod idling-echo-1-2x8kx -o yaml --output-version=invalid --loglevel=1 | head
I1109 09:36:44.589247    2926 result.go:241]  info: the output version specified is invalid. Defaulting to "v1"
apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/created-by: |
      {"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationController","namespace":"default","name":"idling-echo-1","uid":"8225fcde-a601-11e6-a78d-507b9dac96e1","apiVersion":"v1","resourceVersion":"71806"}}
    openshift.io/deployment-config.latest-version: "1"
    openshift.io/deployment-config.name: idling-echo
    openshift.io/deployment.name: idling-echo-1
    openshift.io/scc: restricted
```
Comment 6 Juan Vallejo 2016-11-09 09:39:56 EST
(In reply to Juan Vallejo from comment #5)
> yadu@redhat.com sorry about the confusion. The warning is printed in
> `--loglevel=1` or greater. Tried the command below and worked as expected:
> 
> ```
> $ oc get pod idling-echo-1-2x8kx -o yaml --output-version=invalid
> --loglevel=1 | head
> I1109 09:36:44.589247    2926 result.go:241]  info: the output version
> specified is invalid. Defaulting to "v1"
> apiVersion: v1
> kind: Pod
> metadata:
>   annotations:
>     kubernetes.io/created-by: |
>      
> {"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":
> "ReplicationController","namespace":"default","name":"idling-echo-1","uid":
> "8225fcde-a601-11e6-a78d-507b9dac96e1","apiVersion":"v1","resourceVersion":
> "71806"}}
>     openshift.io/deployment-config.latest-version: "1"
>     openshift.io/deployment-config.name: idling-echo
>     openshift.io/deployment.name: idling-echo-1
>     openshift.io/scc: restricted
> ```

# oc version

oc v1.3.0-rc1+a24ab26-1350-dirty
kubernetes v1.4.0+776c994
features: Basic-Auth

Server https://10.13.137.149:8443
openshift v1.3.0-rc1
kubernetes v1.3.0+52492b4
Comment 7 Yan Du 2016-11-10 02:18:14 EST
Issue have been fixed. Move bug to verified. Thanks!

# oc get pod -o yaml --output-version=invalid --loglevel=1 | head
I1110 15:17:12.196785    8923 result.go:241]  info: the output version specified is invalid. Defaulting to "v1"

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