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

Fixing subpath custom conf #627

Merged
merged 2 commits into from
Oct 12, 2022
Merged

Fixing subpath custom conf #627

merged 2 commits into from
Oct 12, 2022

Conversation

CharlyF
Copy link
Contributor

@CharlyF CharlyF commented Oct 12, 2022

What does this PR do?

Without this fix, converting a v1 to v2 when using a custom conf file will block the deployment of the cluster agent with the following message:

  Warning  Failed     25m (x4 over 26m)    kubelet            Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/lib/kubelet/pods/ed3b360b-8f77-40bf-90b5-88aff9460358/volumes/kubernetes.io~configmap/custom-datadog-yaml" to rootfs at "/etc/datadog-agent/datadog.yaml": mount /var/lib/kubelet/pods/ed3b360b-8f77-40bf-90b5-88aff9460358/volumes/kubernetes.io~configmap/custom-datadog-yaml:/etc/datadog-agent/datadog.yaml (via /proc/self/fd/6), flags: 0x5001: not a directory: unknown

This is because the conversion did not specify the subpath. This can be verified by submitting a conversion to the webhook:

[root@datadog-operator-7bdc4ccc89-khqz5 /]# curl --cacert /tmp/k8s-webhook-server/serving-certs/ca.pem https://datadog-operator-webhook-service.datadog-agent.svc.muk.cluster.local:443/convert -X POST -d 

using the following payload:

{"request":{"uid":"123", "desiredAPIVersion":"datadoghq.com/v2alpha1", "objects":[{ "apiVersion": "datadoghq.com/v1alpha1", "kind": "DatadogAgent", "spec": { "agent": { "customConfig": { "configMap": { "fileKey": "datadog.yaml", "name": "datadog-agent-config-abc" } }, "systemProbe": {"customConfig": { "configMap": { "fileKey": "system-probe.yaml", "name": "datadog-agent-system-probe-config-abc" } } } }, "clusterAgent": { "config": {"confd": { "configMapName": "cluster-agent-confd-0.1.2", "items": [ { "key": "helm-yaml", "path": "./helm.yaml" }, { "key": "kubernetes-apiserver-yaml", "path": "./kubernetes_apiserver.yaml" }, { "key": "orchestrator-yaml-default", "path": "./orchestrator.yaml.default" } ] } }, "customConfig": { "configMap": { "fileKey": "datadog-cluster.yaml", "name": "datadog-cluster-agent-abc" } } } } }]}}

it yields:

{"response":{"uid":"123","convertedObjects":[{"kind":"DatadogAgent","apiVersion":"datadoghq.com/v2alpha1","metadata":{"creationTimestamp":null},"spec":{"features":{"npm":{}},"override":{"clusterAgent":{"customConfigurations":{"datadog.yaml":{"configMap":{"name":"datadog-cluster-agent-abc","items":[{"key":"datadog-cluster.yaml","path":"datadog-cluster.yaml"}]}}},"extraConfd":{"configMap":{"name":"cluster-agent-confd-0.1.2","items":[{"key":"helm-yaml","path":"./helm.yaml"},{"key":"kubernetes-apiserver-yaml","path":"./kubernetes_apiserver.yaml"},{"key":"orchestrator-yaml-default","path":"./orchestrator.yaml.default"}]}}},"nodeAgent":{"customConfigurations":{"datadog.yaml":{"configMap":{"name":"datadog-agent-config-abc","items":[{"key":"datadog.yaml","path":"datadog.yaml"}]}},"system-probe.yaml":{"configMap":{"name":"datadog-agent-system-probe-config-abc","items":[{"key":"system-probe.yaml","path":"system-probe.yaml"}]}}}}}},"status":{"conditions":null}}],"result":{"metadata":{},"status":"Success"}}}

with the fix we have the "path":"datadog.yaml", as well as "path":"datadog-cluster.yaml" etc.

Motivation

Unblock the conversion/deployment of a custom use case.

Describe your test plan

you can use the above payload and endpoint to convert before and after the fix to confirm that the new fields are added.

@CharlyF CharlyF requested review from a team as code owners October 12, 2022 18:49
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: bug, enhancement, refactoring, documentation, tooling

@CharlyF CharlyF added the bug Something isn't working label Oct 12, 2022
@CharlyF CharlyF added this to the v1.0.0 milestone Oct 12, 2022
@CharlyF CharlyF merged commit 2b677df into main Oct 12, 2022
@CharlyF CharlyF deleted the fixing-subpath-custom-conf branch October 12, 2022 19:09
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
Development

Successfully merging this pull request may close these issues.

3 participants