-
Notifications
You must be signed in to change notification settings - Fork 151
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
chore: address comments for monitoring component #1520
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
appsv1 "k8s.io/api/apps/v1" | ||
k8serr "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
||
|
@@ -79,13 +80,13 @@ | |
// read the component instance to get tha actual status | ||
err := rr.Client.Get(ctx, client.ObjectKeyFromObject(ci), ci) | ||
switch { | ||
case err != nil: | ||
case err == nil: | ||
enabled = meta.IsStatusConditionTrue(ci.GetStatus().Conditions, status.ConditionTypeReady) | ||
case k8serr.IsNotFound(err): | ||
enabled = false | ||
if !k8serr.IsNotFound(err) { | ||
return fmt.Errorf("error getting component state: component=%s, enabled=%t, error=%w", ch.GetName(), enabled, err) | ||
} | ||
default: | ||
enabled = meta.IsStatusConditionTrue(ci.GetStatus().Conditions, status.ConditionTypeReady) | ||
enabled = false | ||
return fmt.Errorf("error getting component state: component=%s, enabled=%t, error=%w", ch.GetName(), enabled, err) | ||
} | ||
|
||
// Check for shared components | ||
|
@@ -111,6 +112,17 @@ | |
if !ok { | ||
return errors.New("instance is not of type *services.Monitoring") | ||
} | ||
|
||
// TODO: deprecate phase | ||
m.Status.Phase = "NotReady" | ||
// condition | ||
nc := metav1.Condition{ | ||
Type: string(ReadyConditionType), | ||
Status: metav1.ConditionFalse, | ||
Reason: status.ReconcileInit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if |
||
Message: status.PhaseNotReady, | ||
} | ||
|
||
promDeployment := &appsv1.DeploymentList{} | ||
err := rr.Client.List( | ||
ctx, | ||
|
@@ -128,10 +140,15 @@ | |
} | ||
} | ||
|
||
m.Status.Phase = "NotReady" | ||
if len(promDeployment.Items) == 1 && ready == 1 { | ||
// TODO: deprecate phase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
m.Status.Phase = "Ready" | ||
// condition | ||
nc.Status = metav1.ConditionTrue | ||
nc.Reason = status.ReconcileCompleted | ||
nc.Message = status.ReconcileCompletedMessage | ||
} | ||
meta.SetStatusCondition(&m.Status.Conditions, nc) | ||
m.Status.ObservedGeneration = m.GetObjectMeta().GetGeneration() | ||
|
||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for service/component, the ready condition should just be
Ready
, the suffix is only needed if the service/component specific readiness condition is exposed in an higher level API (i.e. DSC/DSCI)