Skip to content

Commit

Permalink
Add mechanism for adding tolerations on provider server
Browse files Browse the repository at this point in the history
Signed-off-by: Nitin Goyal <[email protected]>
  • Loading branch information
iamniting committed Mar 15, 2024
1 parent 094df0d commit 719e470
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/defaults/placements.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

var (
ProviderServerKey = "provider-server"

// osdLabelSelector is the key in OSD pod. Used
// as a label selector for topology spread constraints.
osdLabelSelector = "rook-ceph-osd"
Expand Down Expand Up @@ -126,6 +128,12 @@ var (
getOcsToleration(),
},
},

ProviderServerKey: {
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
},
}
)

Expand Down
6 changes: 6 additions & 0 deletions controllers/storagecluster/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ func getPlacement(sc *ocsv1.StorageCluster, component string) rookCephv1.Placeme
return placement
}

// if provider-server placements are found in the storagecluster spec append the default ocs tolerations to it
if ok && component == defaults.ProviderServerKey {
placement.Tolerations = append(placement.Tolerations, defaults.DaemonPlacements[component].Tolerations...)
return placement
}

// If no placement is specified for the given component and the
// StorageCluster has no label selector, set the default node
// affinity.
Expand Down
2 changes: 2 additions & 0 deletions controllers/storagecluster/provider_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/defaults"
"github.com/red-hat-storage/ocs-operator/v4/controllers/util"
"github.com/red-hat-storage/ocs-operator/v4/services/provider/server"
)
Expand Down Expand Up @@ -379,6 +380,7 @@ func GetProviderAPIServerDeployment(instance *ocsv1.StorageCluster) *appsv1.Depl
},
},
},
Tolerations: getPlacement(instance, defaults.ProviderServerKey).Tolerations,
ServiceAccountName: ocsProviderServerName,
},
},
Expand Down
2 changes: 2 additions & 0 deletions controllers/storagecluster/provider_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"

ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/defaults"
"github.com/red-hat-storage/ocs-operator/v4/controllers/util"
"github.com/red-hat-storage/ocs-operator/v4/services/provider/server"
)
Expand Down Expand Up @@ -393,6 +394,7 @@ func GetProviderAPIServerDeploymentForTest(instance *ocsv1.StorageCluster) *apps
},
},
ServiceAccountName: ocsProviderServerName,
Tolerations: getPlacement(instance, defaults.ProviderServerKey).Tolerations,
},
},
},
Expand Down

0 comments on commit 719e470

Please sign in to comment.