Skip to content

Commit

Permalink
Merge pull request #1454 from arooshap/frontend-cron
Browse files Browse the repository at this point in the history
Changes to the frontend docker image and kubernetes manifest to decrease load on the CRIC servers.
  • Loading branch information
arooshap authored Mar 18, 2024
2 parents e010d42 + 83e81c1 commit a2711b6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ RUN crontab /data/crontab.txt
ADD run.sh $WDIR/run.sh
ADD monitor.sh $WDIR/monitor.sh
ADD alerts.sh $WDIR/alerts.sh
COPY authmap-prod.cron /tmp/authmap-prod.cron
COPY authmap-preprod.cron /tmp/data/tools/authmap-preprod.cron
COPY authmap-test.cron /tmp/authmap-test.cron
COPY copy_cron.sh $WDIR/copy_cron.sh



ENV PATH="${WDIR}/cmsweb/bin:${WDIR}:${WDIR}/gopath/bin:${PATH}"

Expand Down
2 changes: 2 additions & 0 deletions docker/frontend/authmap-preprod.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/15 * * * * sleep $((RANDOM % 601)); /data/srv/current/config/frontend/mkauthmap -c /data/srv/current/config/frontend/mkauth.conf -o /data/srv/state/frontend/etc/authmap.json --cert /etc/robots/robotcert.pem --key /etc/robots/robotkey.pem --ca-cert /etc/ssl/certs/CERN-bundle.pem ; [ $? -ne 0 ] && /bin/bash /data/alerts.sh

2 changes: 2 additions & 0 deletions docker/frontend/authmap-prod.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/15 * * * * sleep $((RANDOM % 601)); /data/srv/current/config/frontend/mkauthmap -c /data/srv/current/config/frontend/mkauth.conf -o /data/srv/state/frontend/etc/authmap.json --cert /etc/robots/robotcert.pem --key /etc/robots/robotkey.pem --ca-cert /etc/ssl/certs/CERN-bundle.pem ; [ $? -ne 0 ] && /bin/bash /data/alerts.sh

2 changes: 2 additions & 0 deletions docker/frontend/authmap-test.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/30 * * * * sleep $((RANDOM % 901)); /data/srv/current/config/frontend/mkauthmap -c /data/srv/current/config/frontend/mkauth.conf -o /data/srv/state/frontend/etc/authmap.json --cert /etc/robots/robotcert.pem --key /etc/robots/robotkey.pem --ca-cert /etc/ssl/certs/CERN-bundle.pem ; [ $? -ne 0 ] && /bin/bash /data/alerts.sh

17 changes: 17 additions & 0 deletions docker/frontend/copy_cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if [ "$ENVIRONMENT" = "k8s-prod" ]; then
# Copy the production cron file
echo "Copying authmap-prod.cron"
cp /tmp/authmap-prod.cron /tmp/authmap.cron
elif [ "$ENVIRONMENT" = "k8s-preprod" ]; then
# Copy the development cron file
echo "Copying authmap-preprod.cron"
cp /tmp/authmap-preprod.cron /tmp/authmap.cron
elif [ "$ENVIRONMENT" = "k8s-test" ]; then
# Copy the test cron file
echo "Copying authmap-test.cron"
cp /tmp/authmap-test.cron /tmp/authmap.cron

else
echo "Unsupported environment: $ENVIRONMENT"
exit 1
fi
3 changes: 3 additions & 0 deletions docker/frontend/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,8 @@ crontab -l | \
# add proxy generation via robot certificate
crontab -l | egrep -v "reboot|ProxyRenew|LogArchive|ServerMonitor" > /tmp/mycron
echo "0 0 * * * sudo /usr/sbin/fetch-crl" >> /tmp/mycron
sed -i '/mkauthmap/d' /tmp/mycron
chmod +x copy_cron.sh && ./copy_cron.sh && cat /tmp/authmap.cron >> /tmp/mycron

crontab /tmp/mycron
rm /tmp/mycron
2 changes: 2 additions & 0 deletions kubernetes/cmsweb/daemonset/frontend-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: ENVIRONMENT
value: k8s #k8s#
ports:
- containerPort: 80
name: http
Expand Down

0 comments on commit a2711b6

Please sign in to comment.