Skip to content

Commit

Permalink
Merge pull request #8213 from olemarkus/automated-cherry-pick-of-#783…
Browse files Browse the repository at this point in the history
…2-origin-release-1.15

Automated cherry pick of #7832: cilium: don't try to mount sys/fs/bpf if already mounted
  • Loading branch information
k8s-ci-robot committed Jan 3, 2020
2 parents eb50e5e + a827b64 commit b6b2365
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 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,8 +72,21 @@ func (b *NetworkBuilder) Build(c *fi.ModelBuilderContext) error {
}

if networking.Cilium != nil {
var unit *string
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 @@ -85,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 b6b2365

Please sign in to comment.