cloudfoundry / app-autoscaler

Auto Scaling for CF Applications
Apache License 2.0
73 stars 62 forks source link

500:Internal Server Error #33

Closed NavleenKaur-24 closed 8 years ago

NavleenKaur-24 commented 8 years ago

Following the Documentation for app-autoscaler, When I am trying to make the API connection to the server by the following command- curl -v -X 'PUT' -H "Content-Type: application/json" -H "Authorization: $ACCESS_TOKEN" app_url/v1/apps/app_id/policy -d '{ }'

I am facing the 500 : Internal Server Error

OUTPUT is as follows

upload completely sent off: 3 out of 3 bytes HTTP/1.1 500 Internal Server Error Content-Length: 0 Date: Tue, 07 Jun 2016 09:37:29 GMT Server Apache-Coyote/1.1 is not blacklisted Server: Apache-Coyote/1.1 X-Vcap-Request-Id: Vcap_ID Connection #0 to host app_url left intact

fraenkel commented 8 years ago

if you run cf logs on the api server while you are performing the curl, what comes out in the log?

NavleenKaur-24 commented 8 years ago

2016-06-07T10:58:17.80+0000 [App/0] OUT 2016-06-07 10:58:17,808 INFO org.cloudfoundry.autoscaler.api.rest.PublicRestApi:85 [http-nio-61018-exec-10] [createPolicy] Received JSON String of policy content: { } 2016-06-07T10:58:17.81+0000 [RTR/0] OUT autoscalingapi.apps.eu.cfdev.canopy-cloud.com - [07/06/2016:10:58:17.688 +0000] "PUT /v1/apps/cfe24ac0-d059-4070-8685-6fb875a2c95f/policy HTTP/1.1" 500 3 105 "-" "curl/7.35.0" 10.0.0.253:37199 x_forwarded_for:"52.201.224.134" x_forwarded_proto:"https" vcap_request_id:d88376ee-cdc4-491c-6824-1cecb55cf3c7 response_time:0.125237882 app_id:17f72572-0910-430a-9fbc-344cf54bcb36 2016-06-07T10:58:17.81+0000 [App/0] OUT 2016-06-07 10:58:17,815 INFO org.cloudfoundry.autoscaler.api.rest.PublicRestApi:111 [http-nio-61018-exec-10] [createPolicy] error in getserverinfo: java.net.UnknownHostException: https 2016-06-07T10:58:17.81+0000 [App/0] OUT 2016-06-07 10:58:17,816 ERROR org.cloudfoundry.autoscaler.api.util.RestApiResponseHandler:163 [http-nio-61018-exec-10] [getResponseInternalServerError] com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: https

fraenkel commented 8 years ago

Looks like you are misconfigured. The scalingServiceName is not configured or is not deployed as CF-AutoScaler (default). Did you run the acceptance tests to make sure you have configured things correctly?

NavleenKaur-24 commented 8 years ago

Yes , But they are failing because of our Password Policy , Is there any workaround ?

fraenkel commented 8 years ago

You can configure the clientId and clientSecret so I don't understand why you can't pick a password that meets your policy needs.

NavleenKaur-24 commented 8 years ago

Failure [1.240 seconds] [BeforeSuite] BeforeSuite /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_suite_test.go:47

Got stuck at: Creating user CATS-USER-1-2016_06_08-08h11m44.735s... FAILED Error creating user CATS-USER-1-2016_06_08-08h11m44.735s. Server error, status code: 400, error code: invalid_password, message: Password must be at least 8 characters in length.,Password must contain at least 1 uppercase charact ers.,Password must contain at least 1 digit characters.,Password must contain at least 1 special characters.

Waiting for: scim_resource_already_exists

fraenkel commented 8 years ago

You just need to tweak your config for running the tests by using an existing user that would be valid.

"use_existing_user": true,
"keep_user_at_suite_end": true,
"existing_user": "USERNAME",
"existing_user_password": "PASSWORD"
NavleenKaur-24 commented 8 years ago

