Skip to content

Commit

Permalink
FRONTEND::CHANGED: improve default values
Browse files Browse the repository at this point in the history
  • Loading branch information
ELDiablO59152 committed Jul 23, 2024
1 parent 6cf23b8 commit 9040567
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
25 changes: 15 additions & 10 deletions vulture_os/services/frontend/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,15 @@ class Meta:
'queue_type': Select(choices=RSYSLOG_QUEUE_TYPE_CHOICES, attrs={'class': 'form-control select2'}),
'queue_size': NumberInput(attrs={'class': 'form-control', 'placeholder': '50000'}),
'dequeue_batch_size': NumberInput(attrs={'class': 'form-control', 'placeholder': '1024'}),
'nb_workers': NumberInput(attrs={'class': 'form-control'}),
'nb_workers': NumberInput(attrs={'class': 'form-control', 'placeholder': '8'}),
'new_worker_minimum_messages': NumberInput(attrs={'class': 'form-control', 'placeholder': 'queue.size/queue.workerthreads'}),
'shutdown_timeout': NumberInput(attrs={'class': 'form-control', 'placeholder': '1500'}),
'shutdown_timeout': NumberInput(attrs={'class': 'form-control', 'placeholder': '5000'}),
'enable_disk_assist': CheckboxInput(attrs={'class': 'js-switch'}),
'high_watermark': NumberInput(attrs={'class': 'form-control', 'placeholder': '90% of queue.size'}),
'low_watermark': NumberInput(attrs={'class': 'form-control', 'placeholder': '70% of queue.size'}),
'max_file_size': NumberInput(attrs={'class': 'form-control', 'placeholder': '16MB'}),
'max_file_size': NumberInput(attrs={'class': 'form-control', 'placeholder': '256MB'}),
'max_disk_space': NumberInput(attrs={'class': 'form-control', 'placeholder': 'Unlimited'}),
'spool_directory': TextInput(attrs={'class': 'form-control'}),
'spool_directory': TextInput(attrs={'class': 'form-control', 'placeholder': '/var/tmp'}),
'save_on_shutdown': CheckboxInput(attrs={'class': 'js-switch'}),
'mmdb_cache_size': NumberInput(attrs={'class': 'form-control'}),
'redis_batch_size': NumberInput(attrs={'class': 'form-control'}),
Expand Down Expand Up @@ -827,21 +827,26 @@ def clean(self):

""" Rsyslog queue fields verification """
if cleaned_data.get('dequeue_batch_size'):
if cleaned_data['dequeue_batch_size'] > cleaned_data.get('queue_size', 50000):
queue_size = cleaned_data.get('queue_size') or 50000
if cleaned_data['dequeue_batch_size'] > queue_size:
self.add_error("dequeue_batch_size", "This value cannot be over the queue size")

if cleaned_data.get('new_worker_minimum_messages'):
if cleaned_data['new_worker_minimum_messages'] > cleaned_data.get('queue_size', 50000):
queue_size = cleaned_data.get('queue_size') or 50000
if cleaned_data['new_worker_minimum_messages'] > queue_size:
self.add_error("new_worker_minimum_messages", "This value cannot be over the queue size")

if cleaned_data.get('enable_disk_assist') == True:
if cleaned_data.get('high_watermark') > cleaned_data.get('queue_size', 50000) \
or cleaned_data.get('low_watermark') > cleaned_data.get('queue_size', 50000):
queue_size = cleaned_data.get('queue_size') or 50000
high_watermark = cleaned_data.get('high_watermark') or queue_size * 0.9
low_watermark = cleaned_data.get('low_watermark') or queue_size * 0.7

