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

feat: Enable config to log diff on objects when updating #583

Merged
merged 2 commits into from
Sep 9, 2021

Conversation

amisevsk
Copy link
Collaborator

@amisevsk amisevsk commented Sep 7, 2021

What does this PR do?

Use the experimental features flag to enable additional logging when updating objects on the cluster. If experimental features are enabled and a spec object is found to be different from the cluster one, log a
diff between the two.

What issues does this PR fix or reference?

Fixes #581

Is it tested? How?

  1. Start DWO with experimental features enabled
  2. Create a devworkspace
  3. Edit e.g. the deployment/service/devworkspacerouting and check logs

Note that since the controller uses json-structured logging, newlines and tabs are escaped in log messages. An easy way to work around this is to pipe to sed -e 's|\\n|\n|g; s|\\t| |g' -- though, note if using make run it's also necessary to pipe stderr to stdout, i.e. make run 2>&1 | sed -e 's|\\n|\n|g; s|\\t| |g'. Another option is to copy paste a msg and feed it to printf.

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

Use the experimental features flag to enable additional logging when
updating objects on the cluster. If experimental features are enabled
and a spec object is found to be different from the cluster one, log a
diff between the two. This can potentially be useful for diagnosing
reconcile loops.

Due to json-structured logging, the formatted message is escaped into a
string, and so must be parsed for reading (e.g. by piping through sed:

    make run 2>&1 | sed -e 's|\\n|\n|g; s|\\t|    |g'

for quick checking, the .msg can be copy-pasted as the argument the
printf to interpret \t and \n

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

LGTM
Just assume that the object name may be useful as well in logs.

@@ -55,6 +55,10 @@ func (r *DevWorkspaceRoutingReconciler) syncRoutes(routing *controllerv1alpha1.D
if contains, idx := listContainsRouteByName(specRoute, clusterRoutes); contains {
clusterRoute := clusterRoutes[idx]
if !cmp.Equal(specRoute, clusterRoute, routeDiffOpts) {
r.Log.Info("Updating route")
Copy link
Member

Choose a reason for hiding this comment

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

Route name is not in log context only workspace id and probably name/namespace.
So, maybe adding object name makes sense as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

@openshift-ci openshift-ci bot removed the lgtm label Sep 8, 2021
@amisevsk amisevsk changed the title Enable config to log diff on objects when updating feat: Enable config to log diff on objects when updating Sep 8, 2021
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk
Copy link
Collaborator Author

amisevsk commented Sep 8, 2021

/test v8-devworkspace-operator-e2e, v8-che-happy-path

@@ -121,7 +121,7 @@ func SyncDeploymentToCluster(
}

if clusterDeployment == nil {
clusterAPI.Logger.Info("Creating deployment...")
clusterAPI.Logger.Info("Creating deployment")
Copy link
Member

Choose a reason for hiding this comment

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

deployment name can be useful here as well, but since ATM we have only one and one deployment, that's OK

@sleshchenko sleshchenko merged commit 9624f26 into devfile:main Sep 9, 2021
@openshift-ci openshift-ci bot added the lgtm label Sep 9, 2021
@openshift-ci
Copy link

openshift-ci bot commented Sep 9, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, JPinkney, sleshchenko

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:
  • OWNERS [JPinkney,amisevsk,sleshchenko]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@amisevsk amisevsk deleted the diff-context-on-update branch September 9, 2021 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DevWorkspace operator should better reported found differences on reconcilation
3 participants