feat/teams-integration #40
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/teams-integration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
You missed the point of using a trait here. See my comment and refactor accordingly.
@@ -5,0 +9,4 @@mod prometheus_msteams;#[derive(Debug, Clone, Serialize)]pub enum AlertChannel {This defeats the purpose of using a trait. Also prevents extensibility by external users of Harmony.
If this were a trait, then anybody can
impl AlertChannel for MyCustomMessageReceiverand use this AlertChannel in his Harmony deployment.Much better than previous iteration. But still a lot of room for improvement.
First : this should be split into 4-5 pull requests :
Then, I have quite a few more comments that you will see below.
@@ -0,0 +1,14 @@[package]This should be behind a feature flag such as "msteams-deprecated"
Oh it's in the examples, forget this.
@@ -0,0 +38,4 @@webhook_url: Url,}#[typetag::serde]typetag doesn't seem to be a good idea here. Why do you use it? Show me an actual use case that requires it versus having a trait bound
+ Serializeon the PrometheusAlertChannel trait.@@ -0,0 +16,4 @@use std::fmt::Debug;use url::Url;#[typetag::serde(tag = "channel_type")]Yeah I don't think this will work. Show me the actual json that this produces and why you need to use this.
Always be extremely careful when introducing a new dependency in the project. If we need a new dependency it can mean two things :
+ Serializerequirement to the trait like we do with the Score trait.@@ -0,0 +18,4 @@#[typetag::serde(tag = "channel_type")]#[async_trait::async_trait]pub trait PrometheusAlertChannel: DynClone + Debug + Send + Sync {I think PrometheusAlertChannel is a good name for the trait. However both function names feel off :
get_alert_manager_config_contribution : what does this mean? What is the word
contributiondoing here? I feel like the return type is correct or almost correct but the function name is weird. From my understanding here this trait's job is to provide a serializable alert channel yaml configuration that can be insterted in a list of prometheus alert channels.get_dependency_score : this feels very wrong. I'm pretty sure this violates the Single Responsibility Principle as well as Harmony's architecture guidelines.
Please add a rustdoc explaining what is the purpose of this trait. Then review the SRP and make sure that it is followed here.
@@ -0,0 +1,94 @@use serde::{Deserialize, Serialize};This entire file looks pretty good 👍
Almost all types seem to describe the proper abstractions of prometheus types.
However, the implementation specific types should be bundled with their respective implementations. Such as SlackConfig and WebhookConfig.
@@ -74,1 +65,4 @@config.namespace = ns.clone();};let null_channel = NullReceiver::new();Is this really required? This feels wrong, at least it would deserve a small comment explaining why you are ALWAYS instanciating a hardcoded NullReceiver
@@ -77,0 +87,4 @@let alert_manager_config = AlertManagerConfig {global: global_config,route: AlertManagerRoute {Why is all this config hardcoded? Shouldn't it be exposed in the Score's configuration? I think it should have defaults so that users are not forced to set everything by themselves but it should not be hardcoded.
@@ -91,3 +122,3 @@}async fn deploy_alert_channel_service<T: Topology + HelmCommand>(async fn deploy_alert_channel_dependencies<T: Topology + HelmCommand>(I am 99% sure this is wrong.
Dependencies should be handled at the Topology level as capabilities. But I'm not 100% sure because this has the drawback of not being "just in time" when the score is executed. This would be happening right at the Topology's initialization.
However, this implementation here has many drawbacks :
The PrometheusAlertChannel is handling dependencies in a unique way, that is not following the rest of Harmony's architecture.
Take the K8sAnywhereTopology for example : K8sResourceScore has a K8sClient dependency, which is provided by K8sAnywhere. Then, upon initialization, K8sAnywhere will make sure that it is fulfilling is contract by making sure that there is a K8sClient available, either by installing K3d locally or verifying that it is able to reach whatever cluster it is connected to.
This means that I would have expected this architecture :
Pull request closed