if high_watermark > queue_size or low_watermark > queue_size:
self.add_error("queue_size", "Queue size is lower than a watermark")
if cleaned_data.get('high_watermark', cleaned_data.get('queue_size', 50000) * 0.9) < cleaned_data.get('low_watermark', cleaned_data.get('queue_size', 50000) * 0.7):
if high_watermark < low_watermark:
self.add_error("high_watermark", "High watermark is lower than the low watermark value")
self.add_error("low_watermark", "Low watermark is higher than the high watermark value")
if cleaned_data.get('max_disk_space') and cleaned_data.get('max_file_size', 16) > cleaned_data.get('max_disk_space'):
if cleaned_data.get('max_disk_space') and (cleaned_data.get('max_file_size') or 16) > cleaned_data.get('max_disk_space'):
self.add_error("max_file_size", "File size is higher than the disk space")

return cleaned_data
Expand Down
24 changes: 13 additions & 11 deletions vulture_os/services/frontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,14 @@ class Frontend(models.Model):
verbose_name=_("Rsyslog queue type")
)
queue_size = models.PositiveIntegerField(
blank=True, #50000
blank=True,
null=True,
help_text=_("Size of the queue in nb of message"),
verbose_name=_("Size of the queue in nb of message"),
validators=[MinValueValidator(100)]
)
dequeue_batch_size = models.PositiveIntegerField(
blank=True, #1024
blank=True,
null=True,
help_text=_("Size of the batch to dequeue"),
verbose_name=_("Size of the batch to dequeue"),
Expand All @@ -544,14 +544,15 @@ class Frontend(models.Model):
validators=[MinValueValidator(1)]
)
new_worker_minimum_messages = models.PositiveIntegerField(
blank=True, #queue.size/queue.workerthreads
blank=True,
null=True,
help_text=_("Number of messages in queue to start a new worker thread"),
verbose_name=_("Minimum messages to start a new worker"),
validators=[MinValueValidator(1)]
)
shutdown_timeout = models.PositiveIntegerField(
blank=True, #1500
default=5000,
blank=True,
null=True,
help_text=_("Time to wait for the queue to finish processing entries (in ms)"),
verbose_name=_("Queue timeout shutdown (ms)"),
Expand All @@ -563,28 +564,29 @@ class Frontend(models.Model):
verbose_name=_("Enable disk queue on failure")
)
high_watermark = models.PositiveIntegerField(
blank=True, #90% of queue.size
blank=True,
null=True,
help_text=_("Write in DA queue after nb messages"),
verbose_name=_("High watermark target"),
validators=[MinValueValidator(100)]
)
low_watermark = models.PositiveIntegerField(
blank=True, #70% of queue.size
blank=True,
null=True,
help_text=_("Write in DA queue until nb messages"),
verbose_name=_("Low watermark target"),
validators=[MinValueValidator(100)]
)
max_file_size = models.PositiveIntegerField(
blank=True, #16MB
default=256,
blank=True,
null=True,
help_text=_("Set the max value of the queue in MB"),
verbose_name=_("Max file size of the queue in MB"),
validators=[MinValueValidator(1)]
)
max_disk_space = models.PositiveIntegerField(
blank=True, #Undefined
blank=True,
null=True,
help_text=_("Limit the maximum disk space used by the queue in MB"),
verbose_name=_("Max disk space used by the queue in MB"),
Expand Down Expand Up @@ -1856,9 +1858,9 @@ def render_ruleset_options(self):
options_dict.update({
"highWatermark": self.high_watermark,
"lowWatermark": self.low_watermark,
"spoolDirectory": self.spool_directory,
"maxFileSize": f"{self.max_file_size}m",
"maxDiskSpace": f"{self.max_disk_space}m",
"spoolDirectory": self.spool_directory or "/var/tmp",
"maxFileSize": f"{self.max_file_size}m" if self.max_file_size else None,
"maxDiskSpace": f"{self.max_disk_space}m" if self.max_disk_space else None,
"saveOnShutdown": "on" if self.save_on_shutdown else None,
"filename": f"{self.get_ruleset()}_disk-queue",
"checkpointInterval": 1024
Expand Down

0 comments on commit 9040567

Please sign in to comment.