Skip to content

Commit

Permalink
Added multisite with code
Browse files Browse the repository at this point in the history
  • Loading branch information
tgarg-splunk committed Aug 8, 2023
1 parent 89ff0ae commit c679321
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions pkg/splunk/enterprise/indexercluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,41 +1128,11 @@ func (mgr *indexerClusterPodManager) isIndexerClusterReadyForUpgrade(ctx context
mgr.c = c
}

cm := mgr.getClusterManagerClient(ctx)
clusterInfo, err := cm.GetClusterInfo(false)
if err != nil {
return false, fmt.Errorf("could not get cluster info from cluster manager")
}
if clusterInfo.MultiSite == "true" {
opts := []rclient.ListOption{
rclient.InNamespace(cr.GetNamespace()),
}
indexerList, err := getIndexerClusterList(ctx, c, cr, opts)
if err != nil {
return false, err
}
sortedList, err := getIndexerClusterSortedSiteList(ctx, c, cr.Spec.ClusterManagerRef, indexerList)

preIdx := enterpriseApi.IndexerCluster{}

for i, v := range sortedList.Items {
if &v == cr {
if i > 0 {
preIdx = sortedList.Items[i-1]
}
break

}
}
if len(preIdx.Name) != 0 {
image, _ := getCurrentImage(ctx, c, &preIdx, SplunkIndexer)
if preIdx.Status.Phase != enterpriseApi.PhaseReady || image != cr.Spec.Image {
return false, nil
}
}

}

// cm := mgr.getClusterManagerClient(ctx)
// clusterInfo, err := cm.GetClusterInfo(false)
// if err != nil {
// return false, fmt.Errorf("could not get cluster info from cluster manager")
// }
// check if a search head cluster exists with the same ClusterManager instance attached
searchHeadClusterInstance := enterpriseApi.SearchHeadCluster{}
opts := []rclient.ListOption{
Expand Down Expand Up @@ -1209,5 +1179,32 @@ func (mgr *indexerClusterPodManager) isIndexerClusterReadyForUpgrade(ctx context
if (cr.Spec.Image != idxImage) && (searchHeadClusterInstance.Status.Phase != enterpriseApi.PhaseReady || shcImage != cr.Spec.Image) {
return false, nil
}

opts = []rclient.ListOption{
rclient.InNamespace(cr.GetNamespace()),
}
indexerList, err := getIndexerClusterList(ctx, c, cr, opts)
if err != nil {
return false, err
}
sortedList, err := getIndexerClusterSortedSiteList(ctx, c, cr.Spec.ClusterManagerRef, indexerList)

preIdx := enterpriseApi.IndexerCluster{}

for i, v := range sortedList.Items {
if &v == cr {
if i > 0 {
preIdx = sortedList.Items[i-1]
}
break

}
}
if len(preIdx.Name) != 0 {
image, _ := getCurrentImage(ctx, c, &preIdx, SplunkIndexer)
if preIdx.Status.Phase != enterpriseApi.PhaseReady || image != cr.Spec.Image {
return false, nil
}
}
return true, nil
}

0 comments on commit c679321

Please sign in to comment.