karmada icon indicating copy to clipboard operation
karmada copied to clipboard

fix propagation bug when resource create before lazy policy applied

Open chaosi-zju opened this issue 1 year ago • 7 comments

What type of PR is this?

/kind bug

What this PR does / why we need it:

fix propagation bug when resource create before lazy policy applied:

first create a deployment and then create a lazy policy(activationPreference=lazy)

if then we delete this lazy policy, then this deployment will never be matched by any following new policies.

detail refers to #5348

Which issue(s) this PR fixes:

Fixes #5348

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


chaosi-zju avatar Aug 10 '24 09:08 chaosi-zju

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.

Project coverage is 29.34%. Comparing base (052b06e) to head (e9e14aa). Report is 38 commits behind head on master.

Files Patch % Lines
pkg/detector/detector.go 0.00% 26 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5349      +/-   ##
==========================================
+ Coverage   28.45%   29.34%   +0.89%     
==========================================
  Files         632      632              
  Lines       43856    43878      +22     
==========================================
+ Hits        12481    12878     +397     
+ Misses      30472    30067     -405     
- Partials      903      933      +30     
Flag Coverage Δ
unittests 29.34% <0.00%> (+0.89%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 10 '24 09:08 codecov-commenter

Just recording, not related to this PR...

CI failure: https://github.com/karmada-io/karmada/actions/runs/10331176206/job/28601118594?pr=5349

日志:controller.log5349.txt

Work (member2)
"status": {
    "conditions": [
      {
        "type": "Dispatching",
        "status": "True",
        "lastTransitionTime": "2024-08-10T11:34:37Z",
        "reason": "Dispatching",
        "message": "Work is being dispatched to member clusters."
      },
      {
        "type": "Applied",
        "status": "False",
        "lastTransitionTime": "2024-08-10T11:34:38Z",
        "reason": "AppliedFailed",
        "message": "Failed to apply all manifests (0/1): Operation cannot be fulfilled on deployments.apps \"deploy-4ptf8\": the object has been modified; please apply your changes to the latest version and try again"
      }
    ],
    "manifestStatuses": [
      {
        "identifier": {
          "ordinal": 0,
          "group": "apps",
          "version": "v1",
          "kind": "Deployment",
          "resource": "",
          "namespace": "karmadatest-ndw6b",
          "name": "deploy-4ptf8"
        },
        "status": {
          "availableReplicas": 2,
          "generation": 3,
          "observedGeneration": 3,
          "readyReplicas": 2,
          "replicas": 2,
          "resourceTemplateGeneration": 4,
          "updatedReplicas": 2
        },
        "health": "Healthy"
      }
    ]
  }
RB
"aggregatedStatus": [
      {
        "clusterName": "member1",
        "status": {
          "availableReplicas": 2,
          "generation": 4,
          "observedGeneration": 4,
          "readyReplicas": 2,
          "replicas": 2,
          "resourceTemplateGeneration": 4,
          "updatedReplicas": 2
        },
        "applied": true,
        "health": "Healthy"
      },
      {
        "clusterName": "member2",
        "appliedMessage": "Failed to apply all manifests (0/1): Operation cannot be fulfilled on deployments.apps \"deploy-4ptf8\": the object has been modified; please apply your changes to the latest version and try again",
        "health": "Unknown"
      }
    ]
  }
Deployment
"status": {
    "availableReplicas": 2,
    "observedGeneration": 3,
    "readyReplicas": 2,
    "replicas": 2,
    "updatedReplicas": 2
  }
logs
2024-08-10T11:34:38.390330198Z stderr F E0810 11:34:38.390157       1 objectwatcher.go:169] Failed to update resource(kind=Deployment, karmadatest-ndw6b/deploy-4ptf8) in cluster member2, err: Operation cannot be fulfilled on deployments.apps "deploy-4ptf8": the object has been modified; please apply your changes to the latest version and try again.
2024-08-10T11:34:38.390560231Z stderr F E0810 11:34:38.390505       1 execution_controller.go:208] Failed to create or update resource(karmadatest-ndw6b/deploy-4ptf8) in the given member cluster member2, err is Operation cannot be fulfilled on deployments.apps "deploy-4ptf8": the object has been modified; please apply your changes to the latest version and try again
2024-08-10T11:34:38.527329822Z stderr F E0810 11:34:38.488605       1 execution_controller.go:150] Failed to sync work(karmada-es-member2/deploy-4ptf8-654d4fb84c) to cluster(member2), err: Operation cannot be fulfilled on deployments.apps "deploy-4ptf8": the object has been modified; please apply your changes to the latest version and try again
2024-08-10T11:34:38.527710748Z stderr F E0810 11:34:38.527386       1 controller.go:324] "Reconciler error" err="Operation cannot be fulfilled on deployments.apps \"deploy-4ptf8\": the object has been modified; please apply your changes to the latest version and try again" controller="work" controllerGroup="work.karmada.io" controllerKind="Work" Work="karmada-es-member2/deploy-4ptf8-654d4fb84c" namespace="karmada-es-member2" name="deploy-4ptf8-654d4fb84c" reconcileID="975444f0-24cb-4faf-af39-8aeee758f3ad"
...
2024-08-10T11:34:38.532659245Z stderr F I0810 11:34:38.532592       1 execution_controller.go:76] Reconciling Work karmada-es-member2/deploy-4ptf8-654d4fb84c
2024-08-10T11:34:38.550410018Z stderr F I0810 11:34:38.550334       1 objectwatcher.go:173] Updated the resource(kind=Deployment, karmadatest-ndw6b/deploy-4ptf8) on cluster(member2).
2024-08-10T11:34:38.551362429Z stderr F I0810 11:34:38.551304       1 execution_controller.go:155] Sync work(karmada-es-member2/deploy-4ptf8-654d4fb84c) to cluster(member2) successful.

chaosi-zju avatar Aug 12 '24 03:08 chaosi-zju

/retest

chaosi-zju avatar Aug 12 '24 03:08 chaosi-zju

/cc @chaunceyjiang can you please help reviewing it?

chaosi-zju avatar Aug 12 '24 04:08 chaosi-zju

/cc @XiShanYongYe-Chang can you please help reviewing it?

chaosi-zju avatar Aug 13 '24 01:08 chaosi-zju

Thanks @chaosi-zju /assign

XiShanYongYe-Chang avatar Aug 13 '24 13:08 XiShanYongYe-Chang

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please ask for approval from xishanyongye-chang. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

karmada-bot avatar Aug 14 '24 09:08 karmada-bot