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

Error in /etc/systemd/system/kubelet.service.d (put_read) Is a directory #548

Closed
cofyc opened this issue Mar 9, 2018 · 5 comments
Closed

Comments

@cofyc
Copy link

cofyc commented Mar 9, 2018

hi,

I try to use augtool to modify /etc/systemd/system/kubelet.service.d/10-kubeadm.conf, but found an error. Here is what I did

augtool> set /files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[last()+1]/KUBELET_EXTRA_ARGS "--feature-gates=PersistentLocalVolumes=true"
augtool> print /files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[1]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[1]/KUBELET_CGROUP_DRIVER = "--cgroup-driver=cgroupfs"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[2]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[2]/KUBELET_KUBECONFIG_ARGS = "--kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[3]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[3]/KUBELET_SYSTEM_PODS_ARGS = "--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[4]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[4]/KUBELET_NETWORK_ARGS = "--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[5]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[5]/KUBELET_DNS_ARGS = "--cluster-dns=172.30.0.10 --cluster-domain=cluster.local"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[6]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[6]/KUBELET_AUTHZ_ARGS = "--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[7]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[7]/KUBELET_POD_INFRA_ARGS = "--pod-infra-container-image=index-dev.qiniu.io/kelibrary/pause-amd64:3.0"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[8]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[8]/KUBELET_LOG_LEVEL = "-v=7"
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[9]
/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf/Service/Environment[9]/KUBELET_EXTRA_ARGS = "--feature-gates=PersistentLocalVolumes=true"
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool> errors
...
Error in /etc/systemd/system/kubelet.service.d (put_read)
  Is a directory
...

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf cannot be updated.

@raphink
Copy link
Member

raphink commented Mar 9, 2018

Hello,

Can you show your file before the change please?

@cofyc
Copy link
Author

cofyc commented Mar 9, 2018

@raphink

hi, /etc/systemd/system/kubelet.service.d/10-kubeadm.conf is systemd configure file for kubelet.service. After installing kubelet, I need to change configuration in this file to configure kubelet. Previously I modify this file manually, I want to automate this process. It's ok to parse this file, and print out the tree, but I cannot save my changes.

# cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=http://kubernetes.io/docs/

[Service]
Restart=always
StartLimitInterval=0
RestartSec=10
Environment="KUBELET_CGROUP_DRIVER=--cgroup-driver=cgroupfs"
Environment="KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true"
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
Environment="KUBELET_DNS_ARGS=--cluster-dns=172.30.0.10 --cluster-domain=cluster.local"
Environment="KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt"
Environment="KUBELET_POD_INFRA_ARGS=--pod-infra-container-image=index-dev.qiniu.io/kelibrary/pause-amd64:3.0"
Environment="KUBELET_LOG_LEVEL=-v=7"
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_EXTRA_ARGS $KUBELET_POD_INFRA_ARGS $KUBELET_NODE_IP_ARGS $KUBELET_CGROUPS_DRIVER $KUBELET_LOG_LEVEL

[Install]
WantedBy=multi-user.target

Environment:

# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
# uname -a
Linux <hostname> 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
# dpkg-query -l | grep augeas
ii  augeas-lenses                      1.4.0-0ubuntu1                     all          Set of lenses needed by libaugeas0 to parse config files
ii  augeas-tools                       1.4.0-0ubuntu1                     amd64        Augeas command line tools
ii  libaugeas0                         1.4.0-0ubuntu1                     amd64        Augeas configuration editing library and API

@lutter
Copy link
Member

lutter commented Mar 12, 2018

Augeas gets confused about file system paths here, and thinks /etc/systemd/system/kubelet.service.d is the file it should write. The culprit are these two lines

One way to work around this would be to change the definition of the filter to exclude *.d entries, i.e. change it to something like

let filter = incl "/lib/systemd/system/*"
           . incl "/lib/systemd/system/*/*"
           . incl "/etc/systemd/system/*"
           . incl "/etc/systemd/system/*/*"
           . incl "/etc/systemd/logind.conf"
           . incl "/etc/sysconfig/*.systemd"
           . excl "/lib/systemd/system/*.d"
           . excl "/etc/systemd/system/*.d"
           . Util.stdexcl

If that works, we'd need to figure out what other patterns usually denote directories and exclude them too (seems "*.wants" falls into the same category) and update the lens.

lutter added a commit to lutter/augeas that referenced this issue Mar 13, 2018
We used to get confused when writing back systemd changes and tried to
write a whole *.d or *.wants directory as one file, which would fail. By
explicitly not matching them, we make sure that we write to the files in
those directories, not the directories themselves.

Fixes hercules-team#548
@lutter
Copy link
Member

lutter commented Mar 13, 2018

I've just put up a PR that seems to fix this issue in my testing.

lutter added a commit to lutter/augeas that referenced this issue Mar 13, 2018
We used to get confused when writing back systemd changes and tried to
write a whole *.d or *.wants directory as one file, which would fail. By
explicitly not matching them, we make sure that we write to the files in
those directories, not the directories themselves.

Fixes hercules-team#548
@cofyc
Copy link
Author

cofyc commented Mar 14, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants