Skip to content

Commit

Permalink
Merge pull request #129 from infrawatch/release-prep-1.5.4
Browse files Browse the repository at this point in the history
STF 1.5.4 release ops
  • Loading branch information
vkmc authored Feb 14, 2024
2 parents ccfe248 + 37757b0 commit 02aeeb6
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- project:
name: infrawatch/sg-core
templates:
- stf-crc-jobs
2 changes: 2 additions & 0 deletions devstack/observabilityclient-files/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
host: localhost
port: 9090
147 changes: 115 additions & 32 deletions devstack/plugin.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,134 @@
function preinstall_sg-core {
install_package $SG_CORE_CONTAINER_EXECUTABLE
function install_container_executable {
if install_package podman; then
SG_CORE_CONTAINER_EXECUTABLE="podman"
elif install_package docker.io; then
sudo chown stack:docker /var/run/docker.sock
sudo usermod -aG docker stack
SG_CORE_CONTAINER_EXECUTABLE="docker"
else
echo_summary "Couldn't install podman or docker"
return 1
fi
if is_ubuntu; then
install_package uidmap
fi
}

### sg-core ###
function install_sg-core {
$SG_CORE_CONTAINER_EXECUTABLE pull $SG_CORE_CONTAINER_IMAGE
}

function configure_sg-core {
sudo mkdir -p `dirname $SG_CORE_CONF`
sudo cp $SG_CORE_DIR/devstack/sg-core.conf.yaml $SG_CORE_CONF
sudo cp $SG_CORE_DIR/devstack/sg-core-files/sg-core.conf.yaml $SG_CORE_CONF
}

function init_sg-core {
$SG_CORE_CONTAINER_EXECUTABLE run -v $SG_CORE_CONF:/etc/sg-core.conf.yaml --network host --name sg-core -d $SG_CORE_CONTAINER_IMAGE
}

### prometheus ###
function install_prometheus {
$SG_CORE_CONTAINER_EXECUTABLE pull $PROMETHEUS_CONTAINER_IMAGE
}

function configure_prometheus {
BASE_CONFIG_FILE=$SG_CORE_DIR/devstack/prometheus-files/prometheus.yml
RESULT_CONFIG_FILE=$SG_CORE_WORKDIR/prometheus.yml

cat $BASE_CONFIG_FILE > $RESULT_CONFIG_FILE

SERVICES=$(echo $PROMETHEUS_SERVICE_SCRAPE_TARGETS | tr "," "\n")
for SERVICE in ${SERVICES[@]}
do
cat $SG_CORE_DIR/devstack/prometheus-files/scrape_configs/$SERVICE >> $RESULT_CONFIG_FILE
done

if [[ $PROMETHEUS_CUSTOM_SCRAPE_TARGETS != "" ]]; then
echo " - job_name: 'custom'" >> $RESULT_CONFIG_FILE
echo " static_configs:" >> $RESULT_CONFIG_FILE
echo " - targets: [$PROMETHEUS_CUSTOM_SCRAPE_TARGETS]" >> $RESULT_CONFIG_FILE
fi

sudo mkdir -p `dirname $PROMETHEUS_CONF`
sudo cp $RESULT_CONFIG_FILE $PROMETHEUS_CONF

sudo cp $SG_CORE_DIR/devstack/observabilityclient-files/prometheus.yaml /etc/openstack/prometheus.yaml
}

function init_prometheus {
$SG_CORE_CONTAINER_EXECUTABLE run -v $PROMETHEUS_CONF:/etc/prometheus/prometheus.yml --network host --name prometheus -d $PROMETHEUS_CONTAINER_IMAGE --config.file=/etc/prometheus/prometheus.yml --web.enable-admin-api
}


# check for service enabled
if is_service_enabled sg-core; then

if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
# Set up system services
echo_summary "Configuring system services sg-core"
preinstall_sg-core

elif [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source
echo_summary "Installing sg-core"
install_sg-core

elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configuring sg-core"
configure_sg-core

elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the sg-core service
echo_summary "Initializing sg-core"
init_sg-core
fi

if [[ "$1" == "unstack" ]]; then
$SG_CORE_CONTAINER_EXECUTABLE stop sg-core
$SG_CORE_CONTAINER_EXECUTABLE rm sg-core
fi

if [[ "$1" == "clean" ]]; then
$SG_CORE_CONTAINER_EXECUTABLE rmi sg-core:latest
fi
mkdir $SG_CORE_WORKDIR
if [[ $SG_CORE_ENABLE = true ]]; then
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
# Set up system services
echo_summary "Configuring system services for sg-core"
install_container_executable

elif [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source
echo_summary "Installing sg-core"
install_sg-core

elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configuring sg-core"
configure_sg-core

elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the sg-core service
echo_summary "Initializing sg-core"
init_sg-core
fi

if [[ "$1" == "unstack" ]]; then
$SG_CORE_CONTAINER_EXECUTABLE stop sg-core
$SG_CORE_CONTAINER_EXECUTABLE rm -f sg-core
fi

if [[ "$1" == "clean" ]]; then
$SG_CORE_CONTAINER_EXECUTABLE rmi $SG_CORE_CONTAINER_IMAGE
fi
fi
if [[ $PROMETHEUS_ENABLE = true ]]; then
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
# Set up system services
echo_summary "Configuring system services prometheus"
install_container_executable

elif [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source
echo_summary "Installing prometheus"
install_prometheus

elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Configure after the other layer 1 and 2 services have been configured
echo_summary "Configuring prometheus"
configure_prometheus

elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the prometheus service
echo_summary "Initializing prometheus"
init_prometheus
fi

if [[ "$1" == "unstack" ]]; then
$PROMETHEUS_CONTAINER_EXECUTABLE stop prometheus
$PROMETHEUS_CONTAINER_EXECUTABLE rm -f prometheus
fi

if [[ "$1" == "clean" ]]; then
$PROMETHEUS_CONTAINER_EXECUTABLE rmi $PROMETHEUS_CONTAINER_IMAGE
fi

fi
rm -rf $SG_CORE_WORKDIR
fi

4 changes: 4 additions & 0 deletions devstack/prometheus-files/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.

scrape_configs:
4 changes: 4 additions & 0 deletions devstack/prometheus-files/scrape_configs/prometheus
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- job_name: 'prometheus'

static_configs:
- targets: ['localhost:9090']
4 changes: 4 additions & 0 deletions devstack/prometheus-files/scrape_configs/sg-core
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- job_name: 'sg-core'

static_configs:
- targets: ['localhost:3000']
24 changes: 23 additions & 1 deletion devstack/settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@ plugin_requires sg-core ceilometer
enable_service sg-core
enable_service ceilometer

### sg-core ###
SG_CORE_ENABLE=${SG_CORE_ENABLE:-true}

SG_CORE_DIR=$DEST/sg-core
SG_CORE_CONF_DIR=/etc/sg-core
SG_CORE_CONF=$SG_CORE_CONF_DIR/sg-core.conf.yaml
SG_CORE_WORKDIR=$SG_CORE_DIR/devstack/workdir

SG_CORE_CONTAINER_REPOSITORY=${SG_CORE_CONTAINER_REPOSITORY:-quay.io/infrawatch/sg-core}
SG_CORE_CONTAINER_TAG=${SG_CORE_CONTAINER_TAG:-latest}
SG_CORE_CONTAINER_IMAGE=$SG_CORE_CONTAINER_REPOSITORY:$SG_CORE_CONTAINER_TAG

SG_CORE_CONTAINER_EXECUTABLE="podman"
### prometheus ###
PROMETHEUS_ENABLE=${PROMETHEUS_ENABLE:-true}

PROMETHEUS_CONF_DIR=/etc/prometheus
PROMETHEUS_CONF=$PROMETHEUS_CONF_DIR/prometheus.yml

PROMETHEUS_CONTAINER_REPOSITORY=${PROMETHEUS_CONTAINER_REPOSITORY:-quay.io/prometheus/prometheus}
PROMETHEUS_CONTAINER_TAG=${PROMETHEUS_CONTAINER_TAG:-latest}
PROMETHEUS_CONTAINER_IMAGE=$PROMETHEUS_CONTAINER_REPOSITORY:$PROMETHEUS_CONTAINER_TAG

# It's assumed, that each service scrape target has its own same named
# file in the scrape_configs folder
# List of "," delimited names
# Currently supported values are "sg-core" and "prometheus"
PROMETHEUS_SERVICE_SCRAPE_TARGETS=${PROMETHEUS_SERVICE_SCRAPE_TARGETS:="sg-core"}

# List of "," delimited targets. Each target is <ip>:<port>
PROMETHEUS_CUSTOM_SCRAPE_TARGETS=${PROMETHEUS_CUSTOM_SCRAPE_TARGETS:-""}

File renamed without changes.

0 comments on commit 02aeeb6

Please sign in to comment.