Bug 812046 - [REST_API] Provide credentials and connection url in the application cartridges
[REST_API] Provide credentials and connection url in the application cartridges
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Master (Show other bugs)
2.x
Unspecified Unspecified
high Severity low
: ---
: ---
Assigned To: Abhishek Gupta
libra bugs
: Triaged
Depends On:
Blocks: 916268
  Show dependency treegraph
 
Reported: 2012-04-12 11:42 EDT by Xavier Coulon
Modified: 2015-05-14 20:51 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-25 14:26:59 EDT
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 Xavier Coulon 2012-04-12 11:42:00 EDT
As an improvement/new feature, when querying for cartridges, the response could contain the connection URL along with the credentials to connect to the cartridge. For now, if the credentials have not been kept after cartridge creation, the only way to find them back is to connect with ssh and look at the environment variables. 

Also, in its current form, the "info" element in the applications response is not really usable:

"embedded":{
            "mongodb-2.0":{
                "info":"Connection URL: mongodb://127.5.82.129:27017/\n"
            },
            "mysql-5.1":{
                "info":"Connection URL: mysql://127.5.82.129:3306/\n"
            }
        },

it could be replaced by something like this:

"embedded":{
            "mongodb-2.0":{
                "connection_url":"mongodb://127.5.82.129:27017/"
            },
            "mysql-5.1":{
                "connection_url":"mysql://127.5.82.129:3306/"
            }
        },
Comment 1 Xavier Coulon 2012-04-12 11:46:35 EDT
As a complement:

when querying for cartridges; the current response is :

