Make the docker container work with an existing couchDB

This issue has been created since 2021-01-07.

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:[email protected]: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 wrote this answer on 2021-01-07

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

nohaapav wrote this answer on 2021-01-09

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.

Louis-T wrote this answer on 2021-01-11

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.

More Details About Repo
Owner Name swarmpit
Repo Name swarmpit
Full Name swarmpit/swarmpit
Language Clojure
Created Date 2017-02-06
Updated Date 2022-09-28
Star Count 2478
Watcher Count 59
Fork Count 250
Issue Count 143

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
FW:“线上”开庭 跨境电信诈骗案涉案人受审 1 2022-03-28 2022-05-07
Exported file name in lower cases on Linux when using cube copy process 1 2022-07-14 2022-08-11
}bedrock.cube.data.import - How to use pZeroFilter 2 2022-08-02 2022-08-20
Filter out single and double quotes from CSV 1 2022-03-13 2022-09-26
Definition of payloadElements and payload node 4 2021-08-19 2022-08-08
[dsm][HTML] namespace inválido (w) em XML impede de lidar com o XML 4 2020-11-12 2022-09-24
Build error Invalid 'main' field in 0 2022-09-07 2022-09-15
Litespeed cache strips inline JavaScript 0 2021-05-21 2022-08-21
formatting of params.py file 8 2020-11-25 2022-07-27
When does the crawler stop 4 2020-12-25 2022-09-18
freeze on macOS Monterey gives warnings 5 2022-07-25 2022-09-10
Electron `window.setContentSize` equivalent? 1 2021-12-10 2022-09-29
Native: Scroll direction varies by platform 9 2021-05-07 2022-07-09
Feature Request: Support Oauth login 4 2020-12-10 2022-08-29
When import csv file, fix window open but not allow to Fix as per screen shots 1 2021-12-25 2022-02-02
Unannounced breaking change in renaming falcon.api_helpers 2 2021-04-06 2022-09-15
Requires FlyWheel 1.18-0.5.1 or above, and below 1.18-0.6.0 1 2022-01-27 2022-09-13
Elasticsearch Cloud fail to index 0 2021-09-22 2022-07-16
Custom headers ignored in HTTPCollectorBot 1 2022-02-03 2022-09-13
An exception occurs when Where is invoked after ProjectToType. 1 2022-02-24 2022-09-26
How to use HDMI display port? 1 2022-09-18 2022-09-22
Fieldset Textarea have some unwanted behaviour 1 2021-11-10 2022-07-24
Unexpected exception thrown during call to append_features 1 2021-09-07 2022-08-01
Page.ObjectId() does not document default value of UseNames parameter, nor presence of `Page ` in the result 0 2022-06-07 2022-09-22
How can i use an angular 11 application as root config? 1 2021-04-20 2022-08-22
No right click with touch controls 0 2022-08-23 2022-09-13
Configure WhiteSource for GitHub.com 4 2021-08-09 2022-04-17
`Sec-CH-Viewport-Width/Height` aren't `<meta name=viewport>`-aware on navigation requests 13 2021-09-07 2022-09-12
php-scoper requires PHP 8 as minimum 4 2020-12-22 2022-07-07
Develop an app 1 2021-07-14 2022-01-15
[Feature Request] 希望小说有 添加书签显示下划线 功能 1 2021-09-26 2022-07-17
Stream API wrong type 3 2022-08-25 2022-09-21
Managing multiple iam_role configurations with dependencies between them 3 2022-03-17 2022-08-31
low performance with chisel 1 2022-03-29 2022-09-26
Support for DestinationDataSharing parameter in AWS::SSM::ResourceDataSync 0 2021-11-30 2022-09-27
Function triggers 0 2020-10-15 2021-12-29
OpenWhisk support 1 2020-01-20 2022-01-09
Iphone4S GasGauge Error 4 2022-06-28 2022-09-16
SDK support for nestable async events 3 2022-04-02 2022-09-20
Cargo does not pass `--target` to `rustdoc --test` for the host target 4 2022-04-13 2022-09-23
Continuous Integration Testing 1 2018-05-20 2022-07-24
Error creating Job: googleapi: Error 404: Not found: Dataset even if it exists 2 2021-11-26 2022-08-22
google_monitoring_alert_policy imports to wrong project 0 2021-11-26 2022-08-26
Temporary bugfix for getStorage issue on WeChat SDK 2.24.0 1 2022-04-14 2022-09-24
SecAuditLogParts never logs anything for 'K' type (list of rule IDs) 3 2022-02-18 2022-09-24
Modifying mujoco xml file to modify environment 1 2022-01-13 2022-09-26
AssertException on NullPointerException thrown in annotated @Controller method 3 2021-10-01 2022-09-21
Annotate org.springframework.boot.actuate.autoconfigure.endpoint.expose.IncludeExcludeEndpointFilter.IncludeExcludeEndpointFilter(Class<E>, Collection<String>, Collection<String>, DefaultIncludes) with @Deprecated 0 2021-11-10 2022-08-10
Maui Scenario Workload Download Error 3 2022-02-01 2022-09-16
Consider adding support for trusted-types with lazy loading 4 2022-05-23 2022-09-15