diff options
author | Juanjo Rodriguez <jjrodrig@gmail.com> | 2019-06-20 09:05:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-20 09:05:36 +0200 |
commit | 46f4954b5f32f791a206306a8e7395af9a5395fb (patch) | |
tree | 8cbb92caeb433d4e1f24dee4a550c2f58eb52f87 | |
parent | 8cf43afe44f8fb76add802d5b67a44cfbe60b0a3 (diff) | |
parent | 64eb390a197f54a1bb36a4809861f6f3dcd6dc4e (diff) | |
download | couchdb-46f4954b5f32f791a206306a8e7395af9a5395fb.tar.gz |
Merge branch 'master' into port-elixir-auth
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Jenkinsfile | 796 | ||||
-rwxr-xr-x | dev/run | 14 | ||||
-rwxr-xr-x | rel/files/couchdb.in | 1 | ||||
-rw-r--r-- | rel/overlay/etc/default.ini | 1 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_misc.erl | 9 | ||||
-rw-r--r-- | src/couch/src/couch_db.erl | 24 | ||||
-rw-r--r-- | src/couch/src/couch_server.erl | 6 | ||||
-rw-r--r-- | src/mem3/src/mem3_rep.erl | 34 |
9 files changed, 461 insertions, 430 deletions
diff --git a/.gitignore b/.gitignore index 8e9ca151e..36bc13007 100644 --- a/.gitignore +++ b/.gitignore @@ -47,17 +47,21 @@ src/docs/ src/ets_lru/ src/fauxton/ src/folsom/ +src/hqueue/ +src/hyper/ src/ibrowse/ src/ioq/ src/jiffy/ +src/ken/ src/khash/ src/meck/ src/mochiweb/ src/oauth/ +src/proper/ src/rebar/ +src/smoosh/ src/snappy/ src/triq/ -src/hyper/ tmp/ src/couch/*.o diff --git a/Jenkinsfile b/Jenkinsfile index 3488c6ea3..c57574824 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,21 +1,56 @@ #!groovy -/* -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/ -// jenkins user == uid 910 for reference +// +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +// DRYing out the Jenkinsfile... +build_script = ''' +mkdir -p ${COUCHDB_IO_LOG_DIR} + +echo +echo "Build CouchDB from tarball & test" +builddir=$(mktemp -d) +cd ${builddir} +tar -xf ${WORKSPACE}/apache-couchdb-*.tar.gz +cd apache-couchdb-* +./configure --with-curl +make check || (build-aux/logfile-uploader.py && false) + +echo +echo "Build CouchDB packages" +cd ${builddir} +git clone https://github.com/apache/couchdb-pkg +mkdir couchdb +cp ${WORKSPACE}/apache-couchdb-*.tar.gz couchdb +tar -xf ${WORKSPACE}/apache-couchdb-*.tar.gz -C couchdb +cd couchdb-pkg +make ${platform} PLATFORM=${platform} + +echo +echo "Cleanup & save for posterity" +rm -rf ${WORKSPACE}/pkgs/${platform} +mkdir -p ${WORKSPACE}/pkgs/${platform} +mv ../rpmbuild/RPMS/$(arch)/*rpm ${WORKSPACE}/pkgs/${platform} || true +mv ../couchdb/*.deb ${WORKSPACE}/pkgs/${platform} || true +rm -rf ${builddir} ${COUCHDB_IO_LOG_DIR} +''' + pipeline { + // no top-level agent; agents must be declared for each stage - agent none + agent { + label 'ubuntu' + } environment { COUCHAUTH = credentials('couchdb_vm2_couchdb') @@ -27,425 +62,362 @@ pipeline { GIT_COMMITTER_EMAIL = 'couchdb@apache.org' } + options { + buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')) + // This fails the build immediately if any parallel step fails + parallelsAlwaysFailFast() + preserveStashes(buildCount: 10) + timeout(time: 3, unit: 'HOURS') + timestamps() + } + stages { - stage('Build') { + stage('Build Release Tarball') { agent { - // Cannot use docker agent type because image will not be pulled fresh - // each time. Instead, manually insert docker pull then run with the - // the docker image. - node { + // https://github.com/jenkins-infra/jenkins.io/blob/master/Jenkinsfile#64 + // We need the jenkins user mapped inside of the image + // npm config cache below is required because /home/jenkins doesn't + // ACTUALLY exist in the image + docker { + image 'couchdbdev/debian-stretch-erlang-19.3.6:latest' + alwaysPull true + args '-e npm_config_cache=npm-cache -e HOME=. -v=/etc/passwd:/etc/passwd -v /etc/group:/etc/group' label 'ubuntu' } } + options { + timeout(time: 15, unit: "MINUTES") + } steps { - // This image has the oldest Erlang we support, 19 - sh 'docker pull couchdbdev/debian-stretch-erlang-19.3.6' - timeout(time: 15, unit: "MINUTES") { - // https://github.com/jenkins-infra/jenkins.io/blob/master/Jenkinsfile#64 - // We need the jenkins user mapped inside of the image - // npm config cache below is required because /home/jenkins doesn't - // ACTUALLY exist in the image - withDockerContainer(image: 'couchdbdev/debian-stretch-erlang-19.3.6', args: '-e npm_config_cache=npm-cache -e HOME=. -v=/etc/passwd:/etc/passwd -v /etc/group:/etc/group') { - sh ''' - set - rm -rf apache-couchdb-* - ./configure --with-curl - make dist - chmod -R a+w * . - ''' - } - } + sh ''' + set + rm -rf apache-couchdb-* + ./configure --with-curl + make dist + chmod -R a+w * . + ''' } post { success { stash includes: 'apache-couchdb-*.tar.gz', name: 'tarball' archiveArtifacts artifacts: 'apache-couchdb-*.tar.gz', fingerprint: true - deleteDir() } - failure { - deleteDir() + cleanup { + // UGH see https://issues.jenkins-ci.org/browse/JENKINS-41894 + sh 'rm -rf ${WORKSPACE}/*' } } - } + } // stage Build Release Tarball - // TODO rework this once JENKINS-41334 is released - // https://issues.jenkins-ci.org/browse/JENKINS-41334 + // TODO Rework once Improved Docker Pipeline Engine is released + // https://issues.jenkins-ci.org/browse/JENKINS-47962 + // https://issues.jenkins-ci.org/browse/JENKINS-48050 // The builddir stuff is to prevent all the builds from live syncing // their build results to each other during the build, which ACTUALLY // HAPPENS. Ugh. - // Build packages on supported platforms using esl's erlang - stage('Test') { - steps { - parallel(freebsd: { - node(label: 'couchdb && freebsd') { - timeout(time: 90, unit: "MINUTES") { - deleteDir() - unstash 'tarball' - withEnv(['HOME='+pwd()]) { - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - gmake check || (build-aux/logfile-uploader.py && false) - - # No package build for FreeBSD at this time - ''' - } // withEnv - } // timeout - deleteDir() - } // node - }, - centos6: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/centos-6-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/centos-6-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=centos6 - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../rpmbuild/RPMS/x86_64/*rpm $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - centos7: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/centos-7-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/centos-7-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=centos7 - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../rpmbuild/RPMS/x86_64/*rpm $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - ubuntutrusty: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/ubuntu-trusty-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/ubuntu-trusty-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=$(lsb_release -cs) - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../couchdb/*.deb $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - ubuntuxenial: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/ubuntu-xenial-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/ubuntu-xenial-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=$(lsb_release -cs) - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../couchdb/*.deb $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - ubuntubionic: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/ubuntu-bionic-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/ubuntu-bionic-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=$(lsb_release -cs) - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../couchdb/*.deb $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - debianjessie: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/debian-jessie-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/debian-jessie-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=$(lsb_release -cs) - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../couchdb/*.deb $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true - deleteDir() - } // node - }, - debianstretch: { - node(label: 'ubuntu') { - timeout(time: 90, unit: "MINUTES") { - sh 'docker pull couchdbdev/debian-stretch-erlang-19.3.6' - withDockerContainer(image: 'couchdbdev/debian-stretch-erlang-19.3.6') { - sh 'rm -f apache-couchdb-*.tar.gz' - unstash 'tarball' - sh ''' - cwd=$(pwd) - mkdir -p $COUCHDB_IO_LOG_DIR - - # Build CouchDB from tarball & test - builddir=$(mktemp -d) - cd $builddir - tar -xf $cwd/apache-couchdb-*.tar.gz - cd apache-couchdb-* - ./configure --with-curl - make check || (build-aux/logfile-uploader.py && false) - - # Build CouchDB packages - cd $builddir - git clone https://github.com/apache/couchdb-pkg - mkdir couchdb - cp $cwd/apache-couchdb-*.tar.gz couchdb - tar -xf $cwd/apache-couchdb-*.tar.gz -C couchdb - cd couchdb-pkg - platform=$(lsb_release -cs) - make $platform PLATFORM=$platform - - # Cleanup & save for posterity - rm -rf $cwd/pkgs/$platform && mkdir -p $cwd/pkgs/$platform - mv ../couchdb/*.deb $cwd/pkgs/$platform || true - ''' - } // withDocker - } // timeout - archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + stage('make check') { + + parallel { + + stage('FreeBSD') { + agent { + label 'couchdb && freebsd' + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + steps { + // deleteDir is OK here because we're not inside of a Docker container! deleteDir() - } // node - } - ) // parallel - } // steps - } // stage + unstash 'tarball' + withEnv(['HOME='+pwd()]) { + sh ''' + mkdir -p $COUCHDB_IO_LOG_DIR + + # Build CouchDB from tarball & test + builddir=$(mktemp -d) + cd $builddir + tar -xf $WORKSPACE/apache-couchdb-*.tar.gz + cd apache-couchdb-* + ./configure --with-curl + gmake check || (build-aux/logfile-uploader.py && false) + + # No package build for FreeBSD at this time + rm -rf $builddir $COUCHDB_IO_LOG_DIR + ''' + } // withEnv + } // steps + } // stage FreeBSD + + stage('CentOS 6') { + agent { + docker { + image 'couchdbdev/centos-6-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'centos6' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('CentOS 7') { + agent { + docker { + image 'couchdbdev/centos-7-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'centos7' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('Ubuntu Xenial') { + agent { + docker { + image 'couchdbdev/ubuntu-xenial-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'xenial' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('Ubuntu Bionic') { + agent { + docker { + image 'couchdbdev/ubuntu-bionic-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'xenial' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('Debian Jessie') { + agent { + docker { + image 'couchdbdev/debian-jessie-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'jessie' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('Debian Stretch x86_64') { + agent { + docker { + image 'couchdbdev/debian-stretch-erlang-19.3.6:latest' + alwaysPull true + label 'ubuntu' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'jessie' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + stage('Debian Stretch aarch64') { + agent { + docker { + image 'couchdbdev/aarch64-debian-stretch-erlang-20.3.8.20:latest' + alwaysPull true + label 'arm' + } + } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + environment { + platform = 'jessie' + } + steps { + sh 'rm -f apache-couchdb-*.tar.gz' + unstash 'tarball' + sh( script: build_script ) + } // steps + post { + success { + archiveArtifacts artifacts: 'pkgs/**', fingerprint: true + } + } // post + } // stage + + } // parallel + } // stage "Make Check" stage('Publish') { + when { expression { return env.BRANCH_NAME ==~ /master|2.0.x|2.1.x|jenkins-.*/ } } + agent { - // Cannot use docker agent type because image will not be pulled fresh - // each time. Instead, manually insert docker pull then run with the - // the docker image. - node { + docker { + image 'couchdbdev/debian-stretch-erlang-19.3.6:latest' + alwaysPull true + args '-e npm_config_cache=npm-cache -e HOME=. -v=/etc/passwd:/etc/passwd -v /etc/group:/etc/group' label 'ubuntu' } } + options { + skipDefaultCheckout() + timeout(time: 90, unit: "MINUTES") + } + steps { - sh 'docker pull couchdbdev/debian-stretch-erlang-19.3.6:latest' - withDockerContainer(image: 'couchdbdev/debian-stretch-erlang-19.3.6:latest', args: '-e npm_config_cache=npm-cache -e HOME=. -v=/etc/passwd:/etc/passwd -v /etc/group:/etc/group') { - withCredentials([file(credentialsId: 'jenkins-key', variable: 'KEY')]) { - sh 'rm -rf pkgs *.tar.gz' - unarchive mapping: ['pkgs/' : '.'] - unstash 'tarball' - echo 'Retrieving & cleaning current couchdb-vm2 tree...' - sh ''' - rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/$BRANCH_NAME . || mkdir -p $BRANCH_NAME - rm -rf $BRANCH_NAME/debian/* $BRANCH_NAME/el6/* $BRANCH_NAME/el7/* - mkdir -p $BRANCH_NAME/debian $BRANCH_NAME/el6 $BRANCH_NAME/el7 $BRANCH_NAME/source - rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/js . - ''' - echo 'Building Debian repo...' - sh ''' - git clone https://github.com/apache/couchdb-pkg - cp js/debian-jessie/*.deb pkgs/jessie - reprepro -b couchdb-pkg/repo includedeb jessie pkgs/jessie/*.deb - cp js/debian-stretch/*.deb pkgs/stretch - reprepro -b couchdb-pkg/repo includedeb stretch pkgs/stretch/*.deb - cp js/ubuntu-trusty/*.deb pkgs/trusty - reprepro -b couchdb-pkg/repo includedeb trusty pkgs/trusty/*.deb - cp js/ubuntu-xenial/*.deb pkgs/xenial - reprepro -b couchdb-pkg/repo includedeb xenial pkgs/xenial/*.deb - cp js/ubuntu-bionic/*.deb pkgs/bionic - reprepro -b couchdb-pkg/repo includedeb bionic pkgs/bionic/*.deb - ''' - echo 'Building CentOS repos...' - sh ''' - cp js/centos-6/*rpm pkgs/centos6 - cp js/centos-7/*rpm pkgs/centos7 - cd pkgs/centos6 && createrepo --database . - cd ../centos7 && createrepo --database . - ''' - echo 'Building tree to upload...' - sh ''' - mv couchdb-pkg/repo/pool $BRANCH_NAME/debian - mv couchdb-pkg/repo/dists $BRANCH_NAME/debian - mv pkgs/centos6/* $BRANCH_NAME/el6 - mv pkgs/centos7/* $BRANCH_NAME/el7 - mv apache-couchdb-*.tar.gz $BRANCH_NAME/source - cd $BRANCH_NAME/source - ls -1tr | head -n -10 | xargs -d '\n' rm -f -- - cd ../.. - ''' - echo 'rsyncing tree to couchdb-vm2...' - sh ''' - rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no -i $KEY" $BRANCH_NAME jenkins@couchdb-vm2.apache.org:/var/www/html - rm -rf $BRANCH_NAME couchdb-pkg *.tar.gz - ''' - deleteDir() - } // withCredentials - } // withDockerContainer + withCredentials([file(credentialsId: 'jenkins-key', variable: 'KEY')]) { + sh 'rm -rf ${WORKSPACE}/*' + unstash 'tarball' + unarchive mapping: ['pkgs/' : '.'] + + echo 'Retrieving & cleaning current couchdb-vm2 tree...' + sh ''' + rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/$BRANCH_NAME . || mkdir -p $BRANCH_NAME + rm -rf $BRANCH_NAME/debian/* $BRANCH_NAME/el6/* $BRANCH_NAME/el7/* + mkdir -p $BRANCH_NAME/debian $BRANCH_NAME/el6 $BRANCH_NAME/el7 $BRANCH_NAME/source + rsync -avz -e "ssh -o StrictHostKeyChecking=no -i $KEY" jenkins@couchdb-vm2.apache.org:/var/www/html/js . + ''' + + echo 'Building Debian repo...' + sh ''' + git clone https://github.com/apache/couchdb-pkg + cp js/debian-jessie/*.deb pkgs/jessie + reprepro -b couchdb-pkg/repo includedeb jessie pkgs/jessie/*.deb + cp js/debian-stretch/*.deb pkgs/stretch + reprepro -b couchdb-pkg/repo includedeb stretch pkgs/stretch/*.deb + cp js/ubuntu-trusty/*.deb pkgs/trusty + reprepro -b couchdb-pkg/repo includedeb trusty pkgs/trusty/*.deb + cp js/ubuntu-xenial/*.deb pkgs/xenial + reprepro -b couchdb-pkg/repo includedeb xenial pkgs/xenial/*.deb + cp js/ubuntu-bionic/*.deb pkgs/bionic + reprepro -b couchdb-pkg/repo includedeb bionic pkgs/bionic/*.deb + ''' + + echo 'Building CentOS repos...' + sh ''' + cp js/centos-6/*rpm pkgs/centos6 + cp js/centos-7/*rpm pkgs/centos7 + cd pkgs/centos6 && createrepo --database . + cd ../centos7 && createrepo --database . + ''' + + echo 'Building tree to upload...' + sh ''' + mv couchdb-pkg/repo/pool $BRANCH_NAME/debian + mv couchdb-pkg/repo/dists $BRANCH_NAME/debian + mv pkgs/centos6/* $BRANCH_NAME/el6 + mv pkgs/centos7/* $BRANCH_NAME/el7 + mv apache-couchdb-*.tar.gz $BRANCH_NAME/source + cd $BRANCH_NAME/source + ls -1tr | head -n -10 | xargs -d '\n' rm -f -- + cd ../.. + ''' + + echo 'rsyncing tree to couchdb-vm2...' + sh ''' + rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no -i $KEY" $BRANCH_NAME jenkins@couchdb-vm2.apache.org:/var/www/html + rm -rf $BRANCH_NAME couchdb-pkg *.tar.gz + ''' + } // withCredentials } // steps } // stage } // stages @@ -453,15 +425,25 @@ pipeline { post { success { mail to: "${env.recipient}", + replyTo: "${env.recipient}", subject: "[Jenkins] SUCCESS: ${currentBuild.fullDisplayName}", + body: "Yay, we passed. ${env.RUN_DISPLAY_URL}" + } + unstable { + mail to: "${env.recipient}", replyTo: "${env.recipient}", - body: "Yay, we passed. ${env.BUILD_URL}" + subject: "[Jenkins] SUCCESS: ${currentBuild.fullDisplayName}", + body: "Eep! Build is unstable... ${env.RUN_DISPLAY_URL}" } failure { mail to: "${env.recipient}", - subject: "[Jenkins] FAILURE: ${currentBuild.fullDisplayName}", replyTo: "${env.recipient}", - body: "Boo, we failed. ${env.BUILD_URL}" + subject: "[Jenkins] FAILURE: ${currentBuild.fullDisplayName}", + body: "Boo, we failed. ${env.RUN_DISPLAY_URL}" + } + cleanup { + sh 'rm -rf ${WORKSPACE}/*' } } -} + +} // pipeline @@ -249,11 +249,6 @@ def check_beams(ctx): @log("Prepare configuration files") def setup_configs(ctx): - if os.path.exists("src/fauxton/dist/release"): - fauxton_root = "src/fauxton/dist/release" - else: - fauxton_root = "share/www" - for idx, node in enumerate(ctx["nodes"]): cluster_port, backend_port = get_ports(ctx, idx + ctx["node_number"]) env = { @@ -268,7 +263,6 @@ def setup_configs(ctx): "node_name": "-name %s@127.0.0.1" % node, "cluster_port": cluster_port, "backend_port": backend_port, - "fauxton_root": fauxton_root, "uuid": "fake_uuid_for_dev", "_default": "", } @@ -530,6 +524,14 @@ def check_node_alive(url): def set_boot_env(ctx): + # fudge fauxton path + if os.path.exists("src/fauxton/dist/release"): + fauxton_root = "src/fauxton/dist/release" + else: + fauxton_root = "share/www" + + os.environ["COUCHDB_FAUXTON_DOCROOT"] = fauxton_root + # fudge default query server paths couchjs = os.path.join(ctx["rootdir"], "src", "couch", "priv", "couchjs") mainjs = os.path.join(ctx["rootdir"], "share", "server", "main.js") diff --git a/rel/files/couchdb.in b/rel/files/couchdb.in index aae179aa7..f4416115a 100755 --- a/rel/files/couchdb.in +++ b/rel/files/couchdb.in @@ -28,6 +28,7 @@ export PROGNAME=`echo $0 | sed 's/.*\///'` export COUCHDB_QUERY_SERVER_JAVASCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main.js" export COUCHDB_QUERY_SERVER_COFFEESCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main-coffee.js" +export COUCHDB_FAUXTON_DOCROOT={{fauxton_root}} ARGS_FILE="${COUCHDB_ARGS_FILE:-$ROOTDIR/etc/vm.args}" SYSCONFIG_FILE="${COUCHDB_SYSCONFIG_FILE:-$ROOTDIR/releases/$APP_VSN/sys.config}" diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini index 2a920092f..0d7ac6d77 100644 --- a/rel/overlay/etc/default.ini +++ b/rel/overlay/etc/default.ini @@ -94,7 +94,6 @@ n=3 port = {{cluster_port}} bind_address = 127.0.0.1 backlog = 512 -docroot = {{fauxton_root}} socket_options = [{sndbuf, 262144}, {nodelay, true}] server_options = [{recbuf, undefined}] require_valid_user = false diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl index 5aa9aaf97..819d7820e 100644 --- a/src/chttpd/src/chttpd_misc.erl +++ b/src/chttpd/src/chttpd_misc.erl @@ -63,7 +63,7 @@ handle_welcome_req(Req, _) -> send_method_not_allowed(Req, "GET,HEAD"). handle_favicon_req(Req) -> - handle_favicon_req(Req, config:get("chttpd", "docroot")). + handle_favicon_req(Req, get_docroot()). handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) -> {DateNow, TimeNow} = calendar:universal_time(), @@ -80,7 +80,7 @@ handle_favicon_req(Req, _) -> send_method_not_allowed(Req, "GET,HEAD"). handle_utils_dir_req(Req) -> - handle_utils_dir_req(Req, config:get("chttpd", "docroot")). + handle_utils_dir_req(Req, get_docroot()). handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) -> "/" ++ UrlPath = chttpd:path(Req), @@ -504,3 +504,8 @@ message_queues(Registered) -> {Type, Length} = process_info(whereis(Name), Type), {Name, Length} end, Registered). + +get_docroot() -> + % if the env var isn’t set, let’s not throw an error, but + % assume the current working dir is what we want + os:getenv("COUCHDB_FAUXTON_DOCROOT", ""). diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl index ab38eb895..52c3fbb76 100644 --- a/src/couch/src/couch_db.erl +++ b/src/couch/src/couch_db.erl @@ -1560,7 +1560,14 @@ calculate_start_seq(Db, _Node, {Seq, Uuid, EpochNode}) -> calculate_start_seq(Db, _Node, {replace, OriginalNode, Uuid, Seq}) -> case is_prefix(Uuid, couch_db:get_uuid(Db)) of true -> - start_seq(get_epochs(Db), OriginalNode, Seq); + try + start_seq(get_epochs(Db), OriginalNode, Seq) + catch throw:epoch_mismatch -> + couch_log:warning("~p start_seq duplicate uuid on node: ~p " + "db: ~p, seq: ~p, uuid: ~p, epoch_node: ~p", + [?MODULE, node(), Db#db.name, Seq, Uuid, OriginalNode]), + 0 + end; false -> {replace, OriginalNode, Uuid, Seq} end. @@ -1607,8 +1614,8 @@ start_seq([{_, NewSeq}, {OrigNode, _} | _], OrigNode, Seq) when Seq > NewSeq -> NewSeq; start_seq([_ | Rest], OrigNode, Seq) -> start_seq(Rest, OrigNode, Seq); -start_seq([], OrigNode, Seq) -> - erlang:error({epoch_mismatch, OrigNode, Seq}). +start_seq([], _OrigNode, _Seq) -> + throw(epoch_mismatch). fold_docs(Db, UserFun, UserAcc) -> @@ -1986,7 +1993,8 @@ calculate_start_seq_test_() -> t_calculate_start_seq_uuid_mismatch(), t_calculate_start_seq_is_owner(), t_calculate_start_seq_not_owner(), - t_calculate_start_seq_raw() + t_calculate_start_seq_raw(), + t_calculate_start_seq_epoch_mismatch() ] }. @@ -2031,6 +2039,14 @@ t_calculate_start_seq_raw() -> ?assertEqual(13, Seq) end). +t_calculate_start_seq_epoch_mismatch() -> + ?_test(begin + Db = test_util:fake_db([]), + SeqIn = {replace, not_this_node, get_uuid(Db), 42}, + Seq = calculate_start_seq(Db, node1, SeqIn), + ?assertEqual(0, Seq) + end). + is_owner_test() -> ?assertNot(is_owner(foo, 1, [])), ?assertNot(is_owner(foo, 1, [{foo, 1}])), diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl index 3bbd2eb34..e42f1036b 100644 --- a/src/couch/src/couch_server.erl +++ b/src/couch/src/couch_server.erl @@ -292,12 +292,6 @@ handle_config_change("httpd", "port", _, _, _) -> {ok, couch_httpd:stop()}; handle_config_change("httpd", "max_connections", _, _, _) -> {ok, couch_httpd:stop()}; -handle_config_change("httpd", "default_handler", _, _, _) -> - {ok, couch_httpd:stop()}; -handle_config_change("httpd_global_handlers", _, _, _, _) -> - {ok, couch_httpd:stop()}; -handle_config_change("httpd_db_handlers", _, _, _, _) -> - {ok, couch_httpd:stop()}; handle_config_change(_, _, _, _, _) -> {ok, nil}. diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl index d2edd6c4d..fd7c680a6 100644 --- a/src/mem3/src/mem3_rep.erl +++ b/src/mem3/src/mem3_rep.erl @@ -743,13 +743,24 @@ sync_security(#shard{} = Source, #{} = Targets) -> targets_map(#shard{name = <<"shards/", _/binary>> = SrcName} = Src, - #shard{name = <<"shards/", _/binary>>, node = TgtNode}) -> + #shard{name = <<"shards/", _/binary>>, node = TgtNode} = Tgt) -> % Parse range from name in case the passed shard is built with a name only SrcRange = mem3:range(SrcName), Shards0 = mem3:shards(mem3:dbname(SrcName)), Shards1 = [S || S <- Shards0, not shard_eq(S, Src)], Shards2 = [S || S <- Shards1, check_overlap(SrcRange, TgtNode, S)], - maps:from_list([{R, S} || #shard{range = R} = S <- Shards2]); + TMap = maps:from_list([{R, S} || #shard{range = R} = S <- Shards2]), + case [{R, S} || #shard{range = R} = S <- Shards2] of + [] -> + % If target map is empty, create a target map with just + % that one target. This is to support tooling which may be + % moving / copying shards using mem3:go/2,3 before the + % shards are present in the shard map + #{mem3:range(SrcName) => Tgt}; + [_ | _] = TMapList-> + maps:from_list(TMapList) + end; + targets_map(_Src, Tgt) -> #{[0, ?RING_END] => Tgt}. @@ -876,7 +887,8 @@ targets_map_test_() -> target_not_a_shard(), source_contained_in_target(), multiple_targets(), - uneven_overlap() + uneven_overlap(), + target_not_in_shard_map() ] }. @@ -968,4 +980,20 @@ uneven_overlap() -> end). +target_not_in_shard_map() -> + ?_test(begin + R0f = [16#00000000, 16#ffffffff], + Name = <<"shards/00000000-ffffffff/d.1551893552">>, + Shards = [ + #shard{name = Name, node = 'n1', range = R0f}, + #shard{name = Name, node = 'n2', range = R0f} + ], + meck:expect(mem3, shards, 1, Shards), + Src = #shard{name = Name, node = 'n1'}, + Tgt = #shard{name = Name, node = 'n3'}, + Map = targets_map(Src, Tgt), + ?assertEqual(1, map_size(Map)), + ?assertMatch(#{R0f := #shard{name = Name, node = 'n3'}}, Map) + end). + -endif. |