Skip to content

Commit

Permalink
cilium: don't try to mount sys/fs/bpf if already mounted
Browse files Browse the repository at this point in the history
systemd v238 already includes the mount, and the unit file fails.  We
test for the existence of the mount, rather than testing systemd
versions directly.
  • Loading branch information
justinsb committed Dec 28, 2019
1 parent c1f5c7a commit 4d51485
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions nodeup/pkg/model/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package model

import (
"fmt"
"os"
"path/filepath"

"k8s.io/kops/upup/pkg/fi"
Expand Down Expand Up @@ -71,7 +72,21 @@ func (b *NetworkBuilder) Build(c *fi.ModelBuilderContext) error {
}

if networking.Cilium != nil {
unit := s(`
// systemd v238 includes the bpffs mount by default; and gives an error "has a bad unit file setting" if we try to mount it again (see mount_point_is_api)
var alreadyMounted bool
_, err := os.Stat("/sys/fs/bpf")
if err != nil {
if os.IsNotExist(err) {
alreadyMounted = false
} else {
return fmt.Errorf("error checking for /sys/fs/bpf: %v", err)
}
} else {
alreadyMounted = true
}

if !alreadyMounted {
unit := s(`
[Unit]
Description=Cilium BPF mounts
Documentation=http://docs.cilium.io/
Expand All @@ -84,15 +99,16 @@ Where=/sys/fs/bpf
Type=bpf
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
`)

service := &nodetasks.Service{
Name: "sys-fs-bpf.mount",
Definition: unit,
service := &nodetasks.Service{
Name: "sys-fs-bpf.mount",
Definition: unit,
}
service.InitDefaults()
c.AddTask(service)
}
service.InitDefaults()
c.AddTask(service)
}

return nil
Expand Down

0 comments on commit 4d51485

Please sign in to comment.