Code Monkey home page Code Monkey logo

db-dumper-service's Introduction

db-dumper-service Build Status Codacy Badge Codacy Badge Report badge

A Cloud Foundry service broker to dump and restore databases on demand.

Currently supported databases are:

  • mysql
  • postgresql
  • mongodb
  • redis

More details in the specifications at https://docs.google.com/document/d/1Y5vwWjvaUIwHI76XU63cAS8xEOJvN69-cNoCQRqLPqU/edit .

See also the backlog with label "service-db-dumper".

Requirements

Installation in 5 Minutes

  1. Download latest release.zip in releases
LATEST_RELEASE_URL=$(curl -s https://api.github.com/repos/orange-cloudfoundry/db-dumper-service/releases/latest | grep browser_download_url | head -n 1 | cut -d '"' -f 4)
echo "Downloading $LATEST_RELEASE_URL"
curl -O -L $LATEST_RELEASE_URL
  1. Unzip the latest downloaded file
  2. Create a s3 service instance in your cloud foundry instance (e.g for p-riakcs: cf cs p-riakcs developer riak-db-dumper-service)
  3. Create a database service instance in your cloud foundry instance (e.g for p-mysql: cf cs p-mysql 100mb mysql-db-dumper-service)
  4. Update the manifest (manifest.yml) file in the unzipped folder (Note: If you don't want to use uaa to protect access to dashboards, remove uaa profile from spring_profiles_active)
  5. Add cloudfoundry API user following cf_admin_user and cf_admin_password var in manifest (This required for db-dumper to lookup databases by their service name using CC API. A cloudcontroller.read permission is required on all spaces with db instances to dump. Alternatively, cloudcontroller.admin permission could be granted to this user to access any service instance in any space)
  6. Push to your Cloud Foundry (in the manifest.yml folder: cf push)
  7. Register and enable the service broker with:
$ cf create-service-broker db-dumper-service broker-user-from-manifest broker-password-from-manifest https://db-dumper-service.your.domain
$ cf enable-service-access db-dumper-service

Configure your UAA (Optional if you remove uaa profile)

You need to create a new uaa client if you want to use UAA to authenticate user in the dashboard, here the steps you need to do:

  1. use uaa-cli and run: uaac client add db-dumper-service --name "db-dumper-service" --scope "openid,cloud_controller_service_permissions.read" --authorities "openid" -s "mysupersecretkey" --signup_redirect_url "http://your.db-dumper-service.url" (Note: --signup_redirect_urlis optional but highly recommended for security)
  2. Update your manifest.yml (see: uaa_url, security_oauth2_client_clientId and security_oauth2_client_clientSecret keys)

Running locally

Note:

  • Default user to access to dashboard is user/password
  • By default when you activate profile it use a filesystem filer, to use a S3 filer instead activate the profile s3 (e.g. spring_profiles_default=local,s3 ) and set the uri of your s3 in config/spring-cloud.properties file (change the value of spring.cloud.mys3).

Linux 64 bits users

  1. Clone this project
  2. Run the script bin/install-binaries to download all required binaries
  3. You need to activate the spring profile local to do this set an env var spring_profiles_default=local, you can either use with uaa profile to: spring_profiles_default=local,uaa (in this case you will need to set the env uaa_url with the url of your uaa)
  4. Run the application

Others

  1. Clone this project
  2. You will need to have binaries for driver you want to use
  3. These env vars need to be set (set only driver you want to use): mysql_dump_bin_path(Path to mysqldump binary), mysql_restore_bin_path(Path to mysql binary), postgres_dump_bin_path(Path to pg_dump binary), postgres_restore_bin_path(Path to psql binary), mongodb_dump_bin_path(Path to mongodump binary), mongodb_restore_bin_path(Path to mongorestore binary), redis_rutil_bin_path(Path to rutil binary)
  4. You need to activate the spring profile local to do this set an env var spring_profiles_default=local, you can either use with uaa profile to: spring_profiles_default=local,uaa (in this case you will need to set the env uaa_url with the url of your uaa)
  5. Run the application

How to use

Note:

  • The service broker will run tasks asynchronously.
  • The user token is needed when you want to dump or/and restore a database by its service name to check if your user is able to access to this service (We are waiting for token delegation implementation to remove the need for a mandatory user token)

Use with a Cloud Foundry cli plugin

You may use the cli plugin associated to this broker:

  1. Download the latest release of the db-dumper-cli-plugin here: https://github.com/Orange-OpenSource/db-dumper-cli-plugin/releases (e.g.: curl -L "https://github.com/Orange-OpenSource/db-dumper-cli-plugin/releases/download/v1.4.1/db-dumper_linux_amd64" -o db-dumper-plugin
  2. chmod +x db-dumper-plugin
  3. Install it to your cli with this command: cf install-plugin "path/of/db-dumper-plugin" -f

Note: You can use this service without cli plugin, it was made only to have a more convenient way to use it than using broker arbitrary parameters.

Create a dump by passing a database uri

This command will create a dump for you:

cf cs db-dumper-service experimental service-name -c '{"db":"mysql://user:[email protected]:port/database-name"}'

Create a dump and tag it

Sometime, you would like to tag a particular dump, for this you can pass a list of tags during dumps creation. For this you will need to pass this particular json:

{
  "metadata":
    {
      "tags": [
        "mytag1",
        "mytag2"
        //...
      ]
    }
}

Example

cf cs db-dumper-service experimental service-name -c '{"db":"mysql://user:[email protected]:port/database-name", "metadata": {"tags": ["v1"]}}'

Create a dump by passing a service name

For example you have a p-mysql service instance named my-mysql-db, you can create a dump with these parameters:

cf cs db-dumper-service experimental service-name -c '{"db":"my-mysql-db", "cf_user_token": "token retrieve from cf oauth-token", "org": "org of the service", "space": "space of the service"}'

Restore a dump by passing a database uri

cf update-service test -c '{"action": "restore", "db": "mysql://user:[email protected]:port/database-second-name"}'

Restore a dump by passing a service name

For example you have a p-mysql service instance named my-mysql-restore-db, you can restore a dump with these parameters:

cf update-service test -c '{"action": "restore", "db":"my-mysql-restore-db", "cf_user_token": "token retrieve from cf oauth-token", "org": "org of the service", "space": "space of the service"}'

Binding

When you bind to your service instance you could find dumps created by your service instance as credentials, here what it's look like in credentials:

{
  "database_type": "mysql",
  "database_ref": "uri or service name passed",
  "dumps": [
    {
      "dump_id": "1",
      "download_url": "http://generated-user:[email protected]/1",
      "show_url": "http://url.of.db.dumper/1",
      "filename": "file.sql.gzip",
      "created_at": "01-01-1970 00:00",
      "size": 20, // filesize in bytes
      "deleted": false,
      "tags": [
        "tag1"
      ]
    }
  ]
}

See all dumps during binding

By default, you can see only dumps corresponding to your service instance, but if you would like to see all dumps created by any service instance linked to this database, you can pass a see_all_dumps parameter to true during binding.

Example:

cf bind-service myapp test -c '{"see_all_dumps": true}'

See dumps filtered by tags during binding

You can decide to only look at dumps created with a particular tags, to do so you will also need to pass a find_by_tags parameter during binding which contains one or multiple tags.

Example:

cf bind-service myapp test -c '{"find_by_tags": ["mytag"]}'

Add a new dump

If you want to create a new dump you can use this command:

cf update-service test -c '{"action": "dump"}'

Delete dumps

This is equivalent to delete the service, your dumps will be deleted after 5 days to prevent mistake (set by dump_delete_expiration_days in manifest):

cf ds db-dumper-service experimental service-name

Access to dashboard

User access

Users can see their dumps by using the dashboard URL accessible in each service instance, which has format: https://db-dumper-service.my.domain/manage

Preview: Screenshot user

Admin access

Admins have access to a backoffice UI available at https://db-dumper-service.my.domain/manage/admin (protected by basic auth with user and password set in the manifest, see admin_username and admin_password)

Preview: Screenshot user

Manage jobs

Sometimes, async jobs need to be managed, admins can use the job backoffice UI at https://db-dumper-service.my.domain/admin/control/jobs

Preview: Screenshot user

Run tests

In order to run all tests you need to clone this project

Unit test

  1. Install maven
  2. run mvn clean test inside the project

Integration tests

Prepare environment

To run integration tests on a non linux system you will have to install and run each database type you want to test:

You will need to set java properties or env vars (replace '.' by '_' ) to specify dump and restore binaries path for each database type:

Properties Example Location
mysql.dump.bin.path /usr/local/bin/mysqldump
mysql.restore.bin.path /usr/local/Cellar/mariadb/10.1.8/bin/mysql
postgres.dump.bin.path /usr/local/bin/pg_dump
postgres.restore.bin.path /usr/local/bin/psql
mongodb.dump.bin.path /usr/local/bin/mongodump
mongodb.restore.bin.path /usr/local/bin/mongorestore
redis.rutil.bin.path /Users/arthurhalet/go/bin/rutil

TIP: If you are on linux 64 based OS you will do not need to do this, simply run the script bin/install-binaries

Run test with a real Cloud Foundry

If you want to test on a real Cloud Foundry you will need to set these properties or env var (replace '.' by '_' ):

Properties Default value Description
cloud.controller.url N/A API url of your cloud foundry
cf.admin.user N/A Username to connect to cloud foundry
cf.admin.password N/A Password to connect to cloud foundry
int.cf.admin.org N/A Org to target to put services
int.cf.admin.space N/A Space to target to put services
int.cf.service.name.mysql cleardb Mysql service name from marketplace
int.cf.service.plan.mysql spark (free plan) Mysql service plan from marketplace
int.cf.service.name.postgresql elephantsql postgresql service name from marketplace
int.cf.service.plan.postgresql turtle (free plan) postgresql service plan from marketplace
int.cf.service.name.mongodb mongolab mongodb service name from marketplace
int.cf.service.plan.mongodb sandbox (free plan) mongodb service plan from marketplace
int.cf.service.name.redis rediscloud redis service name from marketplace
int.cf.service.plan.redis 30mb (free plan) redis service plan from marketplace

Run test with a real s3 bucket

Set two env var:

  • DYNO=true
  • S3_URL=s3://accessKeyId:[email protected]/mybucket (Change the value with your own s3 url)

Other java properties

Properties Default value Description
int.mysql.server mysql://root@localhost/dbdumpertestsource URI of your mysql server, you can have to change dbdumpertestsource by a real database created on your mysql server
int.postgres.server postgres://postgres@localhost/dbdumpertestsource URI of your mysql server, you can have to change dbdumpertestsource by a real database created on your postgresql server
int.redis.server redis://localhost URI of your redis server
int.mongodb.server mongodb://localhost/dbdumpertestsource URI of your mongodb server
http.proxyHost N/A host of your http proxy (if you have one)
http.proxyPort N/A port of your http proxy (if you have one)
http.proxyUsername N/A username of your http proxy (if you have one)
http.proxyPassword N/A password of your http proxy (if you have one)
skip.ssl.verification false Set to true if you want to skip ssl verification when connecting to cloud foundry or s3 bucket

Run integration test

  1. Install maven
  2. run mvn clean integration-test inside the project

db-dumper-service's People

Contributors

arthurhlt avatar dependabot-preview[bot] avatar gberche-orange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

pcdevsecops

db-dumper-service's Issues

Jpa error during getting the job information from cloud controller

This error was found on this issue: #4

There is a jpa error when a restore failed and when cloud controller go to retrieve the job:

016-09-28T17:11:40.26+0200 [APP/1]      OUT 2016-09-28 15:11:40.269  WARN 15 --- [pool-5-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1615, SQLState: HY000                                                                                                                                                                   
2016-09-28T17:11:40.26+0200 [APP/1]      OUT 2016-09-28 15:11:40.269 ERROR 15 --- [pool-5-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : Prepared statement needs to be re-prepared                                                                                                                                                         
2016-09-28T17:11:40.27+0200 [APP/1]      OUT Query is: select job0_.id as id1_6_, job0_.database_ref_src_id as database8_6_, job0_.database_ref_target_id as database9_6_, job0_.service_instance_id as service10_6_, job0_.dump_date as dump_dat2_6_, job0_.error_message as error_me3_6_, job0_.job_event as job_even4_6_, job0_.job_type as job_type5_6_, job0_.metadata as metadata6_6_, job0_.updated_at as updated_7_6_ from job job0_ where job0_.job_type=? and job0_.job_event=?                                  
2016-09-28T17:11:40.27+0200 [APP/1]      OUT 2016-09-28 15:11:40.277 ERROR 15 --- [pool-5-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.                                                                                                                                                       
2016-09-28T17:11:40.27+0200 [APP/1]      OUT org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet

With this sql error SQL Error: 1615, SQLState: HY000

Fails to start with Java Buildpack v4.18 (offline): hibernate fails with unknown mariadb dialect

-----> Downloading Maria Db JDBC 2.4.0 from https://java-buildpack.cloudfoundry.org/mariadb-jdbc/mariadb-jdbc-2.4.0.jar (found in cache)
[...]
0 of 2 instances running, 1 starting, 1 crashed
	
FAILED
	
Error restarting application: Start unsuccessful
[...]

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
	at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) 
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) 
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847) 
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) 
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) 
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:338) 
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) 
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) 
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) 
	... 24 common frames omitted 
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 
	at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) 
	at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) 
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) 
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) 
	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) 
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234) 
	... 40 common frames omitted

