Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the docker container work with an existing couchDB #576

Closed
Louis-T opened this issue Jan 7, 2021 · 5 comments
Closed

Make the docker container work with an existing couchDB #576

Louis-T opened this issue Jan 7, 2021 · 5 comments

Comments

@Louis-T
Copy link

Louis-T commented Jan 7, 2021

Description

Hi

In the process of starting a new swarmpit instance, it will try to create the _users, _replicator and _global_changes databases on the specified couchDB.
In the event of any of those already present in the couchDB, it will fail and crash.

Could you make a "check" before creating the db ? In case they are already present ? Thanks !

Steps to reproduce the issue:

  1. Create a couchDB instance
  2. Create one of _users, _replicator or _global_changes on it
  3. Launch swarmpit

What happens:

21-01-07 10:12:01 node1-monitor_swarmpit-ui-1 ERROR [swarmpit.http:71] - Request execution failed! Scope: DB
|> PUT http://xxxx:xxxx@couchdb:5984/_replicator
|> Headers: null
|> Payload: null
|< Message: clj-http: status 412
|< Data: {
  "headers" : {
    "Cache-Control" : "must-revalidate",
    "Connection" : "close",
    "Content-Length" : "95",
    "Content-Type" : "application/json",
    "Date" : "Thu, 07 Jan 2021 10:12:01 GMT",
    "Server" : "CouchDB/3.1.0 (Erlang OTP/20)",
    "X-Couch-Request-ID" : "67a1bcf71d",
    "X-CouchDB-Body-Time" : "0"
  },
  "status" : 412,
  "body" : "{\"error\":\"file_exists\",\"reason\":\"The database could not be created, the file already exists.\"}\n",
  "reason-phrase" : "Precondition Failed",
  "type" : "clj-http.client/unexceptional-status"
}
Exception in thread "main" clojure.lang.ExceptionInfo: DB error: file_exists {:status 412, :type :http-client, :headers {"Cache-Control" "must-revalidate", "Connection" "close", "Content-Length" "95", "Content-Type" "application/json", "Date" "Thu, 07 Jan 2021 10:12:01 GMT", "Server" "CouchDB/3.1.0 (Erlang OTP/20)", "X-Couch-Request-ID" "67a1bcf71d", "X-CouchDB-Body-Time" "0"}, :body {:error "file_exists"}}
	at swarmpit.http$execute_in_scope.invokeStatic(http.clj:112)
	at swarmpit.http$execute_in_scope.invoke(http.clj:80)
	at swarmpit.couchdb.client$execute.invokeStatic(client.clj:10)
	at swarmpit.couchdb.client$execute.invoke(client.clj:7)
	at swarmpit.couchdb.client$create_sns_replicator.invokeStatic(client.clj:107)
	at swarmpit.couchdb.client$create_sns_replicator.invoke(client.clj:105)
	at swarmpit.couchdb.migration$single_node_setup.invokeStatic(migration.clj:19)
	at swarmpit.couchdb.migration$single_node_setup.invoke(migration.clj:16)
	at swarmpit.couchdb.migration$migrate.invokeStatic(migration.clj:40)
	at swarmpit.couchdb.migration$migrate.invoke(migration.clj:36)
	at swarmpit.database$init_couch.invokeStatic(database.clj:67)
	at swarmpit.database$init_couch.invoke(database.clj:59)
	at swarmpit.database$init.invokeStatic(database.clj:81)
	at swarmpit.database$init.invoke(database.clj:79)
	at swarmpit.server$_main.invokeStatic(server.clj:92)
	at swarmpit.server$_main.doInvoke(server.clj:90)
	at clojure.lang.RestFn.invoke(RestFn.java:397)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at swarmpit.server.main(Unknown Source)

For the record, I had the same problem with the _users db just before this, so I deleted it, but I can't delete _replicator !

Additional information (e.g. docker version, cluster setup,...):

  • Latest version of swarmpit
  • Docker version 19.03.5, build 633a0ea838
  • Trying to deploy it in a swarm
  • The couchDB is an existing cluster
@nohaapav
Copy link
Member

nohaapav commented Jan 7, 2021

migration is done only once and changelog written in couch .. this is most probably related to different problem ..

@nohaapav
Copy link
Member

nohaapav commented Jan 9, 2021

Oh i see, you already have your own couch DB instance .. in that case you have to create migration document so swarmpit app knows the data model is already there.

@nohaapav
Copy link
Member

nohaapav commented Jan 9, 2021

@Louis-T
Copy link
Author

Louis-T commented Jan 11, 2021

Hi !
Thanks for the pointers 😃

By creating the following file in my couchDB (database: swarmpit), I was indeed able to start the swarmpit app !

{
  "_id": "1c516abfac159b53e5b9edd5d900492b",
  "_rev": "1-c8219b09423abbe3f9f08d5cad2ca9a0",
  "type": "migration",
  "name": "single-node-setup",
  "result": null
}

Thanks again, I'm closing the issue.

@dazinator
Copy link

@Louis-T I am hitting a similar issue in #670 - any pointers would be greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants