Delete User Functionality


The user deletion requirement in Lern has originated from the below requirement.

PRD: [PRD] Delete Account functionality

BE Design Lern - [Design] Delete Account Functionality

FE Design Lern - [Design] [Front-end]Delete User Functionality

What is changing?

The user can request for deletion of their account in Sunbird, this means two primary actions to happen.

  1. The user's Personal Identifiable Information (PII) needs to be removed

  2. The assets created by this user (such as questions, question sets, content, etc.) need to be transferred to an identified user.

Release Tags:

ComponentsBuild Jenkins JobBuild TagDeploy Jenkins JobDeploy TagComment





To onboard the delete user API

Cassandra Migration



Select the sunbird in cassandra_keyspace_to_migrate while deploying

script_repo_branch_or_tag: release-7.0.0_RC3

UserOrg Service



Kafka Setup







Define the core_vault_sunbird_keycloak_user_federation_provider_id in Lern inventory secret. Add user-deletion-cleanup and ml-user-delete into job list and deploy it.

Data Product



Code changes

  • For making the delete user functionality work through the flink job, the adapter needs to trigger the kafka event, For more details about that refer the below link,

  • For more details on the user deletion cleanup flink job, please visit

This flink job was introduced as part of the 7.0.0 release, if any adopter wants to use this feature before the release have to configure and use this flink job.

  1. Added below partition related settings and replication_factor related settings in ansible/roles/setup-lern-kafka/defaults/main.yml file of data pipeline repository.

   - name: delete.user
    retention_time: 172800000
    replication_factor: 1
   - name: delete.user
    num_of_partitions: 2
    replication_factor: 1
  1. Added below user delete flinkjob related configuration in kubernetes/helm_charts/datapipeline_jobs/values.j2 file of data pipeline repository.

  user-deletion-cleanup: |+
    include file("/data/flink/conf/base-config.conf")
    kafka {
      input.topic = ${job.env}".delete.user"
      groupId = ${job.env}"-delete-user-group"
    task {
      user.deletion.cleanup.parallelism = {{ user_deletion_cleanup_job_parallelism }}

    service {
        lms {
            basePath = "{{ lms_service_base_url }}"
        userorg {
            basePath = "{{ userorg_service_base_url }}"

    user_read_api = "/user/v5/read/"
    batch_search_api = "/course/v1/batch/list"

    user {
        keyspace = "sunbird"
        lookup.table = "user_lookup"
        table = "user"
        externalIdentity.table = "usr_external_identity"
        org.table = "user_organisation"

  flink-conf: |+
    jobmanager.memory.flink.size: {{ flink_job_names['user-deletion-cleanup'].jobmanager_memory }}
    taskmanager.memory.flink.size: {{ flink_job_names['user-deletion-cleanup'].taskmanager_memory }}
    taskmanager.numberOfTaskSlots: {{ flink_job_names['user-deletion-cleanup'].taskslots }}
    parallelism.default: 1
    jobmanager.execution.failover-strategy: region 0.1
  1. Added below user delete flinkjob related configuration in kubernetes/ansible/roles/flink-jobs-deploy/defaults/main.yml of data pipeline repository

user_deletion_cleanup_job_consumer_parallelism: 1
user_deletion_cleanup_job_parallelism: 1
    job_class_name: 'org.sunbird.job.deletioncleanup.task.UserDeletionCleanupStreamTask'
    replica: 1
    jobmanager_memory: 1024m
    taskmanager_memory: 1024m
    taskslots: 1
    cpu_requests: 0.3

Ownership transfer delete user assets report:

This report was introduced as part of the 8.0.0 release, if any adopter wants to use this feature before the release have to use the above flink job

  1. Added below ownership transfer delete user assets report related configuration in ansible/roles/lern-data-products-deploy/templates/lern-model-config.j2 of data products repository.

if [ ! -z "$3" ]; then specificUserId=$3; configuredUserId=$3; fi #used as specfic user id in usercacheindxerjob,used as configured user id in deleteusersassetsreportjob
if [ ! -z "$5" ]; then refreshUserData=$5; configuredChannel=$5;fi #used as refreshUserData flag in usercacheindxerjob,used as configured channel flag in deleteusersassetsreportjob

echo '{"search":{"type":"none"},"model":"","modelParams":{"store":"{{dp_object_store_type}}","storageKeyConfig":"storage.key.config","storageSecretConfig":"storage.secret.config","storageContainer":"{{reports_container}}","storageEndpoint":"{{dp_storage_endpoint_config}}","configuredUserId":'$configuredUserId',"configuredOrganisationId":[],"configuredChannel":'$configuredChannel', "sparkCassandraConnectionHost":"{{ core_cassandra_host }}"}}'
  1. Added below ownership transfer delete user assets report related configuration in ansible/roles/lern-data-products-deploy/templates/lern-run-job.j2 of data products repository

"delete-users-assets-report-job") echo ''
  1. Added below ownership transfer delete user assets report related configuration in lern-data-products/src/main/resources/application.conf of data products repository.""""

To learn more about Delete user Assets report visit here Jenkins Job Details For the deployment of the above flink job:


Adoption of the feature Through API

This API was introduced as part of the 7.0.0 release and can be used directly from this release. Before to this release adopters have to use either the flink job or extend this logic

Delete user API

  1. Added the below configuration in the user org service application.conf file of user org service

        router = smallest-mailbox-pool
        nr-of-instances = 5
        dispatcher = brr-usr-dispatcher
         dispatcher =
  1. Added the below property in external related to user delete kafka topic in user org service

  1. Added the below configuration in ansible/roles/kong-api/defaults/main.yml for owuser delete API in sunbird devops repository.

- name: deleteUser
  uris: "{{ user_service_prefix }}/v1/delete"
  upstream_url: "{{ userorg_service_url }}/v1/user/delete"
  strip_uri: true
  - name: jwt
  - name: cors
  - "{{ statsd_pulgin }}"
  - name: acl
    - userUpdate
  - name: rate-limiting
    config.policy: local
    config.hour: "{{ medium_rate_limit_per_hour }}"
    config.limit_by: credential
  - name: request-size-limiting
    config.allowed_payload_size: "{{ medium_request_size_limit }}"
  - name: opa-checks
    config.required: true
    config.enabled: true
  1. Added the user delete topic to the userorgservice.env file in Sunbird DevOps repository.


Last updated