Root cause is that hibernate only supports natively mariadb starting in version 5.2.8 https://planet.jboss.org/post/mariadb_dialects.

Similar issue than https://github.com/orange-cloudfoundry/paas-templates/issues/299

db-dumper fails to refresh expired access tokens

Observed db-dumper to fail with the following user-facing symptoms

cf create-dump pad-mysql
Error: Server error, status code: 502, error code: 10001, message: Service broker error: Access token denied.
Tip: use --verbose to see what's going wrong with cf core command

The db-dumper broker logs seems to confirm this hypothesis

  2018-10-24T17:27:14.36+0200 [RTR/1] OUT db-dumper.redacted-domain- [2018-10-24T15:27:14.278+0000] "PATCH /v2/service_instances/ca6bfcb2-c84b-43d9-83b9-724ea980d1eb?accepts_incomplete=true HTTP/1.1" 500 1757 38 "-" "HTTPClient/1.0 (2.8.2.4, ruby 2.4.2 (2017-09-14))" "192.168.99.31:40130" "192.168.35.92:61028" x_forwarded_for:"192.168.99.31" x_forwarded_proto:"https" vcap_request_id:"a23f3c39-6a0f-4d3f-6cd5-dc86828b6184" response_time:0.090498547 app_id:"aff7eb2a-0107-4082-a257-32a56477010f" app_index:"1" x_b3_traceid:"b469f0a3abfb0565" x_b3_spanid:"b469f0a3abfb0565" x_b3_parentspanid:"-"
   2018-10-24T17:27:14.36+0200 [RTR/1] OUT 
   2018-10-24T17:27:14.36+0200 [APP/PROC/WEB/1] OUT 2018-10-24 15:27:14.367  WARN 14 --- [nio-8080-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: error="access_denied", error_description="Access token denied."
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT 2018-10-24 15:28:12.956  WARN 7 --- [nio-8080-exec-9] o.c.c.s.controller.BaseController        : Exception
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Access token denied.
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:142)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider.refreshAccessToken(ResourceOwnerPasswordAccessTokenProvider.java:40)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.oauth2.OauthClient.refreshToken(OauthClient.java:126)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.oauth2.OauthClient.getToken(OauthClient.java:88)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.oauth2.OauthClient.getAuthorizationHeader(OauthClient.java:97)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.rest.CloudControllerClientImpl$CloudFoundryClientHttpRequestFactory.createRequest(CloudControllerClientImpl.java:2789)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:77)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:615)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.rest.LoggingRestTemplate.doExecute(LoggingRestTemplate.java:62)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:380)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.rest.CloudControllerClientImpl.createServiceKey(CloudControllerClientImpl.java:405)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.rest.CloudControllerClientImpl.createServiceKey(CloudControllerClientImpl.java:382)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.client.lib.CloudFoundryClient.createServiceKey(CloudFoundryClient.java:296)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.service.servicekey.CloudFoundryServiceKeyManager.createServiceKey(CloudFoundryServiceKeyManager.java:49)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.dbdumper.DatabaseRefManager.updateDatabaseRef(DatabaseRefManager.java:76)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.service.DbDumperServiceInstanceService.createDumpFromdbDumperServiceInstance(DbDumperServiceInstanceService.java:219)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.service.DbDumperServiceInstanceService.updateServiceInstance(DbDumperServiceInstanceService.java:200)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.service.DbDumperServiceInstanceService$$FastClassBySpringCGLIB$$f90a4690.invoke(<generated>)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at com.orange.clara.cloud.servicedbdumper.service.DbDumperServiceInstanceService$$EnhancerBySpringCGLIB$$f56e2589.updateServiceInstance(<generated>)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.cloudfoundry.community.servicebroker.controller.ServiceInstanceController.updateServiceInstance(ServiceInstanceController.java:113)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at java.lang.reflect.Method.invoke(Method.java:498)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
   2018-10-24T17:28:12.95+0200 [APP/PROC/WEB/0] OUT         at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

