-
Notifications
You must be signed in to change notification settings - Fork 140
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
fix: do not redeploy segment-io's if it has been deployed previously #1079
fix: do not redeploy segment-io's if it has been deployed previously #1079
Conversation
r.Log.Error(err, "error to deploy manifests under "+segmentPath) | ||
return err | ||
} | ||
r.Log.Error(err, "error to get configmap 'odh-segment-key-config'") |
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.
No, it's under if apierrs.IsNotFound(err)
branch
I personally prefer to use functions for such cases, it allows to use early returns and avoid extra indentation levels, a-la
func (r *DSCInitializationReconciler) configureSegmentIO(ctx context.Context, dsciInit *dsci.DSCInitialization) error {
// create segment.io only when configmap does not exist in the cluster
segmentioConfigMap := &corev1.ConfigMap{}
err := r.Client.Get(ctx, client.ObjectKey{
Namespace: dsciInit.Spec.ApplicationsNamespace,
Name: "odh-segment-key-config",
}, segmentioConfigMap)
if err == nil {
return nil
}
if !apierrs.IsNotFound(err) {
r.Log.Error(err, "error to get configmap 'odh-segment-key-config'")
return err
}
segmentPath := filepath.Join(deploy.DefaultManifestPath, "monitoring", "segment")
if err := deploy.DeployManifestsFromPath(
r.Client,
dsciInit,
segmentPath,
dsciInit.Spec.ApplicationsNamespace,
"segment-io",
dsciInit.Spec.Monitoring.ManagementState == operatorv1.Managed); err != nil {
r.Log.Error(err, "error to deploy manifests under "+segmentPath)
return err
}
return nil
}
func (r *DSCInitializationReconciler) configureCommonMonitoring(ctx context.Context, dsciInit *dsci.DSCInitialization) error {
if err := r.configureSegmentIO(ctx, dsciInit); err != nil {
return err
}
But it's a matter of taste
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.
i have extract logic of segment-io into a dedicated function as you suggested.
Namespace: dsciInit.Spec.ApplicationsNamespace, | ||
Name: "odh-segment-key-config", | ||
}, segmentioConfigMap); err != nil { | ||
if apierrs.IsNotFound(err) { |
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.
Small amendments required due to conflict with #1078
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.
rebased
- dashboard is using segment-io's configmap to flip monitoring settings - upon upgrade, Operator redploy the same configmap to set data to "true" Signed-off-by: Wen Zhou <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ykaliuta The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fa8603c
into
opendatahub-io:incubation
…pendatahub-io#1079) - dashboard is using segment-io's configmap to flip monitoring settings - upon upgrade, Operator redploy the same configmap to set data to "true" Signed-off-by: Wen Zhou <[email protected]>
…pendatahub-io#1079) - dashboard is using segment-io's configmap to flip monitoring settings - upon upgrade, Operator redploy the same configmap to set data to "true" Signed-off-by: Wen Zhou <[email protected]>
Description
https://issues.redhat.com/browse/RHOAIENG-1205
How Has This Been Tested?
Screenshot or short clip
Merge criteria