Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addon: Add support for logging agent health checking #42

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

btaani
Copy link
Contributor

@btaani btaani commented Apr 24, 2024

With this PR, the addon agent will perform health checks on the spoke-cluster's ClusterLogForwarder and OTEL collector instances.

For the OTEL collector, if the .spec.replicas field is 0, it will report AVAILABLE = False to the addon:

$ oc get managedclusteraddons.addon.open-cluster-management.io -n spoke-cluster multicluster-observability-addon 
NAME                               AVAILABLE   DEGRADED   PROGRESSING
multicluster-observability-addon   False                  

For the ClusterLogForwarder resource, the health is based on the status fields .status.conditions.type and .status.conditions.status

@coveralls
Copy link

coveralls commented Apr 24, 2024

Pull Request Test Coverage Report for Build 9196016992

Details

  • 53 of 67 (79.1%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.3%) to 51.888%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/addon/addon.go 53 67 79.1%
Totals Coverage Status
Change from base Build 8877284128: 1.3%
Covered Lines: 371
Relevant Lines: 715

💛 - Coveralls

Copy link
Collaborator

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment, currently MCOA supports having multiple signals enabled or disabled so in the ideal scenario the health prober should consider that all signals might not always be enabled (if possible).

@btaani btaani marked this pull request as ready for review May 22, 2024 17:40
@btaani btaani requested review from a team as code owners May 22, 2024 17:40
Comment on lines +36 to +37
OtelcolName = "spoke-otelcol"
OtelcolNS = "spoke-otelcol"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get this information from the ManagedClusterAddOn object. The same for Logging

Copy link
Collaborator

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Looks promising 👀

internal/addon/addon.go Show resolved Hide resolved
Comment on lines +94 to +98
if *value.Value.String == "Ready" {
return nil
}

return fmt.Errorf("%w: status condition type is %s for %s/%s", ErrWrongType, *value.Value.String, identifier.Namespace, identifier.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this way it's easier to understand the code path

Suggested change
if *value.Value.String == "Ready" {
return nil
}
return fmt.Errorf("%w: status condition type is %s for %s/%s", ErrWrongType, *value.Value.String, identifier.Namespace, identifier.Name)
if *value.Value.String != "Ready" {
return fmt.Errorf("%w: status condition type is %s for %s/%s", ErrWrongType, *value.Value.String, identifier.Namespace, identifier.Name)
}
return nil

Comment on lines +104 to +108
if *value.Value.Integer >= 1 {
return nil
}

return fmt.Errorf("%w: replicas is %d for %s/%s", ErrWrongType, *value.Value.Integer, identifier.Namespace, identifier.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
if *value.Value.Integer >= 1 {
return nil
}
return fmt.Errorf("%w: replicas is %d for %s/%s", ErrWrongType, *value.Value.Integer, identifier.Namespace, identifier.Name)
if *value.Value.Integer < 1 {
return fmt.Errorf("%w: replicas is %d for %s/%s", ErrWrongType, *value.Value.Integer, identifier.Namespace, identifier.Name)
}
return nil

},
HealthCheck: func(identifier workapiv1.ResourceIdentifier, result workapiv1.StatusFeedbackResult) error {
for _, value := range result.Values {
if identifier.Resource == ClfResource {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would change the if... else if... else to a switch statement, that might make it more easy read

internal/addon/addon.go Outdated Show resolved Hide resolved
internal/addon/addon.go Outdated Show resolved Hide resolved
internal/addon/addon.go Outdated Show resolved Hide resolved
internal/addon/addon_test.go Outdated Show resolved Hide resolved
btaani and others added 4 commits May 23, 2024 11:30
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
Co-authored-by: Joao Marcal <joao.marcal12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants