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

ceph: merge toleration for osd/prepareOSD pod if specified both places #8566

Merged
merged 1 commit into from Aug 26, 2021

Conversation

subhamkrai
Copy link
Contributor

@subhamkrai subhamkrai commented Aug 19, 2021

earlier, ApplyToPodSpec() was only taking one toleration and ignoring
tolerations from placement.ALL().

Description of your changes:
this commit merge toleration for Mgr,Mon,Osd pod
For example, for osd it will merge
spec.placement.all and
storageDeviceClassSets.Placement(in case of pvc) or
spec.placement.osd(in case of non-pvc's).

Signed-off-by: subhamkrai srai@redhat.com

TODO
Test on PVC cluster

  • when toleration applied to placement.All()
  • when toleration applied to storageDeviceClassSets.All()

Test on non-PVC cluster

  • when toleration applied to placement.All()
  • when toleration applied to spec.placement.osd

Which issue is resolved by this Pull Request:
Resolves #

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

@mergify mergify bot added the ceph main ceph tag label Aug 19, 2021
@subhamkrai
Copy link
Contributor Author

subhamkrai commented Aug 19, 2021

test result on cluster on pvc when toleration applied at spec.Placement.ALL()
cluster-on-pvc.yaml

spec:
  placement:
   all:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: topology.kubernetes.io/zone
              operator: In
              values:
              - ap-southeast-1a
              - ap-southeast-1b
              - ap-southeast-1c
              - ap-southeast-1d
      tolerations:
      - key: "key1"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"

get cephcluster -o yaml

 placement:
      all:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: topology.kubernetes.io/zone
                operator: In
                values:
                - ap-southeast-1a
                - ap-southeast-1b
                - ap-southeast-1c
                - ap-southeast-1d
        tolerations:
        - effect: NoSchedule
          key: key1
          operator: Equal
          value: value1

get pods

rook-ceph-mgr-a-656447c65b-p6lbd                            1/1     Running     0          15m
rook-ceph-mon-a-669b744887-phqh6                            1/1     Running     0          19m
rook-ceph-mon-b-78f498cd68-mqq26                            1/1     Running     0          19m
rook-ceph-mon-c-6fdff8fd4f-9hhd9                            1/1     Running     0          17m
rook-ceph-operator-6768ff8467-7lbkd                         1/1     Running     0          29m
rook-ceph-osd-0-546ff4bb8b-4g9zp                            1/1     Running     0          14m
rook-ceph-osd-1-9c855657b-5st5z                             1/1     Running     0          14m
rook-ceph-osd-2-7874bdbd85-ldqqd                            1/1     Running     0          14m
rook-ceph-osd-prepare-set1-data-0cvh5z-z8mwn                0/1     Completed   0          15m
rook-ceph-osd-prepare-set1-data-1k765m-vmvd4                0/1     Completed   0          15m
rook-ceph-osd-prepare-set1-data-2gt4pb-9dbw7                0/1     Completed   0          15m

@subhamkrai
Copy link
Contributor Author

subhamkrai commented Aug 19, 2021

test result on PVC cluster when tolerations applied at storageClassDeviceSets.placement
cluster-on-pvc.yaml

storage:
    storageClassDeviceSets:
    ---
        placement:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: topology.kubernetes.io/zone
                operator: In
                values:
                - ap-southeast-1a
                - ap-southeast-1b
                - ap-southeast-1c
                - ap-southeast-1d
          tolerations:
          - key: "key1"
            operator: "Equal"
            value: "value1"
            effect: "NoSchedule"
          ---
        preparePlacement:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: topology.kubernetes.io/zone
                operator: In
                values:
                - ap-southeast-1a
                - ap-southeast-1b
                - ap-southeast-1c
                - ap-southeast-1d
          tolerations:
          - key: "key1"
            operator: "Equal"
            value: "value1"
            effect: "NoSchedule"
storage:
      ---
        placement:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
              nodeSelectorTerms:
              - matchExpressions:
                - key: topology.kubernetes.io/zone
                  operator: In
                  values:
                  - ap-southeast-1a
                  - ap-southeast-1b
                  - ap-southeast-1c
                  - ap-southeast-1d
          tolerations:
          - effect: NoSchedule
            key: key1
            operator: Equal
            value: value1
          ---
        preparePlacement:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
              nodeSelectorTerms:
              - matchExpressions:
                - key: topology.kubernetes.io/zone
                  operator: In
                  values:
                  - ap-southeast-1a
                  - ap-southeast-1b
                  - ap-southeast-1c
                  - ap-southeast-1d
         ---
          tolerations:
          - effect: NoSchedule
            key: key1
            operator: Equal
            value: value1

Copy link
Contributor

@sp98 sp98 left a comment

Choose a reason for hiding this comment

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

nit

pkg/apis/ceph.rook.io/v1/placement.go Outdated Show resolved Hide resolved
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

Can you also show the resulting OSD pod spec with a cluster with tolerations on both all and the storageClassDeviceSets.placement?

pkg/apis/ceph.rook.io/v1/placement.go Outdated Show resolved Hide resolved
pkg/apis/ceph.rook.io/v1/placement.go Outdated Show resolved Hide resolved
@subhamkrai
Copy link
Contributor Author

Can you also show the resulting OSD pod spec with a cluster with tolerations on both all and the storageClassDeviceSets.placement?

different tolerations at all and storageClassDeviceSets.placement or same toleration at both places will work?

@subhamkrai
Copy link
Contributor Author

Can you also show the resulting OSD pod spec with a cluster with tolerations on both all and the storageClassDeviceSets.placement?

different tolerations at all and storageClassDeviceSets.placement or same toleration at both places will work?

test result on PVC cluster with toleration at both all and storageDeviceClassSets.placement (applied same toleration at both places and 2 entries of toleration in osd-0 pod sec confirm it is taking toleration from both places)

yaml file

spec:
  placement:
    all:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: topology.kubernetes.io/zone
              operator: In
              values:
              - ap-southeast-1a
              - ap-southeast-1b
              - ap-southeast-1c
              - ap-southeast-1d
      tolerations:
      - key: "key1"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"
  storage:
    storageClassDeviceSets:
        placement:
          tolerations:
          - key: "key1"
            operator: "Equal"
            value: "value1"
            effect: "NoSchedule"

get pod rook-ceph-osd-0-84bf7697c8-c7526 -o yaml

tolerations:
  - effect: NoSchedule
    key: key1
    operator: Equal
    value: value1
  - effect: NoSchedule
    key: key1
    operator: Equal
    value: value1
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 5
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  topologySpreadConstraints:
  - labelSelector:
      matchExpressions:
      - key: app
        operator: In
        values:
        - rook-ceph-osd

@subhamkrai
Copy link
Contributor Author

I'll test for non PVC cluster tomorrow again with the latest minor changes

@travisn
Copy link
Member

travisn commented Aug 19, 2021

Can you also show the resulting OSD pod spec with a cluster with tolerations on both all and the storageClassDeviceSets.placement?

different tolerations at all and storageClassDeviceSets.placement or same toleration at both places will work?

It doesn't hurt to have the same toleration twice, but the scenario is that different tolerations would be specified at the two levels. If you test a different toleration it will also confirm that the same toleration isn't just being duplicated.

@subhamkrai
Copy link
Contributor Author

Can you also show the resulting OSD pod spec with a cluster with tolerations on both all and the storageClassDeviceSets.placement?

different tolerations at all and storageClassDeviceSets.placement or same toleration at both places will work?

It doesn't hurt to have the same toleration twice, but the scenario is that different tolerations would be specified at the two levels. If you test a different toleration it will also confirm that the same toleration isn't just being duplicated.

spec:
  placement:
    all:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: topology.kubernetes.io/zone
              operator: In
              values:
              - ap-southeast-1a
              - ap-southeast-1b
              - ap-southeast-1c
              - ap-southeast-1d
      tolerations:
      - key: "key1"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"
  storage:
    storageClassDeviceSets:
        placement:
          tolerations:
          - key: "key2"
            operator: "Equal"
            value: "value1"
            effect: "NoSchedule"

get pod rook-ceph-osd-0-7785bb9478-jxsx7 -o yaml

tolerations:
  - effect: NoSchedule
    key: key2
    operator: Equal
    value: value1
  - effect: NoSchedule
    key: key1
    operator: Equal
    value: value1
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 5
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300

this validate the changes, in all it has -key1 and in storageDeviceClassSets.placement key is -key2

@subhamkrai subhamkrai force-pushed the merge-tolerations branch 2 times, most recently from b42e697 to 5a2f4b7 Compare August 20, 2021 08:59
Comment on lines 158 to 159
if with.NodeAffinity != nil {
ret.NodeAffinity = with.NodeAffinity
Copy link
Contributor Author

Choose a reason for hiding this comment

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

still, this two line of code is not perfect or have some issue. It is overriding node affinity when discovering nodes, but I don't think it will cause a problem for now

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a separate method for MergeOsd()? Seems like merging the tolerations should always be done in the Merge() method so it would apply to all daemons, then no need for this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, merging toleration in merge() method will be better, and also it will be applied to other pods like OSD, MGR, MON

@subhamkrai
Copy link
Contributor Author

test result on non-PVC cluster
cluster.yaml

spec:
  placement:
    all:
      tolerations:
      - key: "key1"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"
    osd:
      tolerations:
      - key: "key2"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"
    prepareosd:
      tolerations:
      - key: "key2"
        operator: "Equal"
        value: "value1"
        effect: "NoSchedule"

get pod rook-ceph-osd-0-7869bb94f4-vfkq9 -o yaml

tolerations:
  - effect: NoSchedule
    key: key2
    operator: Equal
    value: value1
  - effect: NoSchedule
    key: key1
    operator: Equal
    value: value1
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300

Comment on lines 158 to 159
if with.NodeAffinity != nil {
ret.NodeAffinity = with.NodeAffinity
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a separate method for MergeOsd()? Seems like merging the tolerations should always be done in the Merge() method so it would apply to all daemons, then no need for this method.

@subhamkrai subhamkrai force-pushed the merge-tolerations branch 2 times, most recently from f1909e6 to 61d2e7f Compare August 25, 2021 05:58
earlier, `ApplyToPodSpec()` was only taking one toleration and ignoring
tolerations from `placement.ALL()`.

this commit merge toleration for Mgr,Mon,Osd pod
example, for osd it will merge
spec.placement.all and
storageDeviceClassSets.Placement(in case of pvc) or
spec.placement.osd(in case of non-pvc's).

Signed-off-by: subhamkrai <srai@redhat.com>
@travisn travisn merged commit 42717d2 into rook:master Aug 26, 2021
@subhamkrai subhamkrai deleted the merge-tolerations branch August 26, 2021 15:17
travisn added a commit that referenced this pull request Aug 26, 2021
ceph: merge toleration for osd/prepareOSD pod if specified both places (backport #8566)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ceph main ceph tag
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants