Bug 1210206 - [origin_platformexp_389]Could not update namespace/status and pods/status successfully using cluster-admin
Summary: [origin_platformexp_389]Could not update namespace/status and pods/status suc...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Containers
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: David Eads
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-09 07:42 UTC by Wei Sun
Modified: 2015-07-07 23:45 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-07-07 23:45:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Wei Sun 2015-04-09 07:42:48 UTC
Description of problem:
Change the namespace's status or pod's status in json file,and update the namespace or pod,but failed.

Version-Release number of selected component (if applicable):
openshift v0.4.3-28-g00cad79
kubernetes v0.13.1-dev-641-gf057a25

How reproducible:
Always

Steps to Reproduce:
1.Create a project
2.List the namespace
3.List a single namespace in JSON output format and save it to a file
4.Update the namespace's status in json file (
Active-> Terminating)
5.Update the namespace using `osc update -f $file.json`
6.List the namespace

Actual results:
2.[fedora@ip-10-142-233-92 sample-app]$ osc get namespaces/test
NAME                LABELS              STATUS
test                <none>              Active
5.[fedora@ip-10-142-233-92 sample-app]$ osc update -f namespace.json 
namespaces/test

6.The namespace's status still is Active

Expected results:

The namespace's status should be Terminating

Additional info:
[fedora@ip-10-142-233-92 sample-app]$ cat namespace.json 
{
    "kind": "Namespace",
    "id": "test",
    "uid": "324c4300-de62-11e4-90c5-22000bd408da",
    "creationTimestamp": "2015-04-09T02:43:25Z",
    "selfLink": "/api/v1beta1/namespaces/test",
    "resourceVersion": 8736,
    "apiVersion": "v1beta1",
    "annotations": {
        "description": "This is an example project to demonstrate OpenShift v3",
        "displayname": "OpenShift 3 Sample"
    },
    "spec": {
        "finalizers": [
            "openshift.com/project",
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Terminating"
    }
}

Comment 1 David Eads 2015-04-09 12:17:15 UTC
osadm new-project --config=openshift.local.certificates/admin/.kubeconfig test --admin=david
osc login --insecure-skip-tls-verify --server=https://localhost:8443 --username=david --password=eads

osc get namespaces/test
NAME                LABELS              STATUS
test                <none>              Active


osc config view --config=~/.config/openshift/openshiftconfig
(get token)

curl -XPUT -k -d @namespace.json -H "Authorization:Bearer NGQzZDA0ZDYtMTYyMy00NGFlLTkwNDgtYjFiNjE5YWRkMmMy" https://localhost:8443/osapi/v1beta1/projects/test/status
(forbidden message)

osc login --username=root --password=r

osadm policy add-role-to-user --config=openshift.local.certificates/admin/.kubeconfig cluster-admin root --namespace=master

osc config view --config=~/.config/openshift/openshiftconfig
(get root token)

curl -XPUT -k -d @namespace.json -H "Authorization:Bearer YjFiY2UxNjgtOWYzYy00ZDM3LWE0ZmEtNWRiMzhkODkwMTBh" https://localhost:8443/osapi/v1beta1/projects/test/status
404.  Root is allowed to do the update, but it seems that we're not proxying the status through :(.  

I would say use namespace instead, but in going through the example with namespace instead of pod, I hit this problem: https://github.com/openshift/origin/issues/1665.

Comment 2 David Eads 2015-04-17 17:35:49 UTC
Subresources on namespaces are now considered to be resources in their own right.  That means namespace/status is not resource=namespace and subresource=status, but rather resource=status.  Because of this, you'll have to run the example with a different subresource.

See: https://github.com/openshift/origin/pull/1788.

Comment 3 Wei Sun 2015-04-20 05:58:42 UTC
Verified on devenv_fedora_1305
Now could update pod status successfully

step:
1.
[fedora@ip-10-111-183-39 sample-app]$ osc get pods/frontend-1-9uxqn
POD                IP           CONTAINER(S)      IMAGE(S)                                                                                                      HOST                                          LABELS                                                                                                 STATUS    CREATED
frontend-1-9uxqn   172.17.0.9   ruby-helloworld   172.30.185.16:5000/test/origin-ruby-sample:34baa2e765c43d7be462f20abf6c3efec62805487be875186a4cfb8fdf835676   ip-10-111-183-39.ec2.internal/10.111.183.39   deployment=frontend-1,deploymentconfig=frontend,name=frontend,template=application-template-stibuild   Running   7 minutes


2.
[fedora@ip-10-111-183-39 sample-app]$ osc get pods/frontend-1-9uxqn -o json > pod.json

3.
[fedora@ip-10-111-183-39 sample-app]$ curl -X PUT -d @pod.json -k -H "Authorization:Bearer ZmMxZGYyZTAtZTIwYS00YTMxLWE1YjItNDc1NDdkNzdiN2Jk" https://localhost:8443/api/v1beta1/pods/frontend-1-9uxqn/status?namespace=test
{
  "kind": "Pod",
  "id": "frontend-1-9uxqn",
  "uid": "2396a028-e719-11e4-b166-22000ba388e4",
  "creationTimestamp": "2015-04-20T04:53:08Z",
  "selfLink": "/api/v1beta1/pods/frontend-1-9uxqn/status?namespace=test",
  "resourceVersion": 623,
  "apiVersion": "v1beta1",
  "namespace": "test",
  "generateName": "frontend-1-",
  "annotations": {
    "deployment": "frontend-1",
    "deploymentConfig": "frontend",
    "deploymentVersion": "1"
  },
  "labels": {
    "deployment": "frontend-1",
    "deploymentconfig": "frontend",
    "name": "frontend",
    "template": "application-template-stibuild"
  },
  "desiredState": {
    "manifest": {
      "version": "v1beta2",
      "id": "",
      "volumes": null,
      "containers": [
        {
          "name": "ruby-helloworld",
          "image": "172.30.185.16:5000/test/origin-ruby-sample:34baa2e765c43d7be462f20abf6c3efec62805487be875186a4cfb8fdf835676",
          "ports": [
            {
              "containerPort": 8080,
              "protocol": "TCP"
            }
          ],
          "env": [
            {
              "name": "ADMIN_USERNAME",
              "key": "ADMIN_USERNAME",
              "value": "adminAM1"
            },
            {
              "name": "ADMIN_PASSWORD",
              "key": "ADMIN_PASSWORD",
              "value": "EwO1gXKG"
            },
            {
              "name": "MYSQL_USER",
              "key": "MYSQL_USER",
              "value": "userB42"
            },
            {
              "name": "MYSQL_PASSWORD",
              "key": "MYSQL_PASSWORD",
              "value": "XCpUGnbc"
            },
            {
              "name": "MYSQL_DATABASE",
              "key": "MYSQL_DATABASE",
              "value": "root"
            }
          ],
          "resources": {},
          "terminationMessagePath": "/dev/termination-log",
          "imagePullPolicy": "PullIfNotPresent",
          "capabilities": {}
        }
      ],
      "restartPolicy": {
        "always": {}
      },
      "dnsPolicy": "ClusterFirst"
    },
    "host": "ip-10-111-183-39.ec2.internal"
  },
  "currentState": {
    "manifest": {
      "version": "",
      "id": "",
      "volumes": null,
      "containers": null,
      "restartPolicy": {}
    },
    "status": "Waiting",
    "Condition": [
      {
        "kind": "Ready",
        "status": "Full"
      }
    ],
    "host": "ip-10-111-183-39.ec2.internal",
    "hostIP": "10.111.183.39",
    "podIP": "172.17.0.9",
    "info": {
      "ruby-helloworld": {
        "state": {
          "running": {
            "startedAt": "2015-04-20T04:53:15Z"
          }
        },
        "lastState": {},
        "ready": true,
        "restartCount": 0,
        "image": "172.30.185.16:5000/test/origin-ruby-sample:34baa2e765c43d7be462f20abf6c3efec62805487be875186a4cfb8fdf835676",
        "imageID": "docker://34baa2e765c43d7be462f20abf6c3efec62805487be875186a4cfb8fdf835676",
        "containerID": "docker://d5646ad7a3e6d8046bd317eeba5329bac62898e00e562d51e7e624489f670193"
      }
    }
  }
}

4.
[fedora@ip-10-111-183-39 sample-app]$ osc get pods/frontend-1-9uxqn
POD                IP           CONTAINER(S)      IMAGE(S)                                                                                                      HOST                                          LABELS                                                                                                 STATUS    CREATED
frontend-1-9uxqn   172.17.0.9   ruby-helloworld   172.30.185.16:5000/test/origin-ruby-sample:34baa2e765c43d7be462f20abf6c3efec62805487be875186a4cfb8fdf835676   ip-10-111-183-39.ec2.internal/10.111.183.39   deployment=frontend-1,deploymentconfig=frontend,name=frontend,template=application-template-stibuild   Pending   12 minutes


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