Compare commits
7 Commits
v2.2.2-uns
...
680d879d03
Author | SHA1 | Date | |
---|---|---|---|
680d879d03 | |||
a8f2da31c6 | |||
b6a59a0fb5 | |||
930ff42495 | |||
494f6d7fc7 | |||
5c0a0b43a1 | |||
bf338d0a32 |
@@ -16,10 +16,13 @@ set -o nounset
|
|||||||
|
|
||||||
# -> delete "cascade" on table "flow" cleans access, code, oidc, pkce and refresh tables.
|
# -> delete "cascade" on table "flow" cleans access, code, oidc, pkce and refresh tables.
|
||||||
|
|
||||||
|
# For table authentication_session, a simple delete on this table is enough.
|
||||||
|
# Delete all rows without reference from table flow (foreign key)
|
||||||
|
|
||||||
DSN="${DSN:-postgresql://${HYDRA_DATABASE_USER}:${HYDRA_DATABASE_PASSWORD}@${HYDRA_DATABASE_SERVICE_NAME}:${HYDRA_DATABASE_SERVICE_PORT:-5432}/hydra?sslmode=disable}"
|
DSN="${DSN:-postgresql://${HYDRA_DATABASE_USER}:${HYDRA_DATABASE_PASSWORD}@${HYDRA_DATABASE_SERVICE_NAME}:${HYDRA_DATABASE_SERVICE_PORT:-5432}/hydra?sslmode=disable}"
|
||||||
RETENTION_HOURS="${RETENTION_HOURS:-48}"
|
RETENTION_HOURS="${RETENTION_HOURS:-48}"
|
||||||
BATCH_SIZE="${BATCH_SIZE:-50}"
|
BATCH_SIZE="${BATCH_SIZE:-50}"
|
||||||
|
BATCH_SIZE_ORIG="${BATCH_SIZE}"
|
||||||
LIMIT="${LIMIT:-1000}"
|
LIMIT="${LIMIT:-1000}"
|
||||||
BEFORE_DATE="$(date +'%Y-%m-%d %H:%M:%S' --date=@$(($(date +%s) - RETENTION_HOURS * 3600)))"
|
BEFORE_DATE="$(date +'%Y-%m-%d %H:%M:%S' --date=@$(($(date +%s) - RETENTION_HOURS * 3600)))"
|
||||||
|
|
||||||
@@ -66,6 +69,7 @@ where table_schema = 'public'
|
|||||||
order by 4 desc;
|
order by 4 desc;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
log "Cleaning flow table..."
|
||||||
|
|
||||||
REMAINING_ELMTS="${LIMIT}"
|
REMAINING_ELMTS="${LIMIT}"
|
||||||
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
||||||
@@ -86,7 +90,7 @@ EOF
|
|||||||
log "${OUTPUT}"
|
log "${OUTPUT}"
|
||||||
|
|
||||||
if ! [[ "${OUTPUT}" =~ '^DELETE ' ]] ; then
|
if ! [[ "${OUTPUT}" =~ '^DELETE ' ]] ; then
|
||||||
log "Output doesn't seems OK..."
|
log "Output doesn't seem OK..."
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
OUTPUT_NB=$(echo "${OUTPUT}" | cut -d' ' -f 2)
|
OUTPUT_NB=$(echo "${OUTPUT}" | cut -d' ' -f 2)
|
||||||
@@ -101,6 +105,73 @@ EOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
log "Cleaning authentication_session table..."
|
||||||
|
|
||||||
|
BATCH_SIZE="${BATCH_SIZE_ORIG}"
|
||||||
|
REMAINING_ELMTS="${LIMIT}"
|
||||||
|
|
||||||
|
OUTPUT=$(psql "${DSN}" <<EOF
|
||||||
|
DO \$\$
|
||||||
|
BEGIN
|
||||||
|
DROP TABLE IF EXISTS hydra_cleaner.hydra_childless_auth_session;
|
||||||
|
DROP SCHEMA IF EXISTS hydra_cleaner;
|
||||||
|
CREATE SCHEMA hydra_cleaner;
|
||||||
|
CREATE TABLE hydra_cleaner.hydra_childless_auth_session AS
|
||||||
|
SELECT id
|
||||||
|
FROM hydra_oauth2_authentication_session
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hydra_oauth2_flow
|
||||||
|
WHERE hydra_oauth2_authentication_session.id = hydra_oauth2_flow.login_session_id
|
||||||
|
)
|
||||||
|
LIMIT ${REMAINING_ELMTS};
|
||||||
|
END \$\$;
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
log "${OUTPUT}"
|
||||||
|
|
||||||
|
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
||||||
|
|
||||||
|
OUTPUT=$(psql "${DSN}" <<EOF
|
||||||
|
WITH cte AS (
|
||||||
|
SELECT id
|
||||||
|
FROM hydra_cleaner.hydra_childless_auth_session
|
||||||
|
LIMIT ${BATCH_SIZE}
|
||||||
|
),
|
||||||
|
auth_session_deleted as (
|
||||||
|
DELETE
|
||||||
|
FROM hydra_oauth2_authentication_session
|
||||||
|
WHERE hydra_oauth2_authentication_session.id in (select * from cte)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hydra_oauth2_flow
|
||||||
|
WHERE hydra_oauth2_authentication_session.id = hydra_oauth2_flow.login_session_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
DELETE
|
||||||
|
FROM hydra_cleaner.hydra_childless_auth_session
|
||||||
|
WHERE hydra_cleaner.hydra_childless_auth_session.id in (select * from cte);
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
log "${OUTPUT}"
|
||||||
|
|
||||||
|
if ! [[ "${OUTPUT}" =~ '^DELETE ' ]] ; then
|
||||||
|
log "Output doesn't seem OK..."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
OUTPUT_NB=$(echo "${OUTPUT}" | cut -d' ' -f 2)
|
||||||
|
|
||||||
|
if [ "${OUTPUT_NB}" -lt "${BATCH_SIZE}" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
REMAINING_ELMTS=$((REMAINING_ELMTS - BATCH_SIZE))
|
||||||
|
if [ "${REMAINING_ELMTS}" -lt "${BATCH_SIZE}" ]; then
|
||||||
|
BATCH_SIZE="${REMAINING_ELMTS}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
log "Final estimated size:"
|
log "Final estimated size:"
|
||||||
psql "${DSN}" <<EOF
|
psql "${DSN}" <<EOF
|
||||||
|
@@ -18,7 +18,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: hydra-oidc-php-fpm
|
- name: hydra-oidc-php-fpm
|
||||||
image: reg.cadoles.com/cadoles/hydra-oidc-base:2025.5.12-develop.1308.4d1b0a4
|
image: reg.cadoles.com/cadoles/hydra-oidc-base:2025.6.13-develop.1333.aa5c382
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
@@ -55,7 +55,7 @@ spec:
|
|||||||
runAsUser: 1000
|
runAsUser: 1000
|
||||||
|
|
||||||
- name: hydra-oidc-caddy
|
- name: hydra-oidc-caddy
|
||||||
image: reg.cadoles.com/cadoles/hydra-oidc-base:2025.5.12-develop.1308.4d1b0a4
|
image: reg.cadoles.com/cadoles/hydra-oidc-base:2025.6.13-develop.1333.aa5c382
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args:
|
args:
|
||||||
[
|
[
|
||||||
@@ -97,6 +97,10 @@ spec:
|
|||||||
value: "/tmp/caddy"
|
value: "/tmp/caddy"
|
||||||
- name: CADDY_APP_ROOT_PUBLIC
|
- name: CADDY_APP_ROOT_PUBLIC
|
||||||
value: "/app/public/"
|
value: "/app/public/"
|
||||||
|
- name: CADDY_LOG_FILTER
|
||||||
|
value: healthy|metrics
|
||||||
|
- name: CADDY_LOG_SKIP
|
||||||
|
value: "true"
|
||||||
resources: {}
|
resources: {}
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
|
@@ -21,15 +21,15 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: hydra-sql-fpm
|
- name: hydra-sql-fpm
|
||||||
image: reg.cadoles.com/cadoles/hydra-sql-base:2025.5.12-develop.1303.64d1c1c
|
image: reg.cadoles.com/cadoles/hydra-sql-base:2025.7.30-develop.1146.5f2654c
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
args: ["/usr/sbin/php-fpm84", "-F", "-e"]
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- test -f /etc/php81/php-fpm.d/www.conf
|
- test -f /etc/php84/php-fpm.d/www.conf
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
@@ -61,13 +61,13 @@ spec:
|
|||||||
value: "0"
|
value: "0"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: hydra-sql-php-ini
|
- name: hydra-sql-php-ini
|
||||||
mountPath: /etc/php81/conf.d/03_base.ini
|
mountPath: /etc/php84/conf.d/03_base.ini
|
||||||
subPath: 03_base.ini
|
subPath: 03_base.ini
|
||||||
- name: sql-tmp
|
- name: sql-tmp
|
||||||
mountPath: /tmp
|
mountPath: /tmp
|
||||||
|
|
||||||
- name: hydra-sql-caddy
|
- name: hydra-sql-caddy
|
||||||
image: reg.cadoles.com/cadoles/hydra-sql-base:2025.5.12-develop.1303.64d1c1c
|
image: reg.cadoles.com/cadoles/hydra-sql-base:2025.7.30-develop.1146.5f2654c
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args: ["/usr/sbin/caddy", "run", "--adapter", "caddyfile", "--config", "/etc/caddy/Caddyfile"]
|
args: ["/usr/sbin/caddy", "run", "--adapter", "caddyfile", "--config", "/etc/caddy/Caddyfile"]
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
@@ -98,6 +98,10 @@ spec:
|
|||||||
value: "/tmp/caddy"
|
value: "/tmp/caddy"
|
||||||
- name: CADDY_APP_ROOT_PUBLIC
|
- name: CADDY_APP_ROOT_PUBLIC
|
||||||
value: "/app/public/"
|
value: "/app/public/"
|
||||||
|
- name: CADDY_LOG_FILTER
|
||||||
|
value: health|metrics
|
||||||
|
- name: CADDY_LOG_SKIP
|
||||||
|
value: "true"
|
||||||
resources: {}
|
resources: {}
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
|
@@ -19,14 +19,14 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: hydra-dispatcher-php-fpm
|
- name: hydra-dispatcher-php-fpm
|
||||||
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.5.12-develop.1306.a249b62
|
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.8.28-develop.1505.75881cb
|
||||||
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
args: ["/usr/sbin/php-fpm84", "-F", "-e"]
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- test -f /etc/php81/php-fpm.d/www.conf
|
- test -f /etc/php84/php-fpm.d/www.conf
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
@@ -51,7 +51,7 @@ spec:
|
|||||||
name: hydra-dispatcher-env
|
name: hydra-dispatcher-env
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: hydra-dispatcher-php-ini
|
- name: hydra-dispatcher-php-ini
|
||||||
mountPath: /etc/php81/conf.d/03_base.ini
|
mountPath: /etc/php84/conf.d/03_base.ini
|
||||||
subPath: 03_base.ini
|
subPath: 03_base.ini
|
||||||
- name: dispatcher-tmp
|
- name: dispatcher-tmp
|
||||||
mountPath: /tmp
|
mountPath: /tmp
|
||||||
@@ -61,7 +61,7 @@ spec:
|
|||||||
runAsGroup: 1000
|
runAsGroup: 1000
|
||||||
runAsUser: 1000
|
runAsUser: 1000
|
||||||
- name: hydra-dispatcher-caddy
|
- name: hydra-dispatcher-caddy
|
||||||
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.5.12-develop.1306.a249b62
|
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.8.28-develop.1505.75881cb
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args:
|
args:
|
||||||
[
|
[
|
||||||
@@ -100,6 +100,10 @@ spec:
|
|||||||
value: "/tmp/caddy"
|
value: "/tmp/caddy"
|
||||||
- name: CADDY_APP_ROOT_PUBLIC
|
- name: CADDY_APP_ROOT_PUBLIC
|
||||||
value: "/app/public/"
|
value: "/app/public/"
|
||||||
|
- name: CADDY_LOG_FILTER
|
||||||
|
value: health|metrics
|
||||||
|
- name: CADDY_LOG_SKIP
|
||||||
|
value: "true"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
name: http
|
name: http
|
||||||
|
Reference in New Issue
Block a user