thelastpickle / cassandra-reaper

Automated Repair Awesomeness for Apache Cassandra
http://cassandra-reaper.io/
Apache License 2.0
484 stars 217 forks source link

unable to configure a base path #1013

Open sguenfred opened 3 years ago

sguenfred commented 3 years ago

Project board link

Hi, i have a problem running cassandra-reaper with a basepath configured i want to prefix cassandra-reaper url's with /cassandra-reaper

so i add a

server:
  type: default
  applicationContextPath: ${BASE_URL_PATH}

in my config

bash-5.0# cat /etc/cassandra-reaper.yml 
# Copyright 2017-2017 Spotify AB
# Copyright 2017-2018 The Last Pickle Ltd
#
# 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.

segmentCount: ${REAPER_SEGMENT_COUNT}
repairParallelism: ${REAPER_REPAIR_PARALELLISM}
repairIntensity: ${REAPER_REPAIR_INTENSITY}
scheduleDaysBetween: ${REAPER_SCHEDULE_DAYS_BETWEEN}
repairRunThreadCount: ${REAPER_REPAIR_RUN_THREADS}
hangingRepairTimeoutMins: ${REAPER_HANGING_REPAIR_TIMEOUT_MINS}
storageType: ${REAPER_STORAGE_TYPE}
enableCrossOrigin: ${REAPER_ENABLE_CROSS_ORIGIN}
incrementalRepair: ${REAPER_INCREMENTAL_REPAIR}
blacklistTwcsTables: ${REAPER_BLACKLIST_TWCS}
enableDynamicSeedList: ${REAPER_ENABLE_DYNAMIC_SEED_LIST}
repairManagerSchedulingIntervalSeconds: ${REAPER_REPAIR_MANAGER_SCHEDULING_INTERVAL_SECONDS}
jmxConnectionTimeoutInSeconds: ${REAPER_JMX_CONNECTION_TIMEOUT_IN_SECONDS}
useAddressTranslator: ${REAPER_USE_ADDRESS_TRANSLATOR}

# datacenterAvailability has three possible values: ALL | LOCAL | EACH
# the correct value to use depends on whether jmx ports to C* nodes in remote datacenters are accessible
# If the reaper has access to all node jmx ports, across all datacenters, then configure to ALL.
# If jmx access is only available to nodes in the same datacenter as reaper in running in, then configure to LOCAL.
# If there's a reaper instance running in every datacenter, and it's important that nodes under duress are not involved in repairs,
#    then configure to EACH.
#
# The default is ALL
datacenterAvailability: ${REAPER_DATACENTER_AVAILABILITY}

autoScheduling:
  enabled: ${REAPER_AUTO_SCHEDULING_ENABLED}
  initialDelayPeriod: ${REAPER_AUTO_SCHEDULING_INITIAL_DELAY_PERIOD}
  periodBetweenPolls: ${REAPER_AUTO_SCHEDULING_PERIOD_BETWEEN_POLLS}
  timeBeforeFirstSchedule: ${REAPER_AUTO_SCHEDULING_TIME_BEFORE_FIRST_SCHEDULE}
  scheduleSpreadPeriod: ${REAPER_AUTO_SCHEDULING_SCHEDULE_SPREAD_PERIOD}
  excludedKeyspaces: ${REAPER_AUTO_SCHEDULING_EXCLUDED_KEYSPACES}

jmxPorts: ${REAPER_JMX_PORTS}

jmxAuth:
  username: ${REAPER_JMX_AUTH_USERNAME}
  password: ${REAPER_JMX_AUTH_PASSWORD}

logging:
  level: ${REAPER_LOGGING_ROOT_LEVEL}
  loggers: ${REAPER_LOGGING_LOGGERS}
  appenders:
    - type: console
      logFormat: ${REAPER_LOGGING_APPENDERS_CONSOLE_LOG_FORMAT}
      threshold: ${REAPER_LOGGING_APPENDERS_CONSOLE_THRESHOLD}

server:
  type: default
  applicationContextPath: ${BASE_URL_PATH}
  applicationConnectors:
    - type: http
      port: ${REAPER_SERVER_APP_PORT}
      bindHost: ${REAPER_SERVER_APP_BIND_HOST}
  adminConnectors:
    - type: http
      port: ${REAPER_SERVER_ADMIN_PORT}
      bindHost: ${REAPER_SERVER_ADMIN_BIND_HOST}
  requestLog:
    appenders:
      - type: console
        #logFormat: "%-6level [%d] [%t] %logger{5} - %msg %n"
        threshold: INFO

activateQueryLogger: false