I tried but its showing one more error:

./bin/test_default ++ dirname ./bin/test

can't load package: package acceptance: no buildable Go source files in /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance

Ginkgo ran 1 suite in 338.652ms Test Suite Failed

fraenkel commented 8 years ago

Your initial GOPATH path is wrong. Set it to nothing and see if it works.

NavleenKaur-24 commented 8 years ago

ubuntu@ip-10-0-0-80:~/navleen/CF-AutoScaler/app-autoscaler/src/acceptance$ unset GOPATH ubuntu@ip-10-0-0-80:~/navleen/CF-AutoScaler/app-autoscaler/src/acceptance$ echo $GOPATH

ubuntu@ip-10-0-0-80:~/navleen/CF-AutoScaler/app-autoscaler/src/acceptance$ ./bin/test_default ++ dirname ./bin/test

can't load package: package acceptance: no buildable Go source files in /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance

Ginkgo ran 1 suite in 334.065ms Test Suite Failed

fraenkel commented 8 years ago

What version of GO are you using?

Your output is does not match mine...

Notice that you do not have acceptance/template

Make sure you are using the latest code base and you have updated the submodules.

NavleenKaur-24 commented 8 years ago

go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64

NavleenKaur-24 commented 8 years ago

++ dirname ./bin/test

can't load package: package acceptance: no buildable Go source files in /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance

Ginkgo ran 1 suite in 339.902ms Test Suite Failed

fraenkel commented 8 years ago

Use Go 1.6 and see if it works.

NavleenKaur-24 commented 8 years ago

++ dirname ./bin/test

Ginkgo ran 1 suite in 4.194203389s Test Suite Failed

Now This is the error , I have not made any changes to config.go

fraenkel commented 8 years ago

Something in your json configuration is wrong. I would start with trying to see where you have invalid json in that file.

NavleenKaur-24 commented 8 years ago

⢠Failure [18.781 seconds] AutoScaler API History API [It] retrieves the scaling history /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:138

Expected

: 400 to equal : 200 ## /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:130 Summarizing 4 Failures: [Fail] AutoScaler API Metric API [It] retrieves the scaling history /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:115 [Fail] AutoScaler API Policy API with a valid policy [BeforeEach] updates the policy /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:71 [Fail] AutoScaler API Policy API with a valid policy [BeforeEach] retrieves the policy /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:71 [Fail] AutoScaler API History API [It] retrieves the scaling history /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:130 Ran 5 of 5 Specs in 112.462 seconds FAIL! -- 1 Passed | 4 Failed | 0 Pending | 0 Skipped --- FAIL: TestAcceptance (112.46s) FAIL Ginkgo ran 1 suite in 1m56.734250942s Test Suite Failed
fraenkel commented 8 years ago

You will have to do further investigation but it confirms that the configuration you used during the build/deploy is broken. If configured properly, all the acceptance tests should pass.

NavleenKaur-24 commented 8 years ago

"api": "api.sys.eu.cfdev.canopy-cloud.com", "admin_user": "admin", "adminpassword": "***", "apps_domain": "apps.eu.cfdev.canopy-cloud.com", "skip_ssl_validation": true, "use_http": true, "use_existing_user": true, "keep_user_at_suite_end": true, "existing_user": "navleenkaur", "existing_userpassword": "***", "service_name": "CF-AutoScaler", "api_url": "https://autoscalingapi.apps.eu.cfdev.canopy-cloud.com", "report_interval": 120

NavleenKaur-24 commented 8 years ago

json file , In case you need to look at , Please let me know if any errors are there

boyang9527 commented 8 years ago

can you attach the api server log again?

NavleenKaur-24 commented 8 years ago

The issue is in the Acceptance Tests , Do you want me to put the api server log when I do Curl for establishing the API Connection?

NavleenKaur-24 commented 8 years ago

