OpenCSGs / csghub-installer

This repository provides installation scripts and configuration files for deploying the CSGHub instance, includes Helm charts and Docker Compose scripts to streamline the deployment process in various environments.
Apache License 2.0
6 stars 3 forks source link

failed to signin: failed to create user,error:failed to create user in db,error:ERROR: duplicate key value violates unique constraint "users_email_key" (SQLSTATE=23505) #10

Open MasonXon opened 1 day ago

MasonXon commented 1 day ago

Describe the bug When recreated casdoor pod or container, init_data.json is reloaded. It cause fronted login failed with following:

'failed to signin: failed to create user,error:failed to create user in db,error:ERROR: duplicate key value violates unique constraint "users_email_key" (SQLSTATE=23505)'

To Reproduce Steps to reproduce the behavior:

  1. helm install csghub -n csghub (wait for all pods ready)
  2. login from page with root
  3. kubectl delete pod/csghub-casdoor-xxxxxx
  4. wait for casdoor pod ready
  5. login from page with root again

Expected behavior A clear and concise description of what you expected to happen.

When casdoor pod is recreated, root user can login normally.

Screenshots If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

MasonXon commented 1 day ago

Workaround:

# Downgrade casdoor image from 1.725.0 to 1.571.0
kubectl -n csghub patch deployment csghub-casdoor -p '{"spec":{"template":{"spec":{"containers":[{"name":"casdoor","image":"opencsg-registry.cn-beijing.cr.aliyuncs.com/opencsg_public/casbin/casdoor:v1.571.0"}]}}}}'

# Restart deploy csghub-casdoor
kubectl -n csghub rollout restart deploy csghub-casdoor

# Waiting for casdoor pod ready

Details at init_data.json is reloaded when the pod is recreated.