cassandra:
  clusterName: reaper-cluster
  contactPoints: ["10.20.0.10","10.20.0.11","10.20.0.12"]
  port: 9042
  keyspace: reaper_db
  loadBalancingPolicy:
    type: tokenAware
    shuffleReplicas: true
    subPolicy:
      type: dcAwareRoundRobin
      localDC: 
      usedHostsPerRemoteDC: 0
      allowRemoteDCsForLocalConsistencyLevel: false
accessControl:
  sessionTimeout: PT10M
  shiro:
    iniConfigs: ["file:/etc/shiro.ini"]
jmxAuth:
  username: dsgdsgdsg
  password: dsfdsfdfdf

the env var related to base_path exist

bash-5.0# echo $BASE_URL_PATH
/cassandra-reaper

i can go to https://my-super-website.com/cassandra-reaper/webui

i can proceed login. But right after login it keep redirecting me to https://my-super-website.com/webui

I had to manualy change the url at this step to https://my-super-website.com/cassandra-reaper/webui

to acess it again

here are the logs

overwriting REAPER_CASS_CONTACT_POINTS with CASSANDRA_HOSTS_MAPPING content
INFO   [2021-02-02 17:24:44,624] [main] i.d.s.DefaultServerFactory - Registering jersey handler with root path prefix: /cassandra-reaper 
INFO   [2021-02-02 17:24:44,628] [main] i.d.s.DefaultServerFactory - Registering admin handler with root path prefix: / 
INFO   [2021-02-02 17:24:44,629] [main] i.d.a.AssetsBundle - Registering AssetBundle with name: assets for path /webui/* 
INFO   [2021-02-02 17:24:44,741] [main] o.a.s.c.ReflectionBuilder - An instance with name 'authc' already exists.  Redefining this object as a new instance of type org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter 
INFO   [2021-02-02 17:24:44,743] [main] o.a.s.c.ReflectionBuilder - An instance with name 'rest' already exists.  Redefining this object as a new instance of type io.cassandrareaper.resources.auth.RestPermissionsFilter 
INFO   [2021-02-02 17:24:44,801] [main] i.c.ReaperApplication - initializing runner thread pool with 15 threads 
INFO   [2021-02-02 17:24:44,801] [main] i.c.ReaperApplication - initializing storage of type: cassandra 
INFO   [2021-02-02 17:24:44,877] [main] c.d.d.core - DataStax Java driver 3.10.1 for Apache Cassandra 
INFO   [2021-02-02 17:24:44,881] [main] c.d.d.c.GuavaCompatibility - Detected Guava >= 19 in the classpath, using modern compatibility layer 
INFO   [2021-02-02 17:24:45,076] [main] c.d.d.c.ClockFactory - Using native clock to generate timestamps. 
INFO   [2021-02-02 17:24:45,176] [main] c.d.d.c.NettyUtil - Did not find Netty's native epoll transport in the classpath, defaulting to NIO. 
INFO   [2021-02-02 17:24:45,687] [main] c.d.d.c.p.DCAwareRoundRobinPolicy - Using data-center name 'dc1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor) 
INFO   [2021-02-02 17:24:45,688] [main] c.d.d.c.Cluster - New Cassandra host /10.20.0.10:9042 added 
INFO   [2021-02-02 17:24:45,688] [main] c.d.d.c.Cluster - New Cassandra host /10.20.0.11:9042 added 
INFO   [2021-02-02 17:24:45,688] [main] c.d.d.c.Cluster - New Cassandra host /10.20.0.12:9042 added 
INFO   [2021-02-02 17:24:45,962] [main] o.c.c.m.MigrationRepository - Found 10 migration scripts 
INFO   [2021-02-02 17:24:45,962] [main] i.c.s.CassandraStorage - Keyspace reaper_db already at schema version 25 
INFO   [2021-02-02 17:24:46,188] [main] i.c.ReaperApplication - no JMX connection factory given in context, creating default 
INFO   [2021-02-02 17:24:46,202] [main] i.c.ReaperApplication - creating and registering health checks 
INFO   [2021-02-02 17:24:46,202] [main] i.c.ReaperApplication - creating resources and registering endpoints 
INFO   [2021-02-02 17:24:47,547] [main] i.c.s.SchedulingManager - Starting new SchedulingManager instance 
INFO   [2021-02-02 17:24:47,549] [main] i.c.s.AutoSchedulingManager - Starting new AutoSchedulingManager instance. First check in 15000ms. Subsequent polls every 600000ms 
INFO   [2021-02-02 17:24:47,549] [main] i.c.ReaperApplication - Initializing JMX seed list for all clusters... 
INFO   [2021-02-02 17:24:47,566] [main] i.c.ReaperApplication - Initialized JMX seed list for all clusters. 
INFO   [2021-02-02 17:24:47,566] [main] i.c.ReaperApplication - resuming pending repair runs 
INFO   [2021-02-02 17:24:47,576] [main] i.c.ReaperApplication - Initialization complete! 
WARN   [2021-02-02 17:24:47,576] [main] i.c.ReaperApplication - Reaper is ready to get things done! 
INFO   [2021-02-02 17:24:47,576] [ReaperApplication-scheduler] i.c.ReaperApplication - Purged 0 repair runs from history 
INFO   [2021-02-02 17:24:47,585] [main] i.d.s.ServerFactory - Starting cassandra-reaper
_________                                          .___               __________
\_   ___ \_____    ______ ___________    ____    __| _/___________    \______   \ ____ _____  ______   ___________
/    \  \/\__  \  /  ___//  ___/\__  \  /    \  / __ |\_  __ \__  \    |       _// __ \\__  \ \____ \_/ __ \_  __ \
\     \____/ __ \_\___ \ \___ \  / __ \|   |  \/ /_/ | |  | \// __ \_  |    |   \  ___/ / __ \|  |_> >  ___/|  | \/
 \______  (____  /____  >____  >(____  /___|  /\____ | |__|  (____  /  |____|_  /\___  >____  /   __/ \___  >__|
        \/     \/     \/     \/      \/     \/      \/            \/          \/     \/     \/|__|        \/

INFO   [2021-02-02 17:24:47,667] [main] o.e.j.s.SetUIDListener - Opened application@8c43966{HTTP/1.1,[http/1.1]}{0.0.0.0:80} 
INFO   [2021-02-02 17:24:47,667] [main] o.e.j.s.SetUIDListener - Opened admin@1efac5b9{HTTP/1.1,[http/1.1]}{0.0.0.0:4301} 
INFO   [2021-02-02 17:24:47,669] [main] o.e.j.s.Server - jetty-9.4.z-SNAPSHOT; built: 2019-04-29T20:42:08.989Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 1.8.0_275-b01 
INFO   [2021-02-02 17:24:47,684] [main] o.e.j.s.session - DefaultSessionIdManager workerName=node0 
INFO   [2021-02-02 17:24:47,684] [main] o.e.j.s.session - No SessionScavenger set, using defaults 
INFO   [2021-02-02 17:24:47,686] [main] o.e.j.s.session - node0 Scavenging every 600000ms 
INFO   [2021-02-02 17:24:48,441] [main] i.d.j.DropwizardResourceConfig - The following paths were found for the configured resources:

    GET     /cluster (io.cassandrareaper.resources.ClusterResource)
    POST    /cluster (io.cassandrareaper.resources.ClusterResource)
    POST    /cluster/auth (io.cassandrareaper.resources.ClusterResource)
    PUT     /cluster/auth/{cluster_name} (io.cassandrareaper.resources.ClusterResource)
    DELETE  /cluster/{cluster_name} (io.cassandrareaper.resources.ClusterResource)
    GET     /cluster/{cluster_name} (io.cassandrareaper.resources.ClusterResource)
    PUT     /cluster/{cluster_name} (io.cassandrareaper.resources.ClusterResource)
    GET     /cluster/{cluster_name}/tables (io.cassandrareaper.resources.ClusterResource)
    GET     /crypto/encrypt/{text} (io.cassandrareaper.resources.CryptoResource)
    GET     /diag_event/sse_listen/{id} (io.cassandrareaper.resources.DiagEventSseResource)
    GET     /diag_event/subscription (io.cassandrareaper.resources.DiagEventSubscriptionResource)
    POST    /diag_event/subscription (io.cassandrareaper.resources.DiagEventSubscriptionResource)
    DELETE  /diag_event/subscription/{id} (io.cassandrareaper.resources.DiagEventSubscriptionResource)
    GET     /diag_event/subscription/{id} (io.cassandrareaper.resources.DiagEventSubscriptionResource)
    GET     /jwt (io.cassandrareaper.resources.auth.ShiroJwtProvider)
    POST    /login (io.cassandrareaper.resources.auth.LoginResource)
    POST    /logout (io.cassandrareaper.resources.auth.LoginResource)
    GET     /node/clientRequestLatencies/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /node/compactions/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /node/dropped/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /node/streams/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /node/tokens/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /node/tpstats/{clusterName}/{host} (io.cassandrareaper.resources.NodeStatsResource)
    GET     /ping (io.cassandrareaper.resources.PingResource)
    HEAD    /ping (io.cassandrareaper.resources.PingResource)
    GET     /repair_run (io.cassandrareaper.resources.RepairRunResource)
    POST    /repair_run (io.cassandrareaper.resources.RepairRunResource)
    GET     /repair_run/cluster/{cluster_name} (io.cassandrareaper.resources.RepairRunResource)
    POST    /repair_run/purge (io.cassandrareaper.resources.RepairRunResource)
    DELETE  /repair_run/{id} (io.cassandrareaper.resources.RepairRunResource)
    GET     /repair_run/{id} (io.cassandrareaper.resources.RepairRunResource)
    PUT     /repair_run/{id} (io.cassandrareaper.resources.RepairRunResource)
    PUT     /repair_run/{id}/intensity/{intensity} (io.cassandrareaper.resources.RepairRunResource)
    GET     /repair_run/{id}/segments (io.cassandrareaper.resources.RepairRunResource)
    POST    /repair_run/{id}/segments/abort/{segment_id} (io.cassandrareaper.resources.RepairRunResource)
    PUT     /repair_run/{id}/state/{state} (io.cassandrareaper.resources.RepairRunResource)
    GET     /repair_schedule (io.cassandrareaper.resources.RepairScheduleResource)
    POST    /repair_schedule (io.cassandrareaper.resources.RepairScheduleResource)
    GET     /repair_schedule/cluster/{cluster_name} (io.cassandrareaper.resources.RepairScheduleResource)
    POST    /repair_schedule/start/{id} (io.cassandrareaper.resources.RepairScheduleResource)
    DELETE  /repair_schedule/{id} (io.cassandrareaper.resources.RepairScheduleResource)
    GET     /repair_schedule/{id} (io.cassandrareaper.resources.RepairScheduleResource)
    PUT     /repair_schedule/{id} (io.cassandrareaper.resources.RepairScheduleResource)
    GET     /snapshot/cluster/{clusterName} (io.cassandrareaper.resources.SnapshotResource)
    POST    /snapshot/cluster/{clusterName} (io.cassandrareaper.resources.SnapshotResource)
    DELETE  /snapshot/cluster/{clusterName}/{snapshotName} (io.cassandrareaper.resources.SnapshotResource)
    GET     /snapshot/{clusterName}/{host} (io.cassandrareaper.resources.SnapshotResource)
    POST    /snapshot/{clusterName}/{host} (io.cassandrareaper.resources.SnapshotResource)
    DELETE  /snapshot/{clusterName}/{host}/{snapshotName} (io.cassandrareaper.resources.SnapshotResource)

INFO   [2021-02-02 17:24:48,443] [main] o.e.j.s.h.ContextHandler - Started i.d.j.MutableServletContextHandler@77c692b4{/cassandra-reaper,null,AVAILABLE} 
INFO   [2021-02-02 17:24:48,447] [main] i.d.s.AdminEnvironment - tasks = 

    POST    /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
    POST    /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)

INFO   [2021-02-02 17:24:48,453] [main] o.e.j.s.h.ContextHandler - Started i.d.j.MutableServletContextHandler@722b2728{/,null,AVAILABLE} 
INFO   [2021-02-02 17:24:48,459] [main] o.e.j.s.AbstractConnector - Started application@8c43966{HTTP/1.1,[http/1.1]}{0.0.0.0:80} 
INFO   [2021-02-02 17:24:48,461] [main] o.e.j.s.AbstractConnector - Started admin@1efac5b9{HTTP/1.1,[http/1.1]}{0.0.0.0:4301} 
INFO   [2021-02-02 17:24:48,461] [main] o.e.j.s.Server - Started @6066ms 
10.1.0.20 - - [02/Feb/2021:17:25:46 +0000] "GET /cassandra-reaper/webui HTTP/1.1" 302 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 42
10.1.0.20 - - [02/Feb/2021:17:25:47 +0000] "GET /cassandra-reaper/webui/login.html HTTP/1.1" 200 1929 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 14
10.1.0.20 - - [02/Feb/2021:17:26:28 +0000] "GET /cassandra-reaper/ HTTP/1.1" 403 51 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 4
10.1.0.20 - - [02/Feb/2021:17:26:33 +0000] "GET /cassandra-reaper/webui HTTP/1.1" 302 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 1
10.1.0.20 - - [02/Feb/2021:17:27:38 +0000] "POST /cassandra-reaper/login HTTP/1.1" 204 0 "https://my-super-website.com/cassandra-reaper/webui/login.html" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 59
10.1.0.20 - - [02/Feb/2021:17:28:48 +0000] "GET /cassandra-reaper/webui/index.html HTTP/1.1" 200 1932 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" 4

any clues with be helpfull

thx

┆Issue is synchronized with this Jira Story by Unito

iamvishnuks commented 3 years ago

Facing same issue

adejanovski commented 3 years ago

Isn't this fixed by this (unreleased) commit? https://github.com/thelastpickle/cassandra-reaper/commit/bb797a34f3ebbb452cb6dab7f2b90f2f3164d6fd

sguenfred commented 3 years ago

I have tried to build docker image from source but it fails

➜  docker-build git:(master) docker images prune
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
➜  docker-build git:(master) docker-compose build
Building with native build. Learn about native build in Compose here: https://docs.docker.com/go/compose-native-build/
Building build
Sending build context to Docker daemon  93.19MB

Step 1/13 : FROM ubuntu:16.04
 ---> 8185511cd5ad
Step 2/13 : ENV WORKDIR /usr/src/app
 ---> Using cache
 ---> 20f4ec335548
Step 3/13 : RUN mkdir -p ${WORKDIR}
 ---> Using cache
 ---> 32a295f1e82a
Step 4/13 : WORKDIR ${WORKDIR}
 ---> Using cache
 ---> 25d3ab27e125
Step 5/13 : RUN apt-get update     && apt-get install -y         curl     && curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh     && bash nodesource_setup.sh     && apt-get update     && apt-get install -y         build-essential         git         maven         nodejs         openjdk-8-jdk         rpm         ruby-dev     && mvn --version     && gem install fpm     && npm install -g bower
 ---> Using cache
 ---> 108fa899b83d
Step 6/13 : COPY pom.xml /tmp/
 ---> Using cache
 ---> 5de9dbe18f66
Step 7/13 : RUN mkdir -p /tmp/src
 ---> Using cache
 ---> 0dc11c103b7a
Step 8/13 : COPY src/server /tmp/src/server
 ---> Using cache
 ---> c710104e517c
Step 9/13 : COPY src/ui /tmp/src/ui
 ---> Using cache
 ---> dac0e3946265
Step 10/13 : WORKDIR /tmp
 ---> Using cache
 ---> 5e4bebfb6e9c
Step 11/13 : WORKDIR ${WORKDIR}
 ---> Using cache
 ---> 8a530d9a45ba
Step 12/13 : COPY src/packaging/docker-build/docker-entrypoint.sh ${WORKDIR}
 ---> Using cache
 ---> 1d0dc3f4ac29
Step 13/13 : ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
 ---> Using cache
 ---> 33ef0107c4e3
Successfully built 33ef0107c4e3
Successfully tagged docker-build_build:latest
➜  docker-build git:(master) docker-compose run build
Creating docker-build_build_run ... done
+ cd /usr/src/app/cassandra-reaper
++ mvn help:evaluate
++ cut -f2
++ grep '^VER'
++ printf 'VER\t${project.version}'
+ export VERSION=2.2.O-SNAPSHOT
+ VERSION=2.2.O-SNAPSHOT
+ cd /usr/src/app/cassandra-reaper/src/packaging
+ make build-packages
echo "2.2.O-SNAPSHOT..."
2.2.O-SNAPSHOT...
rm -Rf packages/*
rm -Rf build/*
mkdir -p build/usr/share/cassandra-reaper
mkdir -p build/usr/local/bin
mkdir -p build/etc/init.d
mkdir -p build/etc/cassandra-reaper
mkdir -p build/etc/cassandra-reaper/configs
mkdir -p build/etc/bash_completion.d
mkdir -p build/lib/systemd/system/
cp resource/cassandra-reaper.yaml build/etc/cassandra-reaper/
cp resource/cassandra-reaper*.yaml build/etc/cassandra-reaper/configs
cp resource/cassandra-reaper-ssl.properties build/etc/cassandra-reaper/configs
cp ../server/target/cassandra-reaper-2.2.O-SNAPSHOT.jar build/usr/share/cassandra-reaper/
cp: cannot stat '../server/target/cassandra-reaper-2.2.O-SNAPSHOT.jar': No such file or directory
Makefile:20: recipe for target 'prepare' failed
make: *** [prepare] Error 1
sguenfred commented 3 years ago

As a workaround of not vbeing able to build,i also tried to pull the master image

docker pull thelastpickle/cassandra-reaper:master

as it is stated here

https://hub.docker.com/r/thelastpickle/cassandra-reaper/

that i will have the latest commit. upon login it keeps redirecting me to a url without my /cassandra-reaper prefix