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

NETOBSERV-1076 Fix service change detection #360

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

jotak
Copy link
Member

@jotak jotak commented Jun 2, 2023

use DeepDerivative on labels & annotations only, rather than full ObjectMeta

use DeepDerivative on labels & annotations only, rather than full
ObjectMeta
@jotak jotak requested a review from msherif1234 June 2, 2023 13:12
@jotak jotak added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jun 2, 2023
@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Merging #360 (b5690fd) into main (ca61fad) will increase coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   53.37%   53.53%   +0.15%     
==========================================
  Files          45       45              
  Lines        5328     5329       +1     
==========================================
+ Hits         2844     2853       +9     
+ Misses       2281     2273       -8     
  Partials      203      203              
Flag Coverage Δ
unittests 53.53% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/helper/comparators.go 78.08% <100.00%> (+0.30%) ⬆️

... and 3 files with indirect coverage changes

@github-actions
Copy link

github-actions bot commented Jun 2, 2023

New images:

  • quay.io/netobserv/network-observability-operator:e50247e
  • quay.io/netobserv/network-observability-operator-bundle:v0.0.0-e50247e
  • quay.io/netobserv/network-observability-operator-catalog:v0.0.0-e50247e

They will expire after two weeks.

Catalog source:

apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: netobserv-dev
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-e50247e
  displayName: NetObserv development catalog
  publisher: Me
  updateStrategy:
    registryPoll:
      interval: 1m

@nathan-weinberg
Copy link
Contributor

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved QE has approved this pull request label Jun 2, 2023
@jotak
Copy link
Member Author

jotak commented Jun 2, 2023

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jun 2, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

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-ci openshift-ci bot added the approved label Jun 2, 2023
@msherif1234
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 2, 2023
@openshift-merge-robot openshift-merge-robot merged commit 6aa0188 into netobserv:main Jun 2, 2023
9 checks passed
@@ -75,7 +75,8 @@ func probeChanged(old, new *corev1.Probe) bool {
}

func ServiceChanged(old, new *corev1.Service, report *ChangeReport) bool {
return report.Check("Service meta changed", !equality.Semantic.DeepDerivative(new.ObjectMeta, old.ObjectMeta)) ||
return report.Check("Service annotations changed", !equality.Semantic.DeepDerivative(new.Annotations, old.Annotations)) ||
report.Check("Service labels changed", !equality.Semantic.DeepDerivative(new.Labels, old.Labels)) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

What part of corev1.Service changed that triggered this to return true, or does it not matter because it's clear that only Annotations and Labels are relevant?  Why was this not happening before?

Copy link
Member Author

@jotak jotak Jun 2, 2023

Choose a reason for hiding this comment

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

Many parts of the ObjectMeta will differ when comparing an existing object with a newly built object; e.g. are the uuid, revision number, etc. It's safe to rely only on labels & annotations because that's at the moment the only things in ObjectMeta that we partly derive from configuration*. You can see an example here of a service that we create: https://github.com/netobserv/network-observability-operator/blob/main/controllers/consoleplugin/consoleplugin_objects.go#L300-L322

*: with the exception of the namespace, but a change of namespace triggers a whole different reconciliation process.

Why it happens only now? I wasn't sure... but now I remember something: in #326, during the refactoring I fixed something related to the DidChange / IsInProgress stuff: previously it wasn't fully working in every situation because these were fields of a structure that happened to be sometimes copied as argument - which means that the "didChange" field of the parent was never updated when the one from the copy was. I fixed it by making didChange/isInProgress variables now only created and owned from the parent, and updated via lambdas.

So, tl;dr: it was happening before, but without the same impact on the "Updating" CR status.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the detailed explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. qe-approved QE has approved this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants