-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into k0s-1-29
- Loading branch information
Showing
20 changed files
with
227 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package configutils | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/replicatedhq/embedded-cluster/pkg/defaults" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfigureSysctl(t *testing.T) { | ||
basedir, err := os.MkdirTemp("", "embedded-cluster-test-base-dir") | ||
assert.NoError(t, err) | ||
defer os.RemoveAll(basedir) | ||
|
||
orig := sysctlConfigPath | ||
defer func() { | ||
sysctlConfigPath = orig | ||
}() | ||
|
||
provider := defaults.NewProvider(basedir) | ||
|
||
// happy path. | ||
dstdir, err := os.MkdirTemp("", "embedded-cluster-test") | ||
assert.NoError(t, err) | ||
defer os.RemoveAll(dstdir) | ||
|
||
sysctlConfigPath = filepath.Join(dstdir, "sysctl.conf") | ||
err = ConfigureSysctl(provider) | ||
assert.NoError(t, err) | ||
|
||
// check that the file exists. | ||
_, err = os.Stat(sysctlConfigPath) | ||
assert.NoError(t, err) | ||
|
||
// now use a non-existing directory. | ||
sysctlConfigPath = filepath.Join(dstdir, "non-existing-dir", "sysctl.conf") | ||
// we do not expect an error here. | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package goods | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMaterializer_SysctlConfig(t *testing.T) { | ||
m := NewMaterializer(nil) | ||
|
||
// happy path. | ||
dstdir, err := os.MkdirTemp("", "embedded-cluster-test") | ||
assert.NoError(t, err) | ||
defer os.RemoveAll(dstdir) | ||
|
||
dstpath := filepath.Join(dstdir, "sysctl.conf") | ||
err = m.SysctlConfig(dstpath) | ||
assert.NoError(t, err) | ||
|
||
expected, err := os.ReadFile(dstpath) | ||
assert.NoError(t, err) | ||
|
||
content, err := staticfs.ReadFile("static/99-embedded-cluster.conf") | ||
assert.NoError(t, err) | ||
assert.Equal(t, string(expected), string(content)) | ||
|
||
// write to a non-existent directory. | ||
dstpath = filepath.Join(dstdir, "dir-does-not-exist", "sysctl.conf") | ||
err = m.SysctlConfig(dstpath) | ||
assert.Contains(t, err.Error(), "no such file or directory") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# this entry enables ip forwarding. this feature is necessary as embedded | ||
# cluster creates virtual network interfaces and need the traffic among them to | ||
# be forwarded. | ||
net.ipv4.ip_forward = 1 | ||
|
||
# arp filter and ignore need to be disabled otherwise we can't have arp | ||
# resolving across the calico network interfaces. | ||
net.ipv4.conf.default.arp_filter = 0 | ||
net.ipv4.conf.default.arp_ignore = 0 | ||
net.ipv4.conf.all.arp_filter = 0 | ||
net.ipv4.conf.all.arp_ignore = 0 |
Oops, something went wrong.