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] config constraint xml formatter error #5817

Closed
kissycn opened this issue Nov 10, 2023 · 9 comments · Fixed by #5853
Closed

[BUG] config constraint xml formatter error #5817

kissycn opened this issue Nov 10, 2023 · 9 comments · Fixed by #5853
Assignees
Labels
bug kind/bug Something isn't working Stale
Milestone

Comments

@kissycn
Copy link
Contributor

kissycn commented Nov 10, 2023

Describe the bug
When using config constraint, The formatter is xml, the expected results are not obtained after modifying the configuration file.

To Reproduce
Steps to reproduce the behavior:

Kubernetes: v1.27.4+k3s1
KubeBlocks: 0.7.0
kbcli: 0.7.0

clusterdefinition.yaml

apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
  name: hbase
  labels:
    {{- include "hbase.labels" . | nindent 4 }}
spec:
  type: hbase
  componentDefs:
    - name: hbase-master
      workloadType: Stateful
      characterType: hbase-master
      statefulSpec:
        updateStrategy: BestEffortParallel
      configSpecs:
        - name: hbase-config
          namespace: {{ .Release.Namespace }}
          templateRef: {{ include "hbase.name" . }}-config-template
          constraintRef: {{ include "hbase.name" . }}-config-constraints
          volumeName: hbase-config
          defaultMode: 0755
 ...
            volumeMounts:
              - name: hbase-config
                mountPath: /hbase/conf

config-tpl-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "hbase.name" . }}-config-template
  labels:
    {{- include "hbase.labels" . | nindent 4 }}
data:
  hbase-site.xml: |-
    {{- .Files.Get "config/hbase-config.tpl" | nindent 4 }}

configconstraint.yaml

{{- $cc := .Files.Get "config/config-effect-scope.yaml" | fromYaml }}
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ConfigConstraint
metadata:
  name: {{ include "hbase.name" . }}-config-constraints
  labels:
    {{- include "hbase.labels" . | nindent 4 }}
spec:
  # hbase configuration file format
  formatterConfig:
    format: xml

  # define parameter validation rules
  cfgSchemaTopLevelName: HBaseParameter

  ## define immutable parameter list
  {{- if hasKey $cc "immutableParameters" }}
  immutableParameters:
    {{- $params := get $cc "immutableParameters" }}
    {{- range $params }}
    - {{ . }}
    {{- end }}
  {{- end}}

  # ConfigurationSchema that impose restrictions on engine parameter's rule
  configurationSchema:
    cue: |-
      {{- .Files.Get "config/hbase-config-constraint.cue" | nindent 6 }}

hbase-config.tpl

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://hdfs-k8s:8020/hbase</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>zk-zookeeper-0.zk-zookeeper-headless.default.svc.cluster.local,zk-zookeeper-0.zk-zookeeper-headless.default.svc.cluster.local,zk-zookeeper-0.zk-zookeeper-headless.default.svc.cluster.local</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.unsafe.stream.capability.enforce</name>
        <value>false</value>
    </property>
    <property>
        <name>zookeeper.session.timeout</name>
        <value>30000</value>
    </property>
    <property>
        <name>hbase.regionserver.handler.count</name>
        <value>90</value>
    </property>
    <property>
        <name>hbase.client.write.buffer</name>
        <value>20971520</value>
    </property>
</configuration>

hbase-config-constraint.cue

#HBaseParameter: {
    // ZooKeeper session timeout in milliseconds. 
    "zookeeper.session.timeout": int | *90000
}
  1. create
helm install  hbase ./hbase
kbcli cluster create hbase --cluster-definition hbase
image
  1. edit params
 kbcli cluster edit-config hbase
image
  1. edit logs
image

4.edit result
image

Expected behavior
expect

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
...
    <property>
        <name>zookeeper.session.timeout</name>
        <value>30001</value>
    </property>
...
</configuration>

actual

 1560  kbcli kubeblocks status
<configuration><property/></configuration>
@kissycn kissycn added the kind/bug Something isn't working label Nov 10, 2023
@sophon-zt sophon-zt self-assigned this Nov 10, 2023
@sophon-zt
Copy link
Contributor

This configuration file has the slice type, the current configuration does not support slice type patches, it is recommended to reconfigure by updating instead of patch.

The only difference between update and patch is whether there is configconstraint, so delete the constraintRef field in configSpec.

image

@kissycn
Copy link
Contributor Author

kissycn commented Nov 13, 2023

@sophon-zt
Thank you for your reply!
I modify the configuration file through the kbcli edit-config command, so the update request is initiated by kbcli. Other types of configurations can initiate path requests normally through kbcli, and xml is updae, so kbcli's processing of xml is not as expected.
I tried it the way you did. If I delete constraintRef in configSpecs, the constraints and modifications to the parameters will not be executed. This is not what I want.

@kissycn
Copy link
Contributor Author

kissycn commented Nov 13, 2023