Root cause seems to be in the deprecated cf-java client library
https://github.com/orange-cloudfoundry/db-dumper-service/blob/master/pom.xml#L37
which includes token refresh bugs

High UAA access token/refresh token creation rate much shorter than refresh validity

It seems that db-dumper has created 1.2 millons UAA refresh tokens in the last 30 days, filling up the uaa/CC db revocable_token table.

The refresh_token_validity is configured to 30days on the affected UAA.

Likely db-dumper is creating new access token for every call /cc api session.

Need to investigate whether revocable AT can be avoided by the cf-java-client

Wrong MariaDB Version for cf-mysql release Bosh

In db-dumper-service/bin/install-binaries
you define

mysql_version="5.7.16"
mysql_global_version="5.7"
mariadb_version="10.2.10"
mongodb_version="3.3.2"
postgresql_version="9.6.1"

The cf-mysql bosh Release is on MariaDB 10.1.x and not 10.2.

1.4.2 release contains binary displaying 1.4.1 version

curl -L "https://github.com/Orange-OpenSource/db-dumper-cli-plugin/releases/download/v1.4.2/db-dumper_linux_amd64" -o db-dumper-plugin

$ curl -L "https://github.com/Orange-OpenSource/db-dumper-cli-plugin/releases/download/v1.4.2/db-dumper_linux_amd64" -o db-dumper-plugin
$ md5sum db-dumper-plugin
e298542cc92d28f05b5a643bd328808d  db-dumper-plugin
$ ls -al db-dumper-plugin
-rwxrwxr-x 1 guillaume guillaume 9961627 sept.  1 10:11 db-dumper-plugin
$  chmod +x db-dumper-plugin
$ cf uninstall-plugin db-dumper
[...]

