Preserve Disk space in ImageStore for Service Fabric Managed Clusters
Published Apr 30 2024 05:12 AM 1,723 Views
Microsoft

As mentioned in this article: Service Fabric: Best Practices to preserve disk space in Image Store ImageStore keeps copied packages and provisioned packages.

In this article, we will discuss how can you configure cleaning up the copied application package for Service Fabric Managed Cluster 'SFMC'.

 

The mitigation is to set "AllowRuntimeCleanupUnusedApplicationTypesPolicy": "true".

For properties, specify the following tags:

...

    "applicationTypeVersionsCleanupPolicy": {

      "maxUnusedVersionsToKeep": 3

    }

 

Let me show you a step-by-step guide to automatically remove the unwanted application versions in your Service Fabric Managed cluster below:

 

Scenario:

- I have deployed 4 versions of my app (1 InUse - 3 UnUsed) to my managed cluster as the following:

Ahmed_Khaled_0-1714056205735.png

 

Symptom:

I need Service Fabric to do automatic cleanup for the Application Unused Versions and keep only the last 3 so as not to fill the disk space.

 

Mitigation Steps:

  1. From https://resources.azure.com/ open your managed cluster resource and open the read/write mode.
  1. Add the tag "AllowRuntimeCleanupUnusedApplicationTypesPolicy": "true"

 

Ahmed_Khaled_1-1714056205737.png

 

  1. Under fabricsettings, add the param "name": "CleanupUnusedApplicationTypes", "value": "true" under fabricsettings and set the "maxUnusedVersionsToKeep":

Ahmed_Khaled_0-1714472113259.png

 

 

  1. Click on PUT to save the changes, and I deployed the 5th version (1.0.4) to the cluster, which should make the cleaning happens for the oldest version (1.0.0)

Ahmed_Khaled_3-1714056205741.png

 

Note: The automatic clean-up should be effective after 24 hours of making those changes.

 

Ahmed_Khaled_4-1714056205742.png

Then I tried to deploy a new version, and I could see that the oldest version was also cleaned up.

Ahmed_Khaled_5-1714056205743.png

 

For manual cleanup of the ImageStoreService:

You can use PowerShell commands to delete copied packages and unregister application types as needed.

This includes using Get-ServiceFabricImageStoreContent to retrieve content and Remove-ServiceFabricApplicationPackage to delete it, as well as Unregister-ServiceFabricApplicationType to remove application packages from the image store and image cache on nodes.

Co-Authors
Version history
Last update:
‎Apr 30 2024 03:15 AM
Updated by: