You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code references var.kyverno.logmatch_notification_rate_limit in line 53, but this variable is not defined in the kyverno variable object in variables.tf. This will cause a Terraform error when the log match alert is created.
The kyverno variable definition in examples/variables.tf has different structure and field names compared to the main variables.tf file. This inconsistency could lead to confusion and errors when using the module.
The variable name change from project to project_id is a breaking change that will require users to update their existing configurations. This should be clearly documented and potentially handled with backward compatibility.
variable"project_id" {
description="The Google Cloud project ID where logging exclusions will be created"type=string
}
The variable var.kyverno.notification_enabled is referenced but not defined in the kyverno variable object. This will cause a Terraform error when the configuration is applied.
Why: The variable var.kyverno.notification_enabled is referenced but not defined in the kyverno variable object in variables.tf, which would cause a Terraform error when applied.
High
Fix regex pattern syntax
The regex pattern uses forward slashes as delimiters but Terraform's replace function expects the pattern as a string without delimiters. This will cause the replacement to fail and potentially create invalid metric names.
Why: The regex pattern incorrectly uses forward slash delimiters which Terraform's replace function doesn't support, causing the replacement to fail and potentially creating invalid metric names.
High
General
Simplify cluster name validation
The count condition checks if cluster_name is not empty after trimming, but an empty string would still pass validation. Consider adding a validation rule or using a more robust check to prevent resource creation with invalid cluster names.
Why: The suggestion simplifies the validation but trimspace() is actually more robust as it handles whitespace-only strings, so the original code is better.
Using threshold_value = var.kyverno.metric_threshold_count - 1 with COMPARISON_GT creates an off-by-one error. To trigger when count reaches the threshold, use the threshold value directly with COMPARISON_GE.
Why: This is a critical logic error. Using threshold_value = var.kyverno.metric_threshold_count - 1 with COMPARISON_GT creates an off-by-one error that would trigger alerts incorrectly.
Medium
General
Fix filter concatenation syntax
The filter concatenation with ${trimspace(var.kyverno.filter_extra)} could create invalid log filter syntax if filter_extra is not empty and doesn't start with a logical operator. Add proper spacing and conditional logic.
Why: Valid concern about potential syntax issues when concatenating filter_extra, though the current implementation with trimspace() may work in most cases. The suggested improvement adds better conditional handling.
The notification_rate_limit block references var.kyverno.notification_rate_limit but this field is not defined in the variable schema. This will cause a Terraform error when the configuration is applied.
Why: This is a critical error that would cause Terraform to fail. The notification_rate_limit field is referenced but not defined in the kyverno variable schema, making this configuration invalid.
High
Fix variable name mismatch
The variable name kyverno_log_alert_settings doesn't match the expected variable name kyverno defined in the module's variables.tf. This mismatch will cause Terraform to fail during plan/apply.
Why: This is a critical error where kyverno_log_alert_settings is used instead of kyverno, which would cause Terraform to fail with an unknown argument error.
High
Update parameter name to project_id
The module call uses project = var.project but the module now expects project_id instead of project based on the variable changes. This will cause Terraform to fail with an unknown argument error.
Why: This is a critical error where the module parameter project should be project_id based on the variable changes in the PR, which would cause Terraform to fail.
The alert policy uses var.kyverno.notification_channels directly instead of the local variable local.kyverno_notification_channels which handles fallback to default channels. This inconsistency could result in missing notifications when no specific channels are configured.
Why: The suggestion correctly identifies an inconsistency where var.kyverno.notification_channels is used instead of local.kyverno_notification_channels, which could result in missing fallback to default channels when no specific channels are configured.
Medium
General
Fix threshold comparison logic
The threshold calculation subtracts a small value (0.000001) from the configured count, which could cause unexpected behavior when the count is exactly at the threshold. Use COMPARISON_GTE instead of COMPARISON_GT for clearer threshold semantics.
Why: The suggestion addresses a potential clarity issue with the threshold logic by recommending COMPARISON_GTE instead of COMPARISON_GT with a small subtraction, making the threshold behavior more explicit and predictable.
The threshold calculation var.kyverno.metric_threshold_count - 0.000001 is fragile and could cause precision issues. Use integer comparison with COMPARISON_GTE instead of subtracting a small decimal from the threshold.
Why: The suggestion correctly identifies a potential precision issue with floating-point arithmetic. Using COMPARISON_GTE with the exact integer value is cleaner and more reliable than subtracting a small decimal.
Low
Add null check for cluster_name
The condition checks if cluster_name is not empty after trimming, but doesn't validate if the variable itself is null. Add null check to prevent potential runtime errors.
Why: The suggestion identifies a potential null reference issue when calling trimspace() on a null value. However, the kyverno variable definition shows cluster_name is required (not optional), making null values less likely but still worth checking defensively.
Low
Add null safety for auto_close
Direct access to var.cloud_sql.auto_close may cause errors if the variable is null. The removed local variable cloud_sql_auto_close provided proper null handling with fallback logic.
Why: The suggestion addresses a potential null reference issue, but the cloud_sql variable definition shows auto_close has a default value of "86400s", making null values unlikely. The concern is valid but less critical given the default.
The reason will be displayed to describe this comment to others. Learn more.
Rifai un check, ti ho lasciato dei commenti. Cmq sai che non mi è del tutto chiara la questione use_metric_threshold? perchè dovremmo volerla attivare? mi pare più un'esercizio di stile che altro 🤔
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
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.
PR Type
Enhancement
Description
Add Kyverno monitoring alerts for controller error logs
Refactor variable names from
projecttoproject_idAdd notification enablement controls for both services
Update documentation and improve code formatting
Changes walkthrough 📝
5 files
Refactor project variables and notification logicUpdate example with Kyverno configurationAdd Kyverno variable and rename project variableAdd Kyverno error log monitoring alertsRename project variable and add Kyverno configuration1 files
Create empty main configuration file2 files
Document version 0.3.0 with Kyverno alertsUpdate documentation with Kyverno monitoring details1 files
Add version variables for Docker tools1 files
Update test variables to use project_id