@@ -1797,6 +1797,32 @@ func undeployStaleReleases(ctx context.Context, c client.Client, clusterSummary
17971797 return nil , err
17981798 }
17991799
1800+ if clusterSummary .Spec .ClusterProfileSpec .SyncMode != configv1beta1 .SyncModeDryRun {
1801+ // If another ClusterSummary is queued to manage this chart in this cluster, do not uninstall.
1802+ // Let the other ClusterSummary take it over.
1803+
1804+ currentChart := & configv1beta1.HelmChart {
1805+ ReleaseNamespace : managedHelmReleases [i ].Namespace ,
1806+ ReleaseName : managedHelmReleases [i ].Name ,
1807+ }
1808+ otherRegisteredClusterSummaries := chartManager .GetRegisteredClusterSummariesForChart (
1809+ clusterSummary .Spec .ClusterNamespace , clusterSummary .Spec .ClusterName ,
1810+ clusterSummary .Spec .ClusterType , currentChart )
1811+ if len (otherRegisteredClusterSummaries ) > 1 {
1812+ // Immediately unregister so next inline ClusterSummary can take this over
1813+ chartManager .UnregisterClusterSummaryForChart (clusterSummary , currentChart )
1814+ err = requeueAllOtherClusterSummaries (ctx , c , clusterSummary .Spec .ClusterNamespace ,
1815+ otherRegisteredClusterSummaries , logger )
1816+ if err != nil {
1817+ // TODO: Handle errors to prevent bad state. ClusterSummary no longer manage the chart,
1818+ // but no other ClusterSummary instance has been requeued.
1819+ return nil , err
1820+ }
1821+
1822+ continue
1823+ }
1824+ }
1825+
18001826 if err := uninstallRelease (ctx , clusterSummary , managedHelmReleases [i ].Name ,
18011827 managedHelmReleases [i ].Namespace , kubeconfig , & registryClientOptions {}, nil ,
18021828 logger ); err != nil {
0 commit comments