$ cf install-plugin ./db-dumper-plugin
[...]
Installing plugin db-dumper-plugin...
OK
Plugin db-dumper v1.4.1 successfully installed.

Bump cf-java client to use CC API V3

db-dumper-services makes heavy usage of CC API V2:

Potentially further calls to be identified:
https://github.com/orange-cloudfoundry/db-dumper-service/search?q=client&unscoped_q=client

CC API V2 deprecation draft plan has been published. A 6 month overlap is planned by the time the CF CLI is not using CC API V2 anymore.

error while restoring a dump to a service instance. SQL Error: 1615, SQLState: HY000

Using db-dumper-service version 1.3.0 (p-mysql v26.2 / cloudfoundry 240).

I successfully create a db-dumper service from an existing database.

Now im trying to restore the dump into a cf-mysql service instance.

Getting this user error :

#cf service orange-dbaas-dumper

Service instance: orange-dbaas-dumper
Service: db-dumper-service
Bound apps:
Tags:
Plan: unlimited
Description: Dump and restore data from your database (db-dumper-service v1.3.0)
Documentation url: https://github.com/orange-cloudfoundry/db-dumper-service/tree/v1.3.0
Dashboard: https://dbdumper-broker.xxx/manage/list/zzz

Last Operation
Status: update failed
Message: Error:
An error occurred:
Error during process (exit code is 1):
Details: ERROR 2013 (HY000) at line 889: Lost connection to MySQL server during query

