-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Routed logs test now correctly checks if CNF is being tailed (#2034
) * Fix: Routed logs test now correctly checks if CNF is being tailed Ref: #2025 #2016 - The issue explained in #2025 where fluent was tailing itself instead of the CNF has been resolved. - The dead helm repo mentioned in #2016 has been replace by link to bitnami repo, there was a similar occurence in the spec test. - The family of fluentd functions and files have been refactored into configurable files (allows for future additions/checking of elastic, aws fluent, etc.). - The routed_logs test was also modified to conform to the new functions (also shortened). - Other files have been edited for completion/conformance with naming conventions. Signed-off-by: svteb <slavo.valko@tietoevry.com> * Fix: Corrected a require command in observability_spec.cr Refs: #2025 Signed-off-by: svteb <slavo.valko@tietoevry.com> * Refactor: better abstraction of fluent flavors Refs: #2025 - Reworked the config dictionary into classes that inherit from a base abstract class. - Renamed FluentManagement module to FluentManager - Interfaces changed to adhere to the new abstraction Signed-off-by: svteb <slavo.valko@tietoevry.com> --------- Signed-off-by: svteb <slavo.valko@tietoevry.com>
- Loading branch information
Showing
14 changed files
with
172 additions
and
243 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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,2 @@ | ||
aggregator: | ||
enabled: false |
This file contains 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 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 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,34 @@ | ||
require "sam" | ||
require "file_utils" | ||
require "colorize" | ||
require "totem" | ||
|
||
desc "Install FluentD" | ||
task "install_fluentd" do |_, args| | ||
FluentManager::FluentD.new.install | ||
end | ||
|
||
desc "Uninstall FluentD" | ||
task "uninstall_fluentd" do |_, args| | ||
FluentManager::FluentD.new.uninstall | ||
end | ||
|
||
desc "Install FluentDBitnami" | ||
task "install_fluentdbitnami" do |_, args| | ||
FluentManager::FluentDBitnami.new.install | ||
end | ||
|
||
desc "Uninstall FluentDBitnami" | ||
task "uninstall_fluentdbitnami" do |_, args| | ||
FluentManager::FluentDBitnami.new.uninstall | ||
end | ||
|
||
desc "Install FluentBit" | ||
task "install_fluentbit" do |_, args| | ||
FluentManager::FluentBit.new.install | ||
end | ||
|
||
desc "Uninstall FluentBit" | ||
task "uninstall_fluentbit" do |_, args| | ||
FluentManager::FluentBit.new.uninstall | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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,100 @@ | ||
module FluentManager | ||
abstract class FluentBase | ||
getter flavor_name : String | ||
getter repo_url : String | ||
getter values_file : String | ||
getter values_macro : String | ||
getter image_name : String | ||
getter chart : String | ||
|
||
def initialize(flavor_name : String, repo_url : String, values_file : String, values_macro : String, image_name : String, chart : String) | ||
@flavor_name = flavor_name | ||
@repo_url = repo_url | ||
@values_file = values_file | ||
@values_macro = values_macro | ||
@image_name = image_name | ||
@chart = chart | ||
end | ||
|
||
def install | ||
Log.info { "Installing #{flavor_name} daemonset using #{values_file}" } | ||
Helm.helm_repo_add(flavor_name, repo_url) | ||
File.write(values_file, values_macro) | ||
begin | ||
Helm.install("--values #{values_file} -n #{TESTSUITE_NAMESPACE} #{flavor_name} #{chart}") | ||
KubectlClient::Get.resource_wait_for_install("Daemonset", flavor_name, namespace: TESTSUITE_NAMESPACE) | ||
rescue Helm::CannotReuseReleaseNameError | ||
Log.info { "Release #{flavor_name} already installed" } | ||
end | ||
end | ||
|
||
def uninstall | ||
Log.info { "Uninstalling #{flavor_name} in #{TESTSUITE_NAMESPACE}" } | ||
Helm.delete("#{flavor_name} -n #{TESTSUITE_NAMESPACE}") | ||
end | ||
|
||
def installed? | ||
KubectlClient::Get.resource_wait_for_install("Daemonset", flavor_name, namespace: TESTSUITE_NAMESPACE) | ||
end | ||
end | ||
|
||
class FluentD < FluentBase | ||
def initialize | ||
super("fluentd", | ||
"https://fluent.github.io/helm-charts", | ||
"fluentd-values.yml", | ||
FLUENTD_VALUES, | ||
"fluent/fluentd-kubernetes-daemonset", | ||
"fluent/fluentd") | ||
end | ||
end | ||
|
||
class FluentDBitnami < FluentBase | ||
def initialize | ||
super("fluentdbitnami", | ||
"https://charts.bitnami.com/bitnami", | ||
"fluentd-bitnami-values.yml", | ||
FLUENTD_BITNAMI_VALUES, | ||
"bitnami/fluentd", | ||
"bitnami/fluentd") | ||
end | ||
end | ||
|
||
class FluentBit < FluentBase | ||
def initialize | ||
super("fluent-bit", | ||
"https://fluent.github.io/helm-charts", | ||
"fluentbit-values.yml", | ||
FLUENTBIT_VALUES, | ||
"fluent/fluent-bit", | ||
"fluent/fluent-bit") | ||
end | ||
end | ||
|
||
def self.find_active_match | ||
all_flavors.each do |flavor| | ||
match = ClusterTools.local_match_by_image_name(flavor.image_name) | ||
return match if match[:found] | ||
end | ||
nil | ||
end | ||
|
||
def self.pod_tailed?(pod_name, match) | ||
return false unless match | ||
|
||
fluent_pods = KubectlClient::Get.pods_by_digest(match[:digest]) | ||
fluent_pods.each do |fluent_pod| | ||
fluent_pod_name = fluent_pod.dig("metadata", "name").as_s | ||
logs = KubectlClient.logs(fluent_pod_name, namespace: TESTSUITE_NAMESPACE) | ||
Log.info { "Searching logs of #{fluent_pod_name} for string #{pod_name}" } | ||
Log.debug { "Fluent logs: #{logs}" } | ||
return true if logs[:output].to_s.includes?(pod_name) | ||
end | ||
|
||
false | ||
end | ||
|
||
def self.all_flavors : Array(FluentBase) | ||
[FluentD.new, FluentDBitnami.new, FluentBit.new] | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.