From 3578cf3db45e45179fdf234383a8f2ae36f6ff62 Mon Sep 17 00:00:00 2001 From: Michael H Date: Thu, 20 Jan 2022 16:00:16 +0000 Subject: [PATCH 1/2] added ability to set event driven thread count update docs fix wrong text Signed-off-by: Michael H update changelog Signed-off-by: Michael H --- CHANGELOG.md | 2 ++ api/v1alpha1/nificluster_types.go | 9 +++++++++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/nifi.orange.com_nificlusters.yaml | 12 ++++++++++++ .../controllersettings/controllersettings.go | 4 +++- pkg/resources/nifi/nifi.go | 11 ++++++----- .../1_nifi_cluster/2_read_only_config.md | 3 +++ 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 525da155e..6c1f0bd2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Added +- [PR #184](https://github.com/Orange-OpenSource/nifikop/pull/184) - **[Operator/NiFiCluster]** Add ability to set MaxEventDrivenThreadCount. + ### Changed ### Deprecated diff --git a/api/v1alpha1/nificluster_types.go b/api/v1alpha1/nificluster_types.go index afb711dd8..106893e7a 100644 --- a/api/v1alpha1/nificluster_types.go +++ b/api/v1alpha1/nificluster_types.go @@ -161,6 +161,8 @@ type Node struct { type ReadOnlyConfig struct { // MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available to the system. MaximumTimerDrivenThreadCount *int32 `json:"maximumTimerDrivenThreadCount,omitempty"` + // MaximumEventDrivenThreadCount define the maximum number of threads for event driven processors available to the system. + MaximumEventDrivenThreadCount *int32 `json:"maximumEventDrivenThreadCount,omitempty"` // AdditionalSharedEnvs define a set of additional env variables that will shared between all init containers and // containers in the pod. AdditionalSharedEnvs []corev1.EnvVar `json:"additionalSharedEnvs,omitempty"` @@ -552,6 +554,13 @@ func (nReadOnlyConfig *ReadOnlyConfig) GetMaximumTimerDrivenThreadCount() int32 return *nReadOnlyConfig.MaximumTimerDrivenThreadCount } +func (nReadOnlyConfig *ReadOnlyConfig) GetMaximumEventDrivenThreadCount() int32 { + if nReadOnlyConfig.MaximumEventDrivenThreadCount == nil { + return 5 + } + return *nReadOnlyConfig.MaximumEventDrivenThreadCount +} + func (nTaskSpec *NifiClusterTaskSpec) GetDurationMinutes() float64 { if nTaskSpec.RetryDurationMinutes == 0 { return 5 diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 184e448ac..c9d2a7c06 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1290,6 +1290,11 @@ func (in *ReadOnlyConfig) DeepCopyInto(out *ReadOnlyConfig) { *out = new(int32) **out = **in } + if in.MaximumEventDrivenThreadCount != nil { + in, out := &in.MaximumEventDrivenThreadCount, &out.MaximumEventDrivenThreadCount + *out = new(int32) + **out = **in + } if in.AdditionalSharedEnvs != nil { in, out := &in.AdditionalSharedEnvs, &out.AdditionalSharedEnvs *out = make([]v1.EnvVar, len(*in)) diff --git a/config/crd/bases/nifi.orange.com_nificlusters.yaml b/config/crd/bases/nifi.orange.com_nificlusters.yaml index b46ff8a28..49dfce6b2 100644 --- a/config/crd/bases/nifi.orange.com_nificlusters.yaml +++ b/config/crd/bases/nifi.orange.com_nificlusters.yaml @@ -2713,6 +2713,12 @@ spec: - name type: object type: object + maximumEventDrivenThreadCount: + description: MaximumEventDrivenThreadCount define the maximum + number of threads for event driven processors available + to the system. + format: int32 + type: integer maximumTimerDrivenThreadCount: description: MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available @@ -3124,6 +3130,12 @@ spec: - name type: object type: object + maximumEventDrivenThreadCount: + description: MaximumEventDrivenThreadCount define the maximum + number of threads for event driven processors available to the + system. + format: int32 + type: integer maximumTimerDrivenThreadCount: description: MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available to the diff --git a/pkg/clientwrappers/controllersettings/controllersettings.go b/pkg/clientwrappers/controllersettings/controllersettings.go index fd863fb44..5a2d648cc 100644 --- a/pkg/clientwrappers/controllersettings/controllersettings.go +++ b/pkg/clientwrappers/controllersettings/controllersettings.go @@ -12,7 +12,8 @@ import ( var log = ctrl.Log.WithName("controllersettings-method") func controllerConfigIsSync(cluster *v1alpha1.NifiCluster, entity *nigoapi.ControllerConfigurationEntity) bool { - return cluster.Spec.ReadOnlyConfig.GetMaximumTimerDrivenThreadCount() == entity.Component.MaxTimerDrivenThreadCount + return cluster.Spec.ReadOnlyConfig.GetMaximumTimerDrivenThreadCount() == entity.Component.MaxTimerDrivenThreadCount && + cluster.Spec.ReadOnlyConfig.GetMaximumEventDrivenThreadCount() == entity.Component.MaxEventDrivenThreadCount } func SyncConfiguration(config *clientconfig.NifiConfig, cluster *v1alpha1.NifiCluster) error { @@ -50,4 +51,5 @@ func updateControllerConfigEntity(cluster *v1alpha1.NifiCluster, entity *nigoapi entity.Component = &nigoapi.ControllerConfigurationDto{} } entity.Component.MaxTimerDrivenThreadCount = cluster.Spec.ReadOnlyConfig.GetMaximumTimerDrivenThreadCount() + entity.Component.MaxEventDrivenThreadCount = cluster.Spec.ReadOnlyConfig.GetMaximumEventDrivenThreadCount() } diff --git a/pkg/resources/nifi/nifi.go b/pkg/resources/nifi/nifi.go index a8f1aeb2e..1fb6486e9 100644 --- a/pkg/resources/nifi/nifi.go +++ b/pkg/resources/nifi/nifi.go @@ -254,8 +254,9 @@ func (r *Reconciler) Reconcile(log logr.Logger) error { } } - if r.NifiCluster.Spec.ReadOnlyConfig.MaximumTimerDrivenThreadCount != nil { - if err := r.reconcileMaximumTimerDrivenThreadCount(log); err != nil { + if r.NifiCluster.Spec.ReadOnlyConfig.MaximumTimerDrivenThreadCount != nil || + r.NifiCluster.Spec.ReadOnlyConfig.MaximumEventDrivenThreadCount != nil { + if err := r.reconcileMaximumThreadCounts(log); err != nil { return errors.WrapIf(err, "failed to reconcile ressource") } } @@ -909,7 +910,7 @@ func (r *Reconciler) reconcilePrometheusReportingTask(log logr.Logger) error { return nil } -func (r *Reconciler) reconcileMaximumTimerDrivenThreadCount(log logr.Logger) error { +func (r *Reconciler) reconcileMaximumThreadCounts(log logr.Logger) error { configManager := config.GetClientConfigManager(r.Client, v1alpha1.ClusterReference{ Namespace: r.NifiCluster.Namespace, Name: r.NifiCluster.Name, @@ -919,10 +920,10 @@ func (r *Reconciler) reconcileMaximumTimerDrivenThreadCount(log logr.Logger) err return err } - // Sync Maximum Timer Driven Thread Count with NiFi side component + // Sync Maximum Timer Driven Thread Count and Maximum Event Driven Thread Count with NiFi side component err = controllersettings.SyncConfiguration(clientConfig, r.NifiCluster) if err != nil { - return errors.WrapIfWithDetails(err, "failed to sync MaximumTimerDrivenThreadCount") + return errors.WrapIfWithDetails(err, "failed to sync MaximumThreadCount configuration") } return nil diff --git a/site/docs/5_references/1_nifi_cluster/2_read_only_config.md b/site/docs/5_references/1_nifi_cluster/2_read_only_config.md index 820bc5b97..bff75a6b7 100644 --- a/site/docs/5_references/1_nifi_cluster/2_read_only_config.md +++ b/site/docs/5_references/1_nifi_cluster/2_read_only_config.md @@ -10,6 +10,8 @@ ReadOnlyConfig object specifies the read-only type Nifi config cluster wide, all readOnlyConfig: # MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available to the system. maximumTimerDrivenThreadCount: 30 + # MaximumEventDrivenThreadCount define the maximum number of threads for event driven processors available to the system. + maximumEventDrivenThreadCount: 10 # Logback configuration that will be applied to the node logbackConfig: # logback.xml configuration that will replace the one produced based on template @@ -124,6 +126,7 @@ readOnlyConfig: |Field|Type|Description|Required|Default| |-----|----|-----------|--------|--------| |maximumTimerDrivenThreadCount|int32|define the maximum number of threads for timer driven processors available to the system.|No|nil| +|maximumEventDrivenThreadCount|int32|define the maximum number of threads for event driven processors available to the system.|No|nil| |additionalSharedEnvs|\[ \][corev1.EnvVar](https://pkg.go.dev/k8s.io/api/core/v1#EnvVar)|define a set of additional env variables that will shared between all init containers and ontainers in the pod..|No|\[ \]| |nifiProperties|[NifiProperties](#nifiproperties)|nifi.properties configuration that will be applied to the node.|No|nil| |zookeeperProperties|[ZookeeperProperties](#zookeeperproperties)|zookeeper.properties configuration that will be applied to the node.|No|nil| From 9255e37ec9048b3115fc49c4f59d82cd0d11d331 Mon Sep 17 00:00:00 2001 From: Michael H Date: Thu, 3 Mar 2022 15:38:25 +0000 Subject: [PATCH 2/2] update helm CRDs Signed-off-by: Michael H --- helm/nifikop/crds/nifi.orange.com_nificlusters.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helm/nifikop/crds/nifi.orange.com_nificlusters.yaml b/helm/nifikop/crds/nifi.orange.com_nificlusters.yaml index b46ff8a28..49dfce6b2 100644 --- a/helm/nifikop/crds/nifi.orange.com_nificlusters.yaml +++ b/helm/nifikop/crds/nifi.orange.com_nificlusters.yaml @@ -2713,6 +2713,12 @@ spec: - name type: object type: object + maximumEventDrivenThreadCount: + description: MaximumEventDrivenThreadCount define the maximum + number of threads for event driven processors available + to the system. + format: int32 + type: integer maximumTimerDrivenThreadCount: description: MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available @@ -3124,6 +3130,12 @@ spec: - name type: object type: object + maximumEventDrivenThreadCount: + description: MaximumEventDrivenThreadCount define the maximum + number of threads for event driven processors available to the + system. + format: int32 + type: integer maximumTimerDrivenThreadCount: description: MaximumTimerDrivenThreadCount define the maximum number of threads for timer driven processors available to the