Cleanup Sonatype Nexus Repository (Compact Blob Store) in Kubernetes

Evgeniy P
3 min readJul 1, 2023

--

When Nexus volume is filled, the Nexus database may got locked in read-only mode, which prevent us from any actions toward the Nexus repository cleanup. The database lock up volume fill limit is indicated in the database settings.

An example of the error:

com.orientechnologies.orient.core.exception.OLowDiskSpaceException: Error occurred while executing a write operation to database 'component' due to limited free space on the disk (3986 MB)

Log in to the Nexus pod and check the used space on the device:

bash-4.4$ df -h
Filesystem Size Used Avail Use% Mounted on
overlay 30G 12G 19G 39% /
tmpfs 64M 0 64M 0% /dev
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/nvme1n1 99G 95G 3.9G 97% /nexus-data
/dev/nvme0n1p1 30G 12G 19G 39% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 7.7G 12K 7.7G 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 7.7G 0 7.7G 0% /proc/acpi
tmpfs 7.7G 0 7.7G 0% /sys/firmware
bash-4.4$
/dev/nvme1n1     99G   95G  3.9G  97% /nexus-data

The preferable way is to add some additional space to a volume (5Gb in our example) and provide a Nexus Repository cleanup. The manipulation is quite simple if you add the allowVolumeExpansion: true field in the StorageClass spec. It will only be necessary to resize PVC in this case.

Now that you have access to Nexus after increasing the volume size, let’s proceed with cleaning the blob store cache.

Steps to Clean Nexus Repository from Blob Store cache

  1. Log in as Admin to Nexus.
  2. Check available Blob Stores:

3. Go to System → Tasks and run all the default Nexus tasks to clear, rebuild, and optimize stores:

4. If a Task stuck in the Running state, click the Refresh button:

If a Task stuck in the Running state for several hours, refreshing does not help, and you cannot Stop the Task, restart the Nexus pod.

5. Create “Admin — Compact blob store” Tasks for each Blob Store in Nexus:

6. Run the created “Admin — Compact blob store” Tasks and check the reduced Blob Stores’ size.

7. Log in to the Nexus pod and check the free space:

/dev/nvme1n1    104G   18G   86G  17% /nexus-data

--

--