Started: 2016-09-28T15:58:20Z
Updated: 2016-09-28T16:05:02Z

And the following logs on db-dumper cf app logs

2016-09-28T17:11:40.26+0200 [APP/1]      OUT 2016-09-28 15:11:40.269  WARN 15 --- [pool-5-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1615, SQLState: HY000                                                                                                                                                                   
2016-09-28T17:11:40.26+0200 [APP/1]      OUT 2016-09-28 15:11:40.269 ERROR 15 --- [pool-5-thread-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : Prepared statement needs to be re-prepared                                                                                                                                                         
2016-09-28T17:11:40.27+0200 [APP/1]      OUT Query is: select job0_.id as id1_6_, job0_.database_ref_src_id as database8_6_, job0_.database_ref_target_id as database9_6_, job0_.service_instance_id as service10_6_, job0_.dump_date as dump_dat2_6_, job0_.error_message as error_me3_6_, job0_.job_event as job_even4_6_, job0_.job_type as job_type5_6_, job0_.metadata as metadata6_6_, job0_.updated_at as updated_7_6_ from job job0_ where job0_.job_type=? and job0_.job_event=?                                  
2016-09-28T17:11:40.27+0200 [APP/1]      OUT 2016-09-28 15:11:40.277 ERROR 15 --- [pool-5-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.                                                                                                                                                       
2016-09-28T17:11:40.27+0200 [APP/1]      OUT org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet                                                                                                                           


NB: the cf-mysql cluster holds my target mysql instance, and db-dumper own database.

cc @gberche-orange @fbonelle

Support for Elasticsearch

Our team would really like to use the db-dumper-service, but we want to know how easy it would be to add support for Elasticsearch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.