@@ -15,6 +15,8 @@ import (
1515 "github.com/stackrox/acs-fleet-manager/internal/central/pkg/api/dbapi"
1616 "github.com/stackrox/acs-fleet-manager/internal/central/pkg/centrals/types"
1717 "github.com/stackrox/acs-fleet-manager/internal/central/pkg/config"
18+ "github.com/stackrox/acs-fleet-manager/internal/central/pkg/externaldns"
19+ "github.com/stackrox/acs-fleet-manager/internal/central/pkg/presenters"
1820 "github.com/stackrox/acs-fleet-manager/internal/central/pkg/rhsso"
1921 "github.com/stackrox/acs-fleet-manager/pkg/api"
2022 "github.com/stackrox/acs-fleet-manager/pkg/auth"
@@ -137,13 +139,14 @@ type centralService struct {
137139 iamConfig * iam.IAMConfig
138140 rhSSODynamicClientsAPI * dynamicClientAPI.AcsTenantsApiService
139141 telemetry * Telemetry
142+ managedCentralPresenter * presenters.ManagedCentralPresenter
140143}
141144
142145// NewCentralService ...
143146func NewCentralService (connectionFactory * db.ConnectionFactory , clusterService ClusterService ,
144147 iamConfig * iam.IAMConfig , centralConfig * config.CentralConfig , dataplaneClusterConfig * config.DataplaneClusterConfig , awsConfig * config.AWSConfig ,
145148 quotaServiceFactory QuotaServiceFactory , awsClientFactory aws.ClientFactory ,
146- clusterPlacementStrategy ClusterPlacementStrategy , amsClient ocm.AMSClient , telemetry * Telemetry ) CentralService {
149+ clusterPlacementStrategy ClusterPlacementStrategy , amsClient ocm.AMSClient , telemetry * Telemetry , managedCentralPresenter * presenters. ManagedCentralPresenter ) CentralService {
147150 return & centralService {
148151 connectionFactory : connectionFactory ,
149152 clusterService : clusterService ,
@@ -157,6 +160,7 @@ func NewCentralService(connectionFactory *db.ConnectionFactory, clusterService C
157160 amsClient : amsClient ,
158161 rhSSODynamicClientsAPI : dynamicclients .NewDynamicClientsAPI (iamConfig .RedhatSSORealm ),
159162 telemetry : telemetry ,
163+ managedCentralPresenter : managedCentralPresenter ,
160164 }
161165}
162166
@@ -597,8 +601,12 @@ func (k *centralService) Delete(centralRequest *dbapi.CentralRequest, force bool
597601 if err != nil {
598602 return errors .NewWithCause (errors .ErrorGeneral , err , "failed to get routes" )
599603 }
604+ managedCentral , err := k .managedCentralPresenter .PresentManagedCentral (centralRequest )
605+ if err != nil {
606+ return errors .NewWithCause (errors .ErrorGeneral , err , "failed to present managed central" )
607+ }
600608 // Only delete the routes when they are set
601- if routes != nil && k .centralConfig .EnableCentralExternalDomain {
609+ if routes != nil && k .centralConfig .EnableCentralExternalDomain && ! externaldns . IsEnabled ( managedCentral ) {
602610 _ , err := k .ChangeCentralCNAMErecords (centralRequest , CentralRoutesActionDelete )
603611 if err != nil {
604612 if force {
0 commit comments