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

bugfixs of dependencies distributor #1499

Merged
merged 2 commits into from Mar 18, 2022

Conversation

mrlihanbo
Copy link

@mrlihanbo mrlihanbo commented Mar 17, 2022

What type of PR is this?
/kind bug

What this PR does / why we need it:
Bugfixs of dependencies distributor :

  1. Enqueue the resource binding that has been scheduled to member clusters.
  2. Update Resource info when update attached bindings.
  3. Add some logs.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: Fixed ResourceBinding maybe prevents en-queue in case of schedule failure.

…r clusters

Signed-off-by: lihanbo <lihanbo2@huawei.com>
Signed-off-by: lihanbo <lihanbo2@huawei.com>
@karmada-bot karmada-bot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. labels Mar 17, 2022
@karmada-bot karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 17, 2022
@RainbowMango
Copy link
Member

  1. How to reproduce it?
  2. Please add a release note.

@karmada-bot karmada-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 17, 2022
@mrlihanbo
Copy link
Author

mrlihanbo commented Mar 17, 2022

To reproduce bug: enqueue the resource binding that has been scheduled to member clusters

  1. create a deployment which references configMap:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: configmap
          mountPath: "/configmap"
      volumes:
      - name: configmap
        configMap:
          name: game-config
  1. create configMap:
apiVersion: v1
kind: ConfigMap
metadata:
  name: game-config
data:
  game.properties: |
    enemies=aliens
    lives=3
    enemies.cheat=true
    enemies.cheat.level=noGoodRotten
    secret.code.passphrase=UUDDLRLRBABAS
    secret.code.allowed=true
    secret.code.lives=30
  1. create a propagation policy to propagate deployment to member1:
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation
spec:
  propagateDeps: true
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - member1
    replicaScheduling:
      replicaSchedulingType: Duplicated
  1. update the propagation policy to propagate deployment to member4(which is not exist):
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation
spec:
  propagateDeps: true
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - member4
    replicaScheduling:
      replicaSchedulingType: Duplicated
  1. then we will found out the resource binding will reserve the last successful schedule result and the Scheduled condition is false:
apiVersion: work.karmada.io/v1alpha2
kind: ResourceBinding
metadata:
  annotations:
    lhb: lhb
  creationTimestamp: "2022-03-14T05:49:11Z"
  finalizers:
  - karmada.io/binding-controller
  generation: 29
  labels:
    propagationpolicy.karmada.io/name: nginx-propagation
    propagationpolicy.karmada.io/namespace: default
  name: nginx-deployment
  namespace: default
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: Deployment
    name: nginx
    uid: 71d5023f-0d51-4e2a-9f31-9ddf553bc536
  resourceVersion: "768505"
  uid: 6a605353-5683-4205-b58d-d6ce8b6e75d8
spec:
  clusters:
  - name: member1
    replicas: 2
  replicas: 2
  resource:
    apiVersion: apps/v1
    kind: Deployment
    name: nginx
    namespace: default
    resourceVersion: "768434"
    uid: 71d5023f-0d51-4e2a-9f31-9ddf553bc536
status:
  aggregatedStatus:
  - applied: true
    clusterName: member1
    status:
      availableReplicas: 2
      conditions:
      - lastTransitionTime: "2022-03-17T07:31:36Z"
        lastUpdateTime: "2022-03-17T07:31:36Z"
        message: Deployment has minimum availability.
        reason: MinimumReplicasAvailable
        status: "True"
        type: Available
      - lastTransitionTime: "2022-03-17T07:31:30Z"
        lastUpdateTime: "2022-03-17T07:31:36Z"
        message: ReplicaSet "nginx-6799fc88d8" has successfully progressed.
        reason: NewReplicaSetAvailable
        status: "True"
        type: Progressing
      observedGeneration: 1
      readyReplicas: 2
      replicas: 2
      updatedReplicas: 2
  conditions:
  - lastTransitionTime: "2022-03-17T07:31:30Z"
    message: All works have been successfully applied
    reason: FullyAppliedSuccess
    status: "True"
    type: FullyApplied
  - lastTransitionTime: "2022-03-17T07:31:54Z"
    message: no clusters fit
    reason: BindingFailedScheduling
    status: "False"
    type: Scheduled
  1. when we update deployment, the resource binding will be dropped in dependencies distributor as its Scheduled condtion is false.

@mrlihanbo
Copy link
Author

To reproduce bug: update Resource info when update attached bindings.

  1. create a deployment which references configMap:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: configmap
          mountPath: "/configmap"
      volumes:
      - name: configmap
        configMap:
          name: game-config
  1. create configMap:
apiVersion: v1
kind: ConfigMap
metadata:
  name: game-config
data:
  game.properties: |
    enemies=aliens
    lives=3
    enemies.cheat=true
    enemies.cheat.level=noGoodRotten
    secret.code.passphrase=UUDDLRLRBABAS
    secret.code.allowed=true
    secret.code.lives=30
  1. create a propagation policy to propagate deployment to member1:
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation
spec:
  propagateDeps: true
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - member1
    replicaScheduling:
      replicaSchedulingType: Duplicated
  1. update the configmap to add data:
apiVersion: v1
kind: ConfigMap
metadata:
  name: game-config
data:
  game.properties: |
    enemies=aliens
    lives=3
    enemies.cheat=true
    enemies.cheat.level=noGoodRotten
    secret.code.passphrase=UUDDLRLRBABAS
    secret.code.allowed=true
    secret.code.lives=30    
  ui.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true
    how.nice.to.look=fairlyNice
  1. you will found that the configmap in member1 is not updated as the reference binding is not updated.

// prevent newBindingObject from the queue if it's not in Scheduled condition
if !helper.IsBindingScheduled(&newBindingObject.Status) {
// prevent newBindingObject from the queue if it's not scheduled yet.
if len(oldBindingObject.Spec.Clusters) == 0 && len(newBindingObject.Spec.Clusters) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

When len(oldBindingObject.Spec.Clusters) == 0 and len(newBindingObject.Spec.Clusters) != 0, does it also need to be added to the queue?

Copy link
Author

Choose a reason for hiding this comment

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

When len(oldBindingObject.Spec.Clusters) == 0 and len(newBindingObject.Spec.Clusters) != 0, does it also need to be added to the queue?

When len(oldBindingObject.Spec.Clusters) == 0 and len(newBindingObject.Spec.Clusters) != 0, it means the resource will be scheduled to some clusters, and it need to be enqueued so that dependencies distributor will propagate its dependencies to the same clusters.
When len(oldBindingObject.Spec.Clusters) != 0 and len(newBindingObject.Spec.Clusters) == 0, it means the resource has been scheduled to some clusters and now be deleted, and it need to be enqueued so that dependencies distributor will remove its dependencies from the clusters.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 18, 2022
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 18, 2022
@karmada-bot karmada-bot merged commit d8bcedc into karmada-io:master Mar 18, 2022
@RainbowMango
Copy link
Member

Hi @mrlihanbo , please check-pick this patch to release-1.1 branch.

Here is the script you can leverage: https://github.com/karmada-io/karmada/blob/master/hack/cherry_pick_pull.sh

karmada-bot added a commit that referenced this pull request Mar 21, 2022
…9-upstream-release-1.1

Automated cherry pick of #1499: bugfix: enqueue the resource binding that has been
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants