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

fix: do not redeploy segment-io's if it has been deployed previously #1079

Merged

Conversation

zdtsw
Copy link
Member

@zdtsw zdtsw commented Jun 25, 2024

  • dashboard is using segment-io's configmap to flip monitoring settings
  • upon upgrade, Operator redploy the same configmap to set data to "true"
  • pass in context

Description

https://issues.redhat.com/browse/RHOAIENG-1205

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

r.Log.Error(err, "error to deploy manifests under "+segmentPath)
return err
}
r.Log.Error(err, "error to get configmap 'odh-segment-key-config'")
Copy link
Contributor

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

Copy link
Member Author

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) {
Copy link
Contributor

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

Copy link
Member Author

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]>
Copy link

openshift-ci bot commented Jun 25, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit fa8603c into opendatahub-io:incubation Jun 25, 2024
8 checks passed
zdtsw added a commit to zdtsw-forking/rhods-operator that referenced this pull request Jul 4, 2024
…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]>
openshift-merge-bot bot pushed a commit to red-hat-data-services/rhods-operator that referenced this pull request Jul 5, 2024
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants