Skip to content

Commit

Permalink
Merge branch 'develop' into CSPL_2920
Browse files Browse the repository at this point in the history
  • Loading branch information
akondur authored Nov 20, 2024
2 parents 0bab91f + 44207b2 commit 6685ec5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
11 changes: 7 additions & 4 deletions pkg/splunk/enterprise/clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,13 @@ func ApplyClusterManager(ctx context.Context, client splcommon.ControllerClient,
return result, err
}

// check if the ClusterManager is ready for version upgrade, if required
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
// CSPL-3060 - If statefulSet is not created, avoid upgrade path validation
if !statefulSet.CreationTimestamp.IsZero() {
// check if the ClusterManager is ready for version upgrade, if required
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
}
}

clusterManagerManager := splctrl.DefaultStatefulSetPodManager{}
Expand Down
25 changes: 16 additions & 9 deletions pkg/splunk/enterprise/indexercluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
}
}

// check if the IndexerCluster is ready for version upgrade
cr.Kind = "IndexerCluster"
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, &mgr)
if err != nil || !continueReconcile {
return result, err
// CSPL-3060 - If statefulSet is not created, avoid upgrade path validation
if !statefulSet.CreationTimestamp.IsZero() {
// check if the IndexerCluster is ready for version upgrade
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, &mgr)
if err != nil || !continueReconcile {
return result, err
}
}

// check if version upgrade is set
Expand Down Expand Up @@ -453,11 +456,14 @@ func ApplyIndexerCluster(ctx context.Context, client splcommon.ControllerClient,
}
}

// check if the IndexerCluster is ready for version upgrade
cr.Kind = "IndexerCluster"
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, &mgr)
if err != nil || !continueReconcile {
return result, err
// CSPL-3060 - If statefulSet is not created, avoid upgrade path validation
if !statefulSet.CreationTimestamp.IsZero() {
// check if the IndexerCluster is ready for version upgrade
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, &mgr)
if err != nil || !continueReconcile {
return result, err
}
}

// check if version upgrade is set
Expand Down Expand Up @@ -628,8 +634,8 @@ func ApplyIdxcSecret(ctx context.Context, mgr *indexerClusterPodManager, replica
// If namespace scoped secret revision is the same ignore
if len(mgr.cr.Status.NamespaceSecretResourceVersion) == 0 {
// First time, set resource version in CR
scopedLog.Info("Setting CrStatusNamespaceSecretResourceVersion for the first time")
mgr.cr.Status.NamespaceSecretResourceVersion = namespaceSecret.ObjectMeta.ResourceVersion
scopedLog.Info("Setting CrStatusNamespaceSecretResourceVersion for the first time")
return nil
} else if mgr.cr.Status.NamespaceSecretResourceVersion == namespaceSecret.ObjectMeta.ResourceVersion {
// If resource version hasn't changed don't return
Expand Down Expand Up @@ -777,6 +783,7 @@ func (mgr *indexerClusterPodManager) Update(ctx context.Context, c splcommon.Con
}
} else {
mgr.log.Info("Cluster Manager is not ready yet", "reason ", err)
return enterpriseApi.PhaseError, err
}

// Get the podExecClient with empty targetPodName.
Expand Down
11 changes: 7 additions & 4 deletions pkg/splunk/enterprise/monitoringconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ func ApplyMonitoringConsole(ctx context.Context, client splcommon.ControllerClie
return result, err
}

// check if the Monitoring Console is ready for version upgrade, if required
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
// CSPL-3060 - If statefulSet is not created, avoid upgrade path validation
if !statefulSet.CreationTimestamp.IsZero() {
// check if the Monitoring Console is ready for version upgrade, if required
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
}
}