400 [2016-06-13 05:58:20.85 (UTC)]> cf unbind-service autoscaler-APP47d24db1-678c-45d5-6803-8343558921f4 scaling-c0765a87-f00b-4ca3-6601-8ba74165f68b Unbinding app autoscaler-APP47d24db1-678c-45d5-6803-8343558921f4 from service scaling-c0765a87-f00b-4ca3-6601-8ba74165f68b in org CATS-ORG-1-2016_06_13-05h57m12.515s / space CATS-SPACE-1-2016_06_13-05h57m12.515s as navleenkaur... OK

[2016-06-13 05:58:31.33 (UTC)]> cf delete-service scaling-c0765a87-f00b-4ca3-6601-8ba74165f68b -f Deleting service scaling-c0765a87-f00b-4ca3-6601-8ba74165f68b in org CATS-ORG-1-2016_06_13-05h57m12.515s / space CATS-SPACE-1-2016_06_13-05h57m12.515s as navleenkaur... OK

[2016-06-13 05:58:31.79 (UTC)]> cf delete autoscaler-APP47d24db1-678c-45d5-6803-8343558921f4 -f -r Deleting app autoscaler-APP47d24db1-678c-45d5-6803-8343558921f4 in org CATS-ORG-1-2016_06_13-05h57m12.515s / space CATS-SPACE-1-2016_06_13-05h57m12.515s as navleenkaur... OK ⢠Failure in Spec Setup (BeforeEach) [23.512 seconds] AutoScaler API Policy API with a valid policy [BeforeEach] retrieves the policy /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:88

Expected

: 400 to equal : 201 ## /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:71 ⢠Summarizing 4 Failures: [Fail] AutoScaler API Policy API with a valid policy [BeforeEach] updates the policy /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:71 [Fail] AutoScaler API History API [It] retrieves the scaling history /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:130 [Fail] AutoScaler API Metric API [It] retrieves the scaling history /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:115 [Fail] AutoScaler API Policy API with a valid policy [BeforeEach] retrieves the policy /home/ubuntu/navleen/CF-AutoScaler/app-autoscaler/src/acceptance/api/api_test.go:71 Ran 5 of 5 Specs in 114.480 seconds FAIL! -- 1 Passed | 4 Failed | 0 Pending | 0 Skipped --- FAIL: TestAcceptance (114.48s) FAIL Ginkgo ran 1 suite in 1m58.242096917s Test Suite Failed
fraenkel commented 8 years ago

This is not an acceptance test issue but highlights the same issue you started with. You have an issue with your deployment configuration.

NavleenKaur-24 commented 8 years ago

I have already sent you the json file, Let me know how can I troubleshoot it

fraenkel commented 8 years ago

You provided the config for the Acceptance tests. We are saying the configuration you deployed with is wrong.

NavleenKaur-24 commented 8 years ago

Sorry for the misunderstanding The file I used to deploy is as follows:

cfUrl=https://xyz.com cfClientId=cf-autoscaler-client cfClientSecret=Secret

Service broker settings

serviceName=CF-AutoScaler brokerUsername=admin brokerPassword=admin

http basic authentication settings between the CF-Autoscaler components

internalAuthUsername=admin internalAuthPassword=admin

scaling and api server URI settings

scalingServerURIList=https://autoscaling.xyz.com apiServerURI=https://autoscalingapi.xyz.com

couchdb settings

couchdbUsername=admin couchdbPassword=Password couchdbHost=Internal_IP couchdbPort=5984 couchdbServerDBName=couchdb-scaling couchdbMetricDBPrefix=couchdb-scalingmetric couchdbBrokerDBName=couchdb-scalingbroker

metrics settings

reportInterval=120

fraenkel commented 8 years ago

Let us get some more detailed logging. Can you modify app-autoscaler/api/src/main/resources/log4j.properties and change the log4j.rootLogger's INFO to DEBUG

You can also try to add to api/src/main/java/org/cloudfoundry/autoscaler/api/rest/PublicRestApi.java change line 111 to

