Compare commits
1 Commits
680d879d03
...
a08dbfe270
Author | SHA1 | Date | |
---|---|---|---|
a08dbfe270 |
@@ -16,8 +16,7 @@ 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.
|
# For table authentication_session, a simple delete on this table should be 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}"
|
||||||
@@ -69,7 +68,6 @@ 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
|
||||||
@@ -105,55 +103,23 @@ EOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Cleaning authentication_session table..."
|
|
||||||
|
|
||||||
BATCH_SIZE="${BATCH_SIZE_ORIG}"
|
BATCH_SIZE="${BATCH_SIZE_ORIG}"
|
||||||
REMAINING_ELMTS="${LIMIT}"
|
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
|
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
||||||
|
|
||||||
OUTPUT=$(psql "${DSN}" <<EOF
|
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
|
DELETE
|
||||||
FROM hydra_cleaner.hydra_childless_auth_session
|
FROM hydra_oauth2_authentication_session
|
||||||
WHERE hydra_cleaner.hydra_childless_auth_session.id in (select * from cte);
|
WHERE id = ANY (
|
||||||
|
array(
|
||||||
|
SELECT id
|
||||||
|
FROM hydra_oauth2_authentication_session
|
||||||
|
WHERE authenticated_at < '${BEFORE_DATE}'
|
||||||
|
LIMIT ${BATCH_SIZE}
|
||||||
|
)
|
||||||
|
);
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
log "${OUTPUT}"
|
log "${OUTPUT}"
|
||||||
|
|
||||||
@@ -173,6 +139,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
log "Final estimated size:"
|
log "Final estimated size:"
|
||||||
psql "${DSN}" <<EOF
|
psql "${DSN}" <<EOF
|
||||||
select
|
select
|
||||||
|
@@ -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.8.28-develop.1505.75881cb
|
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.6.13-develop.1332.c8d277f
|
||||||
args: ["/usr/sbin/php-fpm84", "-F", "-e"]
|
args: ["/usr/sbin/php-fpm81", "-F", "-e"]
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- test -f /etc/php84/php-fpm.d/www.conf
|
- test -f /etc/php81/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/php84/conf.d/03_base.ini
|
mountPath: /etc/php81/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.8.28-develop.1505.75881cb
|
image: reg.cadoles.com/cadoles/hydra-dispatcher-base:2025.6.13-develop.1332.c8d277f
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args:
|
args:
|
||||||
[
|
[
|
||||||
|
Reference in New Issue
Block a user