{
    "version":"1.0",
    "messages":[
        
    ],
    "type":"cartridge",
    "status":"ok",
    "data":{
        "name":"mongodb-2.0",
        "type":"embedded",
        "links":{
  ...
}

the issue is about adding the connection url and the credentials along with the 'name' and the 'type', unless the credentials data is too sensitive. Yet, this could be very useful for our tooling, once we have the port-forwarding implemented in Eclipse.
Comment 2 Andre Dietisheim 2012-06-01 19:40:34 EDT
the main problem with the current reporting strategy is that the connection url is not present in the cartridge-resource, it is only present in the application-resource. This forces the openshift-java-client to hand those from the application to the cartridge. This furthermore only works for cartridges that were present when the application was queried. Cartridges added to the application afterwards are of course not present in the application. See here:

https://issues.jboss.org/browse/JBIDE-12076?focusedCommentId=12698129&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12698129
Comment 3 Andre Dietisheim 2012-06-05 03:44:58 EDT
We code-freezed CR1 last friday which will become GA mid june. This means that we now have a release that will get to users officially. We'd therefore ask you to keep the json responses as compatible as possible so that our installation base wont break. Thanks!
Comment 4 Abhishek Gupta 2012-06-14 20:06:23 EDT
https://github.com/openshift/crankcase/pull/130
Comment 5 Xiaoli Tian 2012-06-18 06:57:57 EDT
(In reply to comment #4)
> https://github.com/openshift/crankcase/pull/130

Tested this on the latest INT(devenv_1850), result is as following, most part is fixed, but still having 3 problems:

1. Credentials for rockmongo is still not added;

2. Jenkins credentials is not shown in either jenkins-client or jenkins server information.

3. Seems there's one more "\n" at the end of each info url.

   "embedded": {
      "mysql-5.1": {
        "database_name": "jbosseapapp1",
        "password": "U1pHtXrzBy6c",
        "connection_url": "mysql://127.6.135.129:3306/",
        "info": "Connection URL: mysql://127.6.135.129:3306/\n",
        "username": "admin"
      },
      "phpmyadmin-3.4": {
        "password": "U1pHtXrzBy6c",
        "connection_url": "https://jbosseapapp1-domainint2.int.rhcloud.com/phpmyadmin/",
        "info": "URL: https://jbosseapapp1-domainint2.int.rhcloud.com/phpmyadmin/\n",
        "username": "admin"
      },
      "mongodb-2.0": {
        "database_name": "jbosseapapp1",
        "password": "aDa-mXTaCyI3",
        "connection_url": "mongodb://127.6.135.129:27017/",
        "info": "Connection URL: mongodb://127.6.135.129:27017/\n",
        "username": "admin"
      },
      "jenkins-client-1.4": {
        "job_url": "https://jenkins1-domainint2.int.rhcloud.com/job/jbosseapapp1-build/",
        "info": "Job URL: https://jenkins1-domainint2.int.rhcloud.com/job/jbosseapapp1-build/\n"
      },
      "rockmongo-1.1": {
        "info": "URL: https://jbosseapapp1-domainint2.int.rhcloud.com/rockmongo/\n"
      }

Jenkins server app information:
    "git_url": "ssh://501280355f504b248c98c3560d2062c8@jenkins1-domainint2.int.rhcloud.com/~/git/jenkins1.git/",
    "framework": "jenkins-1.4",
    "health_check_path": "health",
    "embedded": {
      
    },
    "app_url": "http://jenkins1-domainint2.int.rhcloud.com/",
    "gear_profile": "small",
    "creation_time": "2012-06-18T06:34:44-04:00"
Comment 6 Abhishek Gupta 2012-06-18 17:34:31 EDT
1. Jenkins credentials are already present and can be access through the .../gears and .../gear_groups urls. They will not be included as part of the application response or within the embedded jenkins client properties

2. Added url and credentials for rockmongo, phpmoadmin and the url for metrics cartridges

3. There is already a separate bug (Bug 796458) tracking the "\n" at the end of the connection url in the "Info" tag.
Comment 7 Xiaoli Tian 2012-06-19 07:24:32 EDT
Tested it on devenv_1857 again

For jenkins: 
curl -k -H "Accept: application/json" --user "xtian+b101@redhat.com:123456"  https://localhost/broker/rest/domains/domainbill004/applications/jenkins/gear_groups

  "data": [
    {
      "cartridges": [
        {
          "name": "jenkins-1.4",
          "username": "system_builder",
          "password": "Lw9FQxhgpgXK"
        }
      ],
      "gear_profile": "small",
      "name": "@@app/cart-jenkins-1.4",
      "gears": [
        {
          "id": "022eaf3090e244b29e384a1a97d1ca8c",
          "state": "started"
        }
      ]
    }
  ],

For Rockmongo:
    "embedded": {
      "mongodb-2.0": {
        "database_name": "phpappjenkins",
        "username": "admin",
        "info": "Connection URL: mongodb://127.0.253.1:27017/\n",
        "password": "g1qCdE96waPz",
        "connection_url": "mongodb://127.0.253.1:27017/"
      },
      "rockmongo-1.1": {
        "username": "admin",
        "info": "URL: https://phpappjenkins-domainbill004.dev.rhcloud.com/rockmongo/\n",
        "password": "g1qCdE96waPz",
        "connection_url": "https://phpappjenkins-domainbill004.dev.rhcloud.com/rockmongo/"
      },
Comment 8 Andre Dietisheim 2013-02-27 11:08:40 EST
Unfortunately this is not what I see in PROD. When curl'in my app I get the following:

"embedded":{
            "mongodb-2.2":{
               "info":{

               }
            },
            "rockmongo-1.1":{
               "info":{

               }
            },
            "phpmyadmin-3.4":{
               "info":{

               }
            },
            "jenkins-client-1.4":{
               "info":{

               }
            }
         }

Unfortunately this is worse than what we had before:
In prior version the output was an empty string to "info":

 "rockmongo-1.1":{
               "info":""
            },

We catched this by checked for the "info" being undefined. We then went for the creation log (the log that is being reported when the cartridge is added) and tried to extract the url from there. 
Unfortunately the above is breaking our check since "info" now is defined, it has an empty object. In consequence all our existing users now dont get any URLs for their cartridges any more. See here: https://issues.jboss.org/browse/JBIDE-1363

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