Skip to content

Commit

Permalink
Merge pull request #1335 from splunk/CSPL_2626
Browse files Browse the repository at this point in the history
CSPL-2626 - Github issue #1284, #1326 - Initialize phase early, update aws-sdk-go, CR status change
  • Loading branch information
akondur authored Jun 25, 2024
2 parents cf9c3e8 + 24f01f2 commit 9844246
Show file tree
Hide file tree
Showing 32 changed files with 228 additions and 97 deletions.
4 changes: 4 additions & 0 deletions api/v4/clustermanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type ClusterManagerStatus struct {

// Telemetry App installation flag
TelAppInstalled bool `json:"telAppInstalled"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// BundlePushInfo Indicates if bundle push required
Expand All @@ -87,6 +90,7 @@ type BundlePushInfo struct {
// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.replicas",description="Desired number of indexer peers"
// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Current number of ready indexer peers"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of cluster manager"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type ClusterManager struct {
metav1.TypeMeta `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions api/v4/indexercluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ type IndexerClusterStatus struct {

// status of each indexer cluster peer
Peers []IndexerClusterMemberStatus `json:"peers"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -123,6 +126,7 @@ type IndexerClusterStatus struct {
// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.replicas",description="Desired number of indexer peers"
// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Current number of ready indexer peers"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of indexer cluster"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type IndexerCluster struct {
metav1.TypeMeta `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions api/v4/licensemanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type LicenseManagerStatus struct {

// Telemetry App installation flag
TelAppInstalled bool `json:"telAppInstalled"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -62,6 +65,7 @@ type LicenseManagerStatus struct {
// +kubebuilder:resource:path=licensemanagers,scope=Namespaced,shortName=lmanager
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Status of license manager"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of license manager"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type LicenseManager struct {
metav1.TypeMeta `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions api/v4/monitoringconsole_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type MonitoringConsoleStatus struct {

// App Framework status
AppContext AppDeploymentContext `json:"appContext,omitempty"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -70,6 +73,7 @@ type MonitoringConsoleStatus struct {
// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.replicas",description="Desired number of monitoring console members"
// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Current number of ready monitoring console members"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of monitoring console"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type MonitoringConsole struct {
metav1.TypeMeta `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions api/v4/searchheadcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ type SearchHeadClusterStatus struct {

// Telemetry App installation flag
TelAppInstalled bool `json:"telAppInstalled"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// SearchHeadCluster is the Schema for a Splunk Enterprise search head cluster
Expand All @@ -132,6 +135,7 @@ type SearchHeadClusterStatus struct {
// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.replicas",description="Desired number of search head cluster members"
// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Current number of ready search head cluster members"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of search head cluster"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type SearchHeadCluster struct {
metav1.TypeMeta `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions api/v4/standalone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type StandaloneStatus struct {

// Telemetry App installation flag
TelAppInstalled bool `json:"telAppInstalled"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -86,6 +89,7 @@ type StandaloneStatus struct {
// +kubebuilder:printcolumn:name="Desired",type="integer",JSONPath=".status.replicas",description="Number of desired standalone instances"
// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Current number of ready standalone instances"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of standalone resource"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
// +kubebuilder:storageversion
type Standalone struct {
metav1.TypeMeta `json:",inline"`
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/enterprise.splunk.com_clustermanagers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -4235,6 +4239,9 @@ spec:
needToPushMasterApps:
type: boolean
type: object
message:
description: Auxillary message describing CR status
type: string
phase:
description: current phase of the cluster manager
enum:
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/enterprise.splunk.com_indexerclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3825,6 +3825,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -7513,6 +7517,9 @@ spec:
maintenance_mode:
description: Indicates if the cluster is in maintenance mode.
type: boolean
message:
description: Auxillary message describing CR status
type: string
namespace_scoped_secret_resource_version:
description: Indicates resource version of namespace scoped secret
type: string
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/enterprise.splunk.com_licensemanagers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -4098,6 +4102,9 @@ spec:
description: App Framework version info for future use
type: integer
type: object
message:
description: Auxillary message describing CR status
type: string
phase:
description: current phase of the license manager
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4156,6 +4156,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -8236,6 +8240,9 @@ spec:
needToPushMasterApps:
type: boolean
type: object
message:
description: Auxillary message describing CR status
type: string
phase:
description: current phase of the monitoring console
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4247,6 +4247,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -8387,6 +8391,9 @@ spec:
type: string
type: object
type: array
message:
description: Auxillary message describing CR status
type: string
minPeersJoined:
description: true if the minimum number of search head cluster members
have joined
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/enterprise.splunk.com_standalones.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4400,6 +4400,10 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Auxillary message describing CR status
jsonPath: .status.message
name: Message
type: string
name: v4
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -8592,6 +8596,9 @@ spec:
description: App Framework version info for future use
type: integer
type: object
message:
description: Auxillary message describing CR status
type: string
phase:
description: current phase of the standalone instances
enum:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/splunk/splunk-operator
go 1.21

require (
github.com/aws/aws-sdk-go v1.42.16
github.com/aws/aws-sdk-go v1.47.11
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/minio/minio-go/v7 v7.0.16
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.42.16 h1:jOUmYYpC77NZYQVHTOTFT4lwFBT1u3s8ETKciU4l6gQ=
github.com/aws/aws-sdk-go v1.42.16/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
github.com/aws/aws-sdk-go v1.47.11 h1:Dol+MA+hQblbnXUI3Vk9qvoekU6O1uDEuAItezjiWNQ=
github.com/aws/aws-sdk-go v1.47.11/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down
16 changes: 5 additions & 11 deletions pkg/splunk/enterprise/afwscheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,10 @@ func TestCreateFanOutWorker(t *testing.T) {
}

fanOutWorker := createFanOutWorker(worker, 0)

if fanOutWorker == nil {
t.Errorf("Unable to create a fanout worker")
}

if fanOutWorker.fanOut {
} else if fanOutWorker.fanOut {
t.Errorf("FanOut flag should be false on the new worker")
}

Expand Down Expand Up @@ -792,8 +790,6 @@ func TestPhaseManagersMsgChannels(t *testing.T) {
}

// Just make the lint conversion checks happy
//var client splcommon.ControllerClient = getConvertedClient(c)

capacity := 1
var workerList []*PipelineWorker = make([]*PipelineWorker, capacity)
for i := range workerList {
Expand Down Expand Up @@ -1948,7 +1944,6 @@ func TestExtractClusterScopedAppOnPod(t *testing.T) {
// Just make the lint conversion checks happy
var client splcommon.ControllerClient = getConvertedClient(c)

//var client splcommon.ControllerClient
worker := &PipelineWorker{
appSrcName: "appSrc1",
afwConfig: &cr.Spec.AppFrameworkConfig,
Expand Down Expand Up @@ -2076,7 +2071,6 @@ func TestRunPodCopyWorker(t *testing.T) {
var client splcommon.ControllerClient = getConvertedClient(c)
var waiter sync.WaitGroup

//var client splcommon.ControllerClient
worker := &PipelineWorker{
cr: &cr,
targetPodName: "splunk-stack1-clustermanager-0",
Expand Down Expand Up @@ -2937,7 +2931,7 @@ func TestRunLocalScopedPlaybook(t *testing.T) {
waiter.Add(1)
err := localInstallCtxt.runPlaybook(ctx)
if err == nil {
t.Errorf("Failed to detect missingApp pkg: err: %s", err.Error())
t.Errorf("Failed to detect missingApp pkg")
}

// Test2: checkIfFileExistsOnPod passes but get installed app name returns error
Expand All @@ -2946,7 +2940,7 @@ func TestRunLocalScopedPlaybook(t *testing.T) {
waiter.Add(1)
err = localInstallCtxt.runPlaybook(ctx)
if err == nil {
t.Errorf("Failed to detect that steps to get installed app failed: err: %s", err.Error())
t.Errorf("Failed to detect that steps to get installed app failed")
}

// Test3: get installed app name passes but getting installed app name failed
Expand All @@ -2955,7 +2949,7 @@ func TestRunLocalScopedPlaybook(t *testing.T) {
waiter.Add(1)
err = localInstallCtxt.runPlaybook(ctx)
if err == nil {
t.Errorf("Failed to detect not able to get installed app name: err: %s", err.Error())
t.Errorf("Failed to detect not able to get installed app name: err")
}

// Test4: get installed app command passes but installing app fails
Expand Down Expand Up @@ -4348,5 +4342,5 @@ func TestAddTelAppCManager(t *testing.T) {
},
}
// Negative testing
err = addTelApp(ctx, mockPodExecClient, 2, &crNew)
addTelApp(ctx, mockPodExecClient, 2, &crNew)
}
15 changes: 10 additions & 5 deletions pkg/splunk/enterprise/clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,22 @@ func ApplyClusterManager(ctx context.Context, client splcommon.ControllerClient,
cr.Status.ResourceRevMap = make(map[string]string)
}

var err error
// Initialize phase
cr.Status.Phase = enterpriseApi.PhaseError

// Update the CR Status
defer updateCRStatus(ctx, client, cr, &err)

// validate and updates defaults for CR
err := validateClusterManagerSpec(ctx, client, cr)
err = validateClusterManagerSpec(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "validateClusterManagerSpec", fmt.Sprintf("validate clustermanager spec failed %s", err.Error()))
scopedLog.Error(err, "Failed to validate clustermanager spec")
return result, err
}

// updates status after function completes
cr.Status.Phase = enterpriseApi.PhaseError
cr.Status.Selector = fmt.Sprintf("app.kubernetes.io/instance=splunk-%s-%s", cr.GetName(), "cluster-manager")

if !reflect.DeepEqual(cr.Status.SmartStore, cr.Spec.SmartStore) ||
Expand Down Expand Up @@ -92,9 +100,6 @@ func ApplyClusterManager(ctx context.Context, client splcommon.ControllerClient,
return result, err
}

// Update the CR Status
defer updateCRStatus(ctx, client, cr)

// If needed, Migrate the app framework status
err = checkAndMigrateAppDeployStatus(ctx, client, cr, &cr.Status.AppContext, &cr.Spec.AppFrameworkConfig, false)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/splunk/enterprise/clustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,8 @@ func TestIsClusterManagerReadyForUpgrade(t *testing.T) {
},
}

err := client.Create(ctx, &lm)
_, err = ApplyLicenseManager(ctx, client, &lm)
client.Create(ctx, &lm)
_, err := ApplyLicenseManager(ctx, client, &lm)
if err != nil {
t.Errorf("applyLicenseManager should not have returned error; err=%v", err)
}
Expand Down Expand Up @@ -1467,7 +1467,7 @@ func TestIsClusterManagerReadyForUpgrade(t *testing.T) {
}

cm.Kind = "ClusterManager"
err = client.Create(ctx, &cm)
client.Create(ctx, &cm)
_, err = ApplyClusterManager(ctx, client, &cm)
if err != nil {
t.Errorf("applyClusterManager should not have returned error; err=%v", err)
Expand All @@ -1479,10 +1479,10 @@ func TestIsClusterManagerReadyForUpgrade(t *testing.T) {
createPods(t, ctx, client, "license-manager", fmt.Sprintf("splunk-%s-license-manager-0", lm.Name), lm.Namespace, lm.Spec.Image)
updateStatefulSetsInTest(t, ctx, client, 1, fmt.Sprintf("splunk-%s-license-manager", lm.Name), lm.Namespace)
// now the statefulset image in spec is updated to splunk2
_, err = ApplyLicenseManager(ctx, client, &lm)
ApplyLicenseManager(ctx, client, &lm)

// now the statefulset and license manager both should be in ready state
_, err = ApplyLicenseManager(ctx, client, &lm)
ApplyLicenseManager(ctx, client, &lm)

clusterManager := &enterpriseApi.ClusterManager{}
namespacedName = types.NamespacedName{
Expand Down
Loading

0 comments on commit 9844246

Please sign in to comment.