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

[BUG] cluster can not be created when ResourceQuota set #678

Closed
wangshulei098 opened this issue Dec 6, 2023 · 0 comments
Closed

[BUG] cluster can not be created when ResourceQuota set #678

wangshulei098 opened this issue Dec 6, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@wangshulei098
Copy link

wangshulei098 commented Dec 6, 2023

Hi friends
When I create a cluster under a namespace with ResourceQuota set, I found that some resources cannot be set with request and limit, resulting in creation failure.
ResourceQuota yaml:

kind: ResourceQuota
metadata:
  name: project-middleware-3968
  namespace: project-middleware-3968
spec:
  hard:
    limits.cpu: "10"
    limits.memory: 10Gi
    requests.storage: 10Gi
status:
  hard:
    limits.cpu: "10"
    limits.memory: 10Gi
    requests.storage: 10Gi
  used:
    limits.cpu: "2"
    limits.memory: 2Gi
    requests.storage: 7Gi

opensearch statefulset describe like:

Events:
  Type     Reason            Age                             From                    Message
  ----     ------            ----                            ----                    -------
  Normal   SuccessfulCreate  <invalid>                       statefulset-controller  create Claim data-opensearch-sample-masters-0 Pod opensearch-sample-masters-0 in StatefulSet opensearch-sample-masters success
  Warning  FailedCreate      <invalid> (x14 over <invalid>)  statefulset-controller  create Pod opensearch-sample-masters-0 in StatefulSet opensearch-sample-masters failed error: pods "opensearch-sample-masters-0" is forbidden: failed quota: project-middleware-3968: must specify limits.cpu,limits.memory

I reviewed the source code and found that the init container named "init" can inherit the resource settings from Spec.InitHelper.Resources. However, the init containers named "init-sysctl" and "keystore" cannot inherit the resource settings.
In addition to that, I also found that all generated jobs, such as SnapshotRepoconfigUpdateJob and SecurityconfigUpdateJob, cannot have resource settings applied to them.

Below are my modifications:

  1. All init containers can inherit the settings from Spec.InitHelper.Resources.
  2. Add a Job field to Spec and configure all jobs with settings such as Resource, NodeSelector, Label, etc. as shown below:
type ClusterSpec struct {
  // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
  // Important: Run "make" to regenerate code after modifying this file
  General    GeneralConfig    `json:"general,omitempty"`
  ConfMgmt   ConfMgmt         `json:"confMgmt,omitempty"`
  Bootstrap  BootstrapConfig  `json:"bootstrap,omitempty"`
  Dashboards DashboardsConfig `json:"dashboards,omitempty"`
  Security   *Security        `json:"security,omitempty"`
  NodePools  []NodePool       `json:"nodePools"`
  InitHelper InitHelperConfig `json:"initHelper,omitempty"`
  Job        JobConfig        `json:"job,omitempty"`
}
type JobConfig struct {
  Resources    corev1.ResourceRequirements `json:"resources,omitempty"`
  NodeSelector map[string]string           `json:"nodeSelector,omitempty"`
  Affinity     *corev1.Affinity            `json:"affinity,omitempty"`
  Labels       map[string]string           `json:"labels,omitempty"`
  Annotations  map[string]string           `json:"annotations,omitempty"`
}
@wangshulei098 wangshulei098 added the bug Something isn't working label Dec 6, 2023
wangshulei098 pushed a commit to wangshulei098/opensearch-k8s-operator that referenced this issue Dec 7, 2023
…ntainer inherit the settings from Spec.InitHelper.Resource

opensearchcluster spec add Job  resource config  and all initcontainer inherit the settings from Spec.InitHelper.Resource

Signed-off-by: wangshulei098 <[email protected]>

opensearch-project#678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant