Skip to content

Commit

Permalink
Merge pull request #28 from spidernet-io/bug
Browse files Browse the repository at this point in the history
fix failed to set rp_filter
  • Loading branch information
weizhoublue authored Sep 8, 2022
2 parents 20d696f + c850f14 commit 5a0baab
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
- reopened
push:
branch:
tags:
- main
workflow_call:
inputs:
Expand Down Expand Up @@ -86,8 +85,9 @@ jobs:
with:
context: ./
push: ${{ steps.tag.outputs.push }}
tags: ghcr.io/${{ github.repository }}/meta-plugins:${{ steps.tag.outputs.version }}-${{ matrix.go_arch }}
tags: ghcr.io/${{ github.repository }}/meta-plugins:${{ steps.tag.outputs.version }}
file: ./images/Dockerfile.${{ matrix.go_arch }}
github-token: ${{ secrets.WELAN_PAT }}
platforms: linux/${{ matrix.go_arch }}
build-args: |
GIT_COMMIT_VERSION=${{ steps.arg.outputs.commitver }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- v*
branches:
- v*
- main
workflow_dispatch:
inputs:
ref:
Expand Down
6 changes: 3 additions & 3 deletions charts/meta-plugins/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: meta-plugins
description: Veth works with macvlan cni to solve some communication problems when macvlan is used as CNI.
description: meta-plugins works with macvlan cni to solve some communication problems when macvlan is used as CNI.

# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
Expand All @@ -10,13 +10,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v0.1.5
version: v0.1.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.1.5"
appVersion: "v0.1.6"

maintainers:
- name: Spider-Guys
Expand Down
2 changes: 1 addition & 1 deletion charts/meta-plugins/templates/daemonSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
effect: NoSchedule
containers:
- name: kube-{{ .Chart.Name }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}-amd64
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
env:
- name: KUBERNETES_NODE_NAME
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func SysctlRPFilter(netns ns.NetNS, rp *types.RPFilter) error {
var err error
if rp.Enable != nil && *rp.Enable {
if err = setRPFilter(rp.Value); err != nil {
return err
return fmt.Errorf("failed to set rp_filter for host : %v", err)
}
}
// set pod rp_filter
err = netns.Do(func(_ ns.NetNS) error {
if err := setRPFilter(rp.Value); err != nil {
return err
return fmt.Errorf("failed to set rp_filter for pod : %v", err)
}
return nil
})
Expand All @@ -139,7 +139,7 @@ func setRPFilter(v *int32) error {
}
dirs, err := os.ReadDir(sysctlConfPath)
if err != nil {
return fmt.Errorf("[veth]failed to set rp_filter: %v", err)
return err
}
for _, dir := range dirs {
name := fmt.Sprintf("/net/ipv4/conf/%s/rp_filter", dir.Name())
Expand All @@ -148,7 +148,7 @@ func setRPFilter(v *int32) error {
continue
}
if value == "1" {
if _, e := sysctl.Sysctl(name, fmt.Sprintf("%d", v)); e != nil {
if _, e := sysctl.Sysctl(name, fmt.Sprintf("%d", *v)); e != nil {
return e
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func cmdAdd(args *skel.CmdArgs) error {

// 4. setup sysctl rp_filter
if err = utils.SysctlRPFilter(netns, conf.RPFilter); err != nil {
return fmt.Errorf("%s failed to set rp_filter : %v", logPrefix, err)
return fmt.Errorf("%s : %v", logPrefix, err)
}
fmt.Fprintf(os.Stderr, "%s succeeded to set rp_filter \n", logPrefix)

Expand Down

0 comments on commit 5a0baab

Please sign in to comment.