@@ -35,7 +35,7 @@ import (
3535)
3636
3737// ApplyStandalone reconciles the StatefulSet for N standalone instances of Splunk Enterprise.
38- func ApplyStandalone (ctx context.Context , client splcommon.ControllerClient , cr * enterpriseApi.Standalone ) (reconcile.Result , error ) {
38+ func ApplyStandalone (ctx context.Context , client splcommon.ControllerClient , cr * enterpriseApi.Standalone , appEngine AppEngine ) (reconcile.Result , error ) {
3939
4040 // unless modified, reconcile for this object will be requeued after 5 seconds
4141 result := reconcile.Result {
@@ -72,7 +72,7 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
7272 cr .Status .Replicas = cr .Spec .Replicas
7373
7474 // If needed, Migrate the app framework status
75- err = checkAndMigrateAppDeployStatus (ctx , client , cr , & cr .Status .AppContext , & cr .Spec .AppFrameworkConfig , true )
75+ err = appEngine . ensureAppFrameworkStatus (ctx , client , cr , & cr .Status .AppContext , & cr .Spec .AppFrameworkConfig , enterpriseApi . ScopeLocal )
7676 if err != nil {
7777 return result , err
7878 }
@@ -97,9 +97,9 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
9797 // 1. Initialize the S3Clients based on providers
9898 // 2. Check the status of apps on remote storage.
9999 if len (cr .Spec .AppFrameworkConfig .AppSources ) != 0 {
100- err := initAndCheckAppInfoStatus (ctx , client , cr , & cr .Spec .AppFrameworkConfig , & cr .Status .AppContext )
100+ err := appEngine . ensureAppRepoState (ctx , client , cr , & cr .Spec .AppFrameworkConfig , & cr .Status .AppContext )
101101 if err != nil {
102- eventPublisher .Warning (ctx , "initAndCheckAppInfoStatus " , fmt .Sprintf ("init and check app info status failed %s" , err .Error ()))
102+ eventPublisher .Warning (ctx , "ensureAppRepoState " , fmt .Sprintf ("ensure app repo state failed %s" , err .Error ()))
103103 cr .Status .AppContext .IsDeploymentInProgress = false
104104 return result , err
105105 }
@@ -187,22 +187,22 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
187187 cr .Status .AppContext .IsDeploymentInProgress = true
188188
189189 for appSrc := range appStatusContext .AppsSrcDeployStatus {
190- changeAppSrcDeployInfoStatus (ctx , appSrc , appStatusContext .AppsSrcDeployStatus , enterpriseApi .RepoStateActive , enterpriseApi .DeployStatusComplete , enterpriseApi .DeployStatusPending )
191- changePhaseInfo (ctx , cr .Spec .Replicas , appSrc , appStatusContext .AppsSrcDeployStatus )
190+ appEngine . changeAppSrcDeployInfoStatus (ctx , appSrc , appStatusContext .AppsSrcDeployStatus , enterpriseApi .RepoStateActive , enterpriseApi .DeployStatusComplete , enterpriseApi .DeployStatusPending )
191+ appEngine . changePhaseInfo (ctx , cr .Spec .Replicas , appSrc , appStatusContext .AppsSrcDeployStatus )
192192 }
193193
194194 // if we are scaling down, just delete the state auxPhaseInfo entries
195195 case enterpriseApi .StatefulSetScalingDown :
196196 for appSrc := range appStatusContext .AppsSrcDeployStatus {
197- removeStaleEntriesFromAuxPhaseInfo (ctx , cr .Spec .Replicas , appSrc , appStatusContext .AppsSrcDeployStatus )
197+ appEngine . removeStaleEntriesFromAuxPhaseInfo (ctx , cr .Spec .Replicas , appSrc , appStatusContext .AppsSrcDeployStatus )
198198 }
199199 default :
200200 // nothing to be done
201201 }
202202 }
203203
204204 // create or update statefulset
205- statefulSet , err := getStandaloneStatefulSet (ctx , client , cr )
205+ statefulSet , err := getStandaloneStatefulSet (ctx , client , cr , appEngine )
206206 if err != nil {
207207 eventPublisher .Warning (ctx , "getStandaloneStatefulSet" , fmt .Sprintf ("get standalone status set failed %s" , err .Error ()))
208208 return result , err
@@ -262,7 +262,7 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
262262 scopedLog .Error (err , "Error in deleting automated monitoring console resource" )
263263 }
264264
265- finalResult := handleAppFrameworkActivity (ctx , client , cr , & cr .Status .AppContext , & cr .Spec .AppFrameworkConfig )
265+ finalResult := appEngine . runAppFrameworkIfReady (ctx , client , cr , & cr .Status .AppContext , & cr .Spec .AppFrameworkConfig )
266266 result = * finalResult
267267
268268 // Add a splunk operator telemetry app
@@ -287,7 +287,7 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
287287}
288288
289289// getStandaloneStatefulSet returns a Kubernetes StatefulSet object for Splunk Enterprise standalone instances.
290- func getStandaloneStatefulSet (ctx context.Context , client splcommon.ControllerClient , cr * enterpriseApi.Standalone ) (* appsv1.StatefulSet , error ) {
290+ func getStandaloneStatefulSet (ctx context.Context , client splcommon.ControllerClient , cr * enterpriseApi.Standalone , appEngine AppEngine ) (* appsv1.StatefulSet , error ) {
291291 // get generic statefulset for Splunk Enterprise objects
292292 ss , err := getSplunkStatefulSet (ctx , client , cr , & cr .Spec .CommonSplunkSpec , SplunkStandalone , cr .Spec .Replicas , []corev1.EnvVar {})
293293 if err != nil {
@@ -301,7 +301,7 @@ func getStandaloneStatefulSet(ctx context.Context, client splcommon.ControllerCl
301301 }
302302
303303 // Setup App framework staging volume for apps
304- setupAppsStagingVolume (ctx , client , cr , & ss .Spec .Template , & cr .Spec .AppFrameworkConfig )
304+ appEngine . ensureAppFrameworkStagingVolume (ctx , client , cr , & ss .Spec .Template , & cr .Spec .AppFrameworkConfig )
305305
306306 return ss , nil
307307}
0 commit comments