logger.error("error in getserverinfo", e);

Run either one of your scenarios whichever is quicker since they both have the same issue while doing a cf logs so we can see where things fail and what is being passed around.

NavleenKaur-24 commented 8 years ago

Do you have any slack Channel where I can get to know things better?

NavleenKaur-24 commented 8 years ago

@fraenkel @boyang9527

fraenkel commented 8 years ago

https://cloudfoundry.slack.com/ #autoscaler

NavleenKaur-24 commented 8 years ago

Whenever I execute this command , mvn test -Denv=unittest I am able to see this error :

[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] app-autoscaler ..................................... SUCCESS [ 0.008 s] [INFO] common ............................................. FAILURE [ 12.292 s] [INFO] api ................................................ SKIPPED [INFO] server ............................................. SKIPPED [INFO] servicebroker ...................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.568 s [INFO] Finished at: 2016-07-12T07:49:28+00:00 [INFO] Final Memory: 12M/188M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project common: There are test failures.
[ERROR] [ERROR] Please refer to /home/ubuntu/navleen/autoscaler/app-autoscaler/common/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project common: There are test failures. Please refer to /home/ubuntu/navleen/autoscaler/app-autoscaler/common/target/surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures. Please refer to /home/ubuntu/navleen/autoscaler/app-autoscaler/common/target/surefire-reports for the individual test results. at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91) at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:320) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:892) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :common

fraenkel commented 8 years ago

What version of maven are you using? Try mvn test -Denv=unittest -pl common What are the errors reported in common/target/surefire-reports/

NavleenKaur-24 commented 8 years ago

Apache Maven 3.3.9

NavleenKaur-24 commented 8 years ago

For now I have CF-AutoScaler visible in my marketplace , I have pushed an app and binded to the service instance of CF-AutoScaler

Next is to define the policy ?

fraenkel commented 8 years ago

Yes.

NavleenKaur-24 commented 8 years ago

curl -X -i -k PUT -H "Authorisation: $ACCESS_TOKEN" -H "Accept: application/json" $API_URL/vi/apps//policy/policy.json this is correct?

NavleenKaur-24 commented 8 years ago

curl -X -i -k PUT -H "Authorisation: $ACCESS_TOKEN" -H "Accept: application/json" $API_URL/vi/apps/app_id/policy/policy.json

fraenkel commented 8 years ago

Close. curl -X PUT -k -i -H "Accept:application/json" -H "Content-Type: application/json" -H "Authorization: $ACCESS_TOKEN" --data-binary @"$API_URL/vi/apps/app_id/policy/policy.json"

NavleenKaur-24 commented 8 years ago

I have taken this default example for policy.json

{ "instanceMinCount":1, "instanceMaxCount":5, "policyTriggers":[{ "metricType":"Memory", "statWindow":300, "lowerThreshold":30, "upperThreshold":80, "instanceStepCountDown":1, "instanceStepCountUp":1, "stepDownCoolDownSecs":600, "stepUpCoolDownSecs":600 }], "schedules": { "timezone":"(GMT +08:00) Asia/Shanghai", "recurringSchedule":[{ "startTime":"00:00", "endTime":"23:59", "repeatOn":"[\"1\",\"2\",\"3\",\"4\",\"5\"]", "minInstCount":2, "maxInstCount":5 }], "specificDate":[{ "startDate":"2017-06-19", "startTime":"00:00", "endDate":"2017-06-19", "endTime":"23:59", "minInstCount":1, "maxInstCount":5 }] } }

But when I run the above command I get this error :

Warning: Couldn't read data from file Warning: "https://$API_URL/vi/apps/app_id Warning: /policy/policy.json", this makes an Warning: empty POST. curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information

fraenkel commented 8 years ago

It doesn't like your curl command. Do it in phases, but it is also saying you didn't do a -X PUT.

fraenkel commented 8 years ago

Closing due to inactivity. Please reopen if you have further questions.