mgr := splctrl.DefaultStatefulSetPodManager{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/splunk/enterprise/monitoringconsole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func TestApplyMonitoringConsole(t *testing.T) {
"app.kubernetes.io/component": "versionedSecrets",
"app.kubernetes.io/managed-by": "splunk-operator",
}

listOpts := []client.ListOption{
client.InNamespace("test"),
client.MatchingLabels(labels),
}

listOpts2 := []client.ListOption{
client.InNamespace("test"),
}
Expand All @@ -112,8 +112,8 @@ func TestApplyMonitoringConsole(t *testing.T) {
{ListOpts: listOpts2},
}

createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": {funcCalls[0], funcCalls[3], funcCalls[4], funcCalls[7], funcCalls[9], funcCalls[10], funcCalls[5]}, "Update": {funcCalls[0], funcCalls[10]}, "List": {listmockCall[0], listmockCall[1], listmockCall[1], listmockCall[1], listmockCall[1], listmockCall[1]}}
updateCalls := map[string][]spltest.MockFuncCall{"Get": updateFuncCalls, "Update": {updateFuncCalls[4]}, "List": {listmockCall[0], listmockCall[1], listmockCall[1], listmockCall[1], listmockCall[1], listmockCall[1]}}
createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": {funcCalls[0], funcCalls[3], funcCalls[4], funcCalls[7], funcCalls[9], funcCalls[10], funcCalls[5]}, "Update": {funcCalls[0], funcCalls[10]}, "List": {listmockCall[0]}}
updateCalls := map[string][]spltest.MockFuncCall{"Get": updateFuncCalls, "Update": {updateFuncCalls[4]}, "List": {listmockCall[0]}}

current := enterpriseApi.MonitoringConsole{
TypeMeta: metav1.TypeMeta{
Expand Down
9 changes: 6 additions & 3 deletions pkg/splunk/enterprise/searchheadcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ func ApplySearchHeadCluster(ctx context.Context, client splcommon.ControllerClie
return result, err
}

continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
// CSPL-3060 - If statefulSet is not created, avoid upgrade path validation
if !statefulSet.CreationTimestamp.IsZero() {
continueReconcile, err := UpgradePathValidation(ctx, client, cr, cr.Spec.CommonSplunkSpec, nil)
if err != nil || !continueReconcile {
return result, err
}
}

deployerManager := splctrl.DefaultStatefulSetPodManager{}
Expand Down
7 changes: 3 additions & 4 deletions pkg/splunk/enterprise/searchheadcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func TestApplySearchHeadCluster(t *testing.T) {
{MetaName: "*v1.Secret-test-splunk-test-secret"},
{MetaName: "*v1.Secret-test-splunk-stack1-deployer-secret-v1"},

{MetaName: "*v1.StatefulSet-test-splunk-stack1-search-head"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-deployer"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-search-head"},

Expand All @@ -108,7 +107,7 @@ func TestApplySearchHeadCluster(t *testing.T) {
{MetaName: "*v1.ConfigMap-test-splunk-test-probe-configmap"},
{MetaName: "*v1.Secret-test-splunk-test-secret"},
{MetaName: "*v1.Secret-test-splunk-stack1-deployer-secret-v1"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-search-head"},
//{MetaName: "*v1.StatefulSet-test-splunk-stack1-search-head"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-deployer"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-deployer"},
{MetaName: "*v1.StatefulSet-test-splunk-stack1-search-head"},
Expand All @@ -135,8 +134,8 @@ func TestApplySearchHeadCluster(t *testing.T) {
listmockCall := []spltest.MockFuncCall{
{ListOpts: listOpts}}

createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": {funcCalls[0], funcCalls[3], funcCalls[4], funcCalls[5], funcCalls[8], funcCalls[10], funcCalls[12], funcCalls[16], funcCalls[17]}, "Update": {funcCalls[0]}, "List": {listmockCall[0], listmockCall[0]}}
updateCalls := map[string][]spltest.MockFuncCall{"Get": createFuncCalls, "Update": {createFuncCalls[5], createFuncCalls[9]}, "List": {listmockCall[0], listmockCall[0]}}
createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": {funcCalls[0], funcCalls[3], funcCalls[4], funcCalls[5], funcCalls[8], funcCalls[10], funcCalls[11], funcCalls[15], funcCalls[16]}, "Update": {funcCalls[0]}, "List": {listmockCall[0], listmockCall[0]}}
updateCalls := map[string][]spltest.MockFuncCall{"Get": createFuncCalls, "Update": {createFuncCalls[5], createFuncCalls[11]}, "List": {listmockCall[0], listmockCall[0]}}
statefulSet := enterpriseApi.SearchHeadCluster{
TypeMeta: metav1.TypeMeta{
Kind: "SearchHeadCluster",
Expand Down

0 comments on commit 6685ec5

Please sign in to comment.