-
Notifications
You must be signed in to change notification settings - Fork 127
Update of shc upgrade process #1547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a62bfd4
initial draft of shc upgrade process
072c87a
lint changes
995c9cc
fix unit test
2d78b2c
cleanup code
b2833cf
fix endpoints
62b7140
remove todos
65163fc
Merge branch 'develop' into feature/upgrade-shc-upgrade-process
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import ( | |
| "github.com/splunk/splunk-operator/internal/controller/common" | ||
|
|
||
| "github.com/pkg/errors" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -71,7 +72,7 @@ type ClusterManagerReconciler struct { | |
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *ClusterManagerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| // your logic here | ||
| reconcileCounters.With(getPrometheusLabels(req, "ClusterManager")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "ClusterManager")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "ClusterManager") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
@@ -160,9 +161,9 @@ func (r *ClusterManagerReconciler) SetupWithManager(mgr ctrl.Manager) error { | |
|
|
||
| // recordInstrumentionData Record api profiling information to prometheus | ||
| func recordInstrumentionData(start time.Time, req ctrl.Request, module string, name string) { | ||
| metricLabels := getPrometheusLabels(req, name) | ||
| metricLabels[labelModuleName] = module | ||
| metricLabels[labelMethodName] = name | ||
| metricLabels := metrics.GetPrometheusLabels(req, name) | ||
| metricLabels[metrics.LabelModuleName] = module | ||
| metricLabels[metrics.LabelMethodName] = name | ||
| value := float64(time.Since(start) / time.Millisecond) | ||
| apiTotalTimeMetricEvents.With(metricLabels).Set(value) | ||
| metrics.ApiTotalTimeMetricEvents.With(metricLabels).Set(value) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
|
|
||
| "github.com/pkg/errors" | ||
| enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -72,7 +73,7 @@ type ClusterMasterReconciler struct { | |
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *ClusterMasterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| // your logic here | ||
| reconcileCounters.With(getPrometheusLabels(req, "ClusterMaster")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "ClusterMaster")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "ClusterMaster") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
|
|
||
| "github.com/pkg/errors" | ||
| enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -71,7 +72,7 @@ type IndexerClusterReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *IndexerClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "IndexerCluster")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "IndexerCluster")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "IndexerCluster") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import ( | |
| "github.com/splunk/splunk-operator/internal/controller/common" | ||
|
|
||
| "github.com/pkg/errors" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -70,7 +71,7 @@ type LicenseManagerReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *LicenseManagerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "LicenseManager")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "LicenseManager")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "LicenseManager") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
| "github.com/pkg/errors" | ||
| enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3" | ||
| enterpriseApi "github.com/splunk/splunk-operator/api/v4" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -71,7 +72,7 @@ type LicenseMasterReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *LicenseMasterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "LicenseMaster")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "LicenseMaster")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "LicenseMaster") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
|
|
||
| "github.com/pkg/errors" | ||
| enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -71,7 +72,7 @@ type MonitoringConsoleReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *MonitoringConsoleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "MonitoringConsole")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "MonitoringConsole")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "MonitoringConsole") | ||
| reqLogger := log.FromContext(ctx) | ||
| reqLogger = reqLogger.WithValues("monitoringconsole", req.NamespacedName) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import ( | |
| "github.com/splunk/splunk-operator/internal/controller/common" | ||
|
|
||
| "github.com/pkg/errors" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -70,7 +71,7 @@ type SearchHeadClusterReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *SearchHeadClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "SearchHeadCluster")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "SearchHeadCluster")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "SearchHeadCluster") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import ( | |
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
|
|
||
| "github.com/pkg/errors" | ||
| metrics "github.com/splunk/splunk-operator/pkg/splunk/client/metrics" | ||
| enterprise "github.com/splunk/splunk-operator/pkg/splunk/enterprise" | ||
| k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
|
|
@@ -75,7 +76,7 @@ type StandaloneReconciler struct { | |
| // For more details, check Reconcile and its Result here: | ||
| // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
| func (r *StandaloneReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
| reconcileCounters.With(getPrometheusLabels(req, "Standalone")).Inc() | ||
| metrics.ReconcileCounters.With(metrics.GetPrometheusLabels(req, "Standalone")).Inc() | ||
| defer recordInstrumentionData(time.Now(), req, "controller", "Standalone") | ||
|
|
||
| reqLogger := log.FromContext(ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
| "sigs.k8s.io/controller-runtime/pkg/metrics" | ||
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
| ) | ||
|
|
||
| const ( | ||
| LabelNamespace = "namespace" | ||
| LabelName = "name" | ||
| LabelKind = "kind" | ||
| LabelErrorType = "error_type" | ||
| LabelMethodName = "api" | ||
| LabelModuleName = "module" | ||
| LabelResourceVersion = "resource_version" | ||
| ) | ||
|
|
||
| var ( | ||
| upgradeStartTimestamp int64 | ||
| upgradeEndTimestamp int64 | ||
| ) | ||
|
|
||
| var ReconcileCounters = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
| Name: "splunk_operator_reconcile_total", | ||
| Help: "The number of times reconciled by this controller", | ||
| }, []string{LabelNamespace, LabelName, LabelKind}) | ||
|
|
||
| var ReconcileErrorCounter = prometheus.NewCounter(prometheus.CounterOpts{ | ||
| Name: "splunk_operator_reconcile_error_total", | ||
| Help: "The number of times the operator has failed to reconcile", | ||
| }) | ||
|
|
||
| var ActionFailureCounters = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
| Name: "splunk_operator_error_total", | ||
| Help: "The number of times operator has entered an error state", | ||
| }, []string{LabelErrorType}) | ||
|
|
||
| var ApiTotalTimeMetricEvents = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
| Name: "splunk_operator_module_duration_in_milliseconds", | ||
| Help: "The time it takes to complete each call in standalone (in milliseconds)", | ||
| }, []string{LabelNamespace, LabelName, LabelKind, LabelModuleName, LabelMethodName}) | ||
|
|
||
| var UpgradeStartTime = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
| Name: "splunk_upgrade_start_time", | ||
| Help: "Unix timestamp when the SHC upgrade started", | ||
| }) | ||
|
|
||
| var UpgradeEndTime = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
| Name: "splunk_upgrade_end_time", | ||
| Help: "Unix timestamp when the SHC upgrade ended", | ||
| }) | ||
|
|
||
| var ActiveHistoricalSearchCount = prometheus.NewGaugeVec( | ||
| prometheus.GaugeOpts{ | ||
| Name: "splunk_active_historical_search_count", | ||
| Help: "Total number of active historical search count", | ||
| }, []string{"sh_name"}) | ||
|
|
||
| var ActiveRealtimeSearchCount = prometheus.NewGaugeVec( | ||
| prometheus.GaugeOpts{ | ||
| Name: "splunk_active_realtime_search_count", | ||
| Help: "Total number of active realtime search count", | ||
| }, []string{"sh_name"}) | ||
|
|
||
| func GetPrometheusLabels(request reconcile.Request, kind string) prometheus.Labels { | ||
| return prometheus.Labels{ | ||
| LabelNamespace: request.Namespace, | ||
| LabelName: request.Name, | ||
| LabelKind: kind, | ||
| } | ||
| } | ||
|
|
||
| func RecordUpgradeStartTime() { | ||
| upgradeStartTimestamp = time.Now().Unix() | ||
| UpgradeStartTime.Set(float64(upgradeStartTimestamp)) | ||
| } | ||
|
|
||
| func RecordUpgradeEndTime() { | ||
| upgradeEndTimestamp = time.Now().Unix() | ||
| UpgradeEndTime.Set(float64(upgradeEndTimestamp)) | ||
| } | ||
|
|
||
| func init() { | ||
| metrics.Registry.MustRegister( | ||
| ReconcileCounters, | ||
| ReconcileErrorCounter, | ||
| ActionFailureCounters, | ||
| ApiTotalTimeMetricEvents, | ||
| UpgradeStartTime, | ||
| UpgradeEndTime, | ||
| ActiveHistoricalSearchCount, | ||
| ActiveRealtimeSearchCount, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.