The same problem also exists in OpsRequest:
POST:http://0.0.0.0:8091/apis/apps.kubeblocks.io/v1alpha1/namespaces/default/opsrequests

{
   "apiVersion": "apps.kubeblocks.io/v1alpha1",
   "kind": "OpsRequest",
   "metadata": {
      "generateName": "hbase-reconfiguring-11",
      "namespace": "default"
   },
   "spec": {
      "clusterRef": "hbase",
      "reconfigure": {
         "componentName": "hbase-master",
         "configurations": [
            {
               "keys": [
                  {
                     "key": "hbase-site.xml",
                     "parameters": [
                        {
                           "key": "zookeeper.session.timeout",
                           "value": "30001"
                        }
                     ]
                  }
               ],
               "name": "hbase-config"
            }
         ]
      },
      "ttlSecondsAfterSucceed": 0,
      "type": "Reconfiguring"
   }
}
kubectl describe opsrequests hbase-reconfiguring-114m47z
...
Events:
  Type     Reason                        Age                    From                    Message
  ----     ------                        ----                   ----                    -------
  Normal   OpsRequestProgressingStarted  5m59s                  ops-request-controller  Start to process the OpsRequest: hbase-reconfiguring-114m47z in Cluster: hbase
  Normal   ValidateOpsRequestPassed      5m59s (x2 over 5m59s)  ops-request-controller  OpsRequest: hbase-reconfiguring-114m47z is validated
  Normal   ReconfigureStarted            5m59s (x2 over 5m59s)  ops-request-controller  Start to reconfigure in Cluster: hbase, Component: hbase-master
  Warning  OpsRequestFailed              5m59s                  ops-request-controller  fail with message: Path does not exist
  Warning  DoActionFailed                5m59s                  ops-request-controller  Failed to process the operation of OpsRequest: fail with message: Path does not exist

@sophon-zt
Copy link
Contributor

sophon-zt commented Nov 13, 2023

opsrequest can't solve this problem, so update the entire file.

remove cd.spec.componentDefs[@name=hbase-master].configSpecs[0].constraintRef
and using kbcli cluster edit-config hbase --replace

apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
  name: hbase
  labels:
    {{- include "hbase.labels" . | nindent 4 }}
spec:
  type: hbase
  componentDefs:
    - name: hbase-master
      workloadType: Stateful
      characterType: hbase-master
      statefulSpec:
        updateStrategy: BestEffortParallel
      configSpecs:
        - name: hbase-config
          namespace: {{ .Release.Namespace }}
          templateRef: {{ include "hbase.name" . }}-config-template
          ## constraintRef: {{ include "hbase.name" . }}-config-constraints 
          volumeName: hbase-config
          defaultMode: 0755

@sophon-zt
Copy link
Contributor

Because the schema is not strictly defined, it is currently not possible to support list updates like the k8s API.

@sophon-zt
Copy link
Contributor

OK, we will support the update of array later.

@sophon-zt Thank you for your reply! I modify the configuration file through the kbcli edit-config command, so the update request is initiated by kbcli. Other types of configurations can initiate path requests normally through kbcli, and xml is updae, so kbcli's processing of xml is not as expected. I tried it the way you did. If I delete constraintRef in configSpecs, the constraints and modifications to the parameters will not be executed. This is not what I want.

@sophon-zt
Copy link
Contributor

If there is enough time, we will support this feature in version 0.8, otherwise it may be delayed to 0.9.

@kissycn
Copy link
Contributor Author

kissycn commented Nov 14, 2023

opsrequest can't solve this problem, so update the entire file.

remove cd.spec.componentDefs[@name=hbase-master].configSpecs[0].constraintRef and using kbcli cluster edit-config hbase --replace

apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
  name: hbase
  labels:
    {{- include "hbase.labels" . | nindent 4 }}
spec:
  type: hbase
  componentDefs:
    - name: hbase-master
      workloadType: Stateful
      characterType: hbase-master
      statefulSpec:
        updateStrategy: BestEffortParallel
      configSpecs:
        - name: hbase-config
          namespace: {{ .Release.Namespace }}
          templateRef: {{ include "hbase.name" . }}-config-template
          ## constraintRef: {{ include "hbase.name" . }}-config-constraints 
          volumeName: hbase-config
          defaultMode: 0755

remove cd.spec.componentDefs[@name=hbase-master].configSpecs[0].constraintRef

kbcli cluster edit-config hbase
or
kbcli cluster edit-config hbase --component hbase-master

command error:

error: cannot find valid config templates for component[name=hbase-master] in the cluster[name=hbase]

@sophon-zt sophon-zt linked a pull request Dec 14, 2023 that will close this issue
Copy link

This issue has been marked as stale because it has been open for 30 days with no activity

@github-actions github-actions bot added the Stale label Dec 18, 2023
@github-actions github-actions bot added this to the Release 0.9.0 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug kind/bug Something isn't working Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants