Skip to content

Commit 760c3be

Browse files
authored
Revert "feat(troubleshoot): add filesystem latency check" (#1024)
Revert "feat(troubleshoot): add filesystem latency check (#1018)" This reverts commit 7f7de2b.
1 parent cfa55c1 commit 760c3be

File tree

8 files changed

+95
-253
lines changed

8 files changed

+95
-253
lines changed

Makefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ LD_FLAGS = \
3636
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleMigrationsImageOverride=$(ADMIN_CONSOLE_MIGRATIONS_IMAGE_OVERRIDE) \
3737
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleKurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE) \
3838
-X github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator.EmbeddedOperatorImageOverride=$(EMBEDDED_OPERATOR_IMAGE_OVERRIDE)
39-
DISABLE_FIO_BUILD ?= 0
4039

4140
export PATH := $(shell pwd)/bin:$(PATH)
4241

@@ -77,16 +76,6 @@ pkg/goods/bins/local-artifact-mirror: Makefile
7776
$(MAKE) -C local-artifact-mirror build GOOS=linux GOARCH=amd64
7877
cp local-artifact-mirror/bin/local-artifact-mirror-$(GOOS)-$(GOARCH) pkg/goods/bins/local-artifact-mirror
7978

80-
pkg/goods/bins/fio: PLATFORM = linux/amd64
81-
pkg/goods/bins/fio: Makefile
82-
ifneq ($(DISABLE_FIO_BUILD),1)
83-
mkdir -p pkg/goods/bins
84-
docker build -t fio --build-arg PLATFORM=$(PLATFORM) fio
85-
docker rm -f fio && docker run --name fio fio
86-
docker cp fio:/output/fio pkg/goods/bins/fio
87-
touch pkg/goods/bins/fio
88-
endif
89-
9079
pkg/goods/internal/bins/kubectl-kots: Makefile
9180
mkdir -p pkg/goods/internal/bins
9281
mkdir -p output/tmp/kots
@@ -121,7 +110,6 @@ static: pkg/goods/bins/k0s \
121110
pkg/goods/bins/kubectl-preflight \
122111
pkg/goods/bins/kubectl-support_bundle \
123112
pkg/goods/bins/local-artifact-mirror \
124-
pkg/goods/bins/fio \
125113
pkg/goods/internal/bins/kubectl-kots
126114

127115
.PHONY: embedded-cluster-linux-amd64

cmd/embedded-cluster/install.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,11 @@ func runHostPreflights(c *cli.Context, hpf *v1beta2.HostPreflightSpec, proxy *ec
119119
return nil
120120
}
121121
pb.Infof("Running host preflights")
122-
output, stderr, err := preflights.Run(c.Context, hpf, proxy)
122+
output, err := preflights.Run(c.Context, hpf, proxy)
123123
if err != nil {
124124
pb.CloseWithError()
125125
return fmt.Errorf("host preflights failed to run: %w", err)
126126
}
127-
if stderr != "" {
128-
logrus.Debugf("preflight stderr: %s", stderr)
129-
}
130127

131128
err = output.SaveToDisk()
132129
if err != nil {

e2e/materialize_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ func TestMaterialize(t *testing.T) {
2121
{"rm", "-rf", "/var/lib/embedded-cluster/bin/kubectl"},
2222
{"rm", "-rf", "/var/lib/embedded-cluster/bin/kubectl-preflight"},
2323
{"rm", "-rf", "/var/lib/embedded-cluster/bin/kubectl-support_bundle"},
24-
{"rm", "-rf", "/var/lib/embedded-cluster/bin/fio"},
2524
{"embedded-cluster", "materialize"},
2625
{"ls", "-la", "/var/lib/embedded-cluster/bin/kubectl"},
2726
{"ls", "-la", "/var/lib/embedded-cluster/bin/kubectl-preflight"},
2827
{"ls", "-la", "/var/lib/embedded-cluster/bin/kubectl-support_bundle"},
29-
{"ls", "-la", "/var/lib/embedded-cluster/bin/fio"},
3028
}
3129
if err := RunCommandsOnNode(t, tc, 0, commands); err != nil {
3230
t.Fatalf("fail testing materialize assets: %v", err)

fio/Dockerfile

Lines changed: 0 additions & 27 deletions
This file was deleted.

pkg/defaults/defaults.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
// these should not happen in the first place.
44
package defaults
55

6-
var (
7-
// DefaultProvider holds the default provider and is used by the exported functions.
8-
DefaultProvider = NewProvider("")
9-
)
10-
116
var (
127
// provider holds a global reference to the default provider.
138
provider *Provider
@@ -16,88 +11,97 @@ var (
1611
// Holds the default no proxy values.
1712
var DefaultNoProxy = []string{"localhost", "127.0.0.1", ".default", ".local", ".svc", "kubernetes", "kotsadm-rqlite"}
1813

19-
const ProxyRegistryAddress = "proxy.replicated.com"
14+
var ProxyRegistryAddress = "proxy.replicated.com"
2015

2116
const KotsadmNamespace = "kotsadm"
2217
const SeaweedFSNamespace = "seaweedfs"
2318
const RegistryNamespace = "registry"
2419
const VeleroNamespace = "velero"
2520

21+
// def returns a global reference to the default provider. creates one if not
22+
// already created.
23+
func def() *Provider {
24+
if provider == nil {
25+
provider = NewProvider("")
26+
}
27+
return provider
28+
}
29+
2630
// BinaryName calls BinaryName on the default provider.
2731
func BinaryName() string {
28-
return DefaultProvider.BinaryName()
32+
return def().BinaryName()
2933
}
3034

3135
// EmbeddedClusterBinsSubDir calls EmbeddedClusterBinsSubDir on the default provider.
3236
func EmbeddedClusterBinsSubDir() string {
33-
return DefaultProvider.EmbeddedClusterBinsSubDir()
37+
return def().EmbeddedClusterBinsSubDir()
3438
}
3539

3640
// EmbeddedClusterChartsSubDir calls EmbeddedClusterChartsSubDir on the default provider.
3741
func EmbeddedClusterChartsSubDir() string {
38-
return DefaultProvider.EmbeddedClusterChartsSubDir()
42+
return def().EmbeddedClusterChartsSubDir()
3943
}
4044

4145
// EmbeddedClusterImagesSubDir calls EmbeddedClusterImagesSubDir on the default provider.
4246
func EmbeddedClusterImagesSubDir() string {
43-
return DefaultProvider.EmbeddedClusterImagesSubDir()
47+
return def().EmbeddedClusterImagesSubDir()
4448
}
4549

4650
// EmbeddedClusterLogsSubDir calls EmbeddedClusterLogsSubDir on the default provider.
4751
func EmbeddedClusterLogsSubDir() string {
48-
return DefaultProvider.EmbeddedClusterLogsSubDir()
52+
return def().EmbeddedClusterLogsSubDir()
4953
}
5054

5155
// K0sBinaryPath calls K0sBinaryPath on the default provider.
5256
func K0sBinaryPath() string {
53-
return DefaultProvider.K0sBinaryPath()
57+
return def().K0sBinaryPath()
5458
}
5559

5660
// PathToEmbeddedClusterBinary calls PathToEmbeddedClusterBinary on the default provider.
5761
func PathToEmbeddedClusterBinary(name string) string {
58-
return DefaultProvider.PathToEmbeddedClusterBinary(name)
62+
return def().PathToEmbeddedClusterBinary(name)
5963
}
6064

6165
// PathToLog calls PathToLog on the default provider.
6266
func PathToLog(name string) string {
63-
return DefaultProvider.PathToLog(name)
67+
return def().PathToLog(name)
6468
}
6569

6670
// PathToKubeConfig calls PathToKubeConfig on the default provider.
6771
func PathToKubeConfig() string {
68-
return DefaultProvider.PathToKubeConfig()
72+
return def().PathToKubeConfig()
6973
}
7074

7175
// PreferredNodeIPAddress calls PreferredNodeIPAddress on the default provider.
7276
func PreferredNodeIPAddress() (string, error) {
73-
return DefaultProvider.PreferredNodeIPAddress()
77+
return def().PreferredNodeIPAddress()
7478
}
7579

7680
// TryDiscoverPublicIP calls TryDiscoverPublicIP on the default provider.
7781
func TryDiscoverPublicIP() string {
78-
return DefaultProvider.TryDiscoverPublicIP()
82+
return def().TryDiscoverPublicIP()
7983
}
8084

8185
// PathToK0sConfig calls PathToK0sConfig on the default provider.
8286
func PathToK0sConfig() string {
83-
return DefaultProvider.PathToK0sConfig()
87+
return def().PathToK0sConfig()
8488
}
8589

8690
// PathToK0sStatusSocket calls PathToK0sStatusSocket on the default provider.
8791
func PathToK0sStatusSocket() string {
88-
return DefaultProvider.PathToK0sStatusSocket()
92+
return def().PathToK0sStatusSocket()
8993
}
9094

9195
func PathToK0sContainerdConfig() string {
92-
return DefaultProvider.PathToK0sContainerdConfig()
96+
return def().PathToK0sContainerdConfig()
9397
}
9498

9599
// EmbeddedClusterHomeDirectory calls EmbeddedClusterHomeDirectory on the default provider.
96100
func EmbeddedClusterHomeDirectory() string {
97-
return DefaultProvider.EmbeddedClusterHomeDirectory()
101+
return def().EmbeddedClusterHomeDirectory()
98102
}
99103

100104
// PathToEmbeddedClusterSupportFile calls PathToEmbeddedClusterSupportFile on the default provider.
101105
func PathToEmbeddedClusterSupportFile(name string) string {
102-
return DefaultProvider.PathToEmbeddedClusterSupportFile(name)
106+
return def().PathToEmbeddedClusterSupportFile(name)
103107
}

pkg/preflights/host-preflight.yaml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ spec:
6363
collectorName: resolv.conf
6464
command: 'sh'
6565
args: ['-c', 'cat /etc/resolv.conf']
66-
- filesystemPerformance:
67-
collectorName: filesystem-write-latency-etcd
68-
timeout: 2m
69-
directory: /var/lib/k0s/etcd
70-
fileSize: 22Mi
71-
operationSizeBytes: 2300
72-
datasync: true
73-
enableBackgroundIOPS: true
74-
backgroundIOPSWarmupSeconds: 10
75-
backgroundWriteIOPS: 300
76-
backgroundWriteIOPSJobs: 6
77-
backgroundReadIOPS: 50
78-
backgroundReadIOPSJobs: 1
7966
analyzers:
8067
- cpu:
8168
checkName: CPU
@@ -380,12 +367,3 @@ spec:
380367
- pass:
381368
when: "false"
382369
message: "resolv.conf does not reference '127.0.0.1'"
383-
- filesystemPerformance:
384-
checkName: Filesystem Write Latency
385-
collectorName: filesystem-write-latency-etcd
386-
outcomes:
387-
- pass:
388-
when: "p99 < 10ms"
389-
message: 'Write latency is ok (p99 target < 10ms, actual: {{ "{{" }} .P99 {{ "}}" }})'
390-
- fail:
391-
message: 'Write latency is high (p99 target < 10ms, actual: {{ "{{" }} .String {{ "}}" }})'

pkg/preflights/preflights.go

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"errors"
99
"fmt"
10+
"io"
1011
"os"
1112
"os/exec"
1213
"strings"
@@ -31,34 +32,29 @@ func SerializeSpec(spec *troubleshootv1beta2.HostPreflightSpec) ([]byte, error)
3132

3233
// Run runs the provided host preflight spec locally. This function is meant to be
3334
// used when upgrading a local node.
34-
func Run(ctx context.Context, spec *troubleshootv1beta2.HostPreflightSpec, proxy *ecv1beta1.ProxySpec) (*Output, string, error) {
35+
func Run(ctx context.Context, spec *troubleshootv1beta2.HostPreflightSpec, proxy *ecv1beta1.ProxySpec) (*Output, error) {
3536
// Deduplicate collectors and analyzers before running preflights
3637
spec.Collectors = dedup(spec.Collectors)
3738
spec.Analyzers = dedup(spec.Analyzers)
3839

3940
fpath, err := saveHostPreflightFile(spec)
4041
if err != nil {
41-
return nil, "", fmt.Errorf("unable to save preflight locally: %w", err)
42+
return nil, fmt.Errorf("unable to save preflight locally: %w", err)
4243
}
4344
defer os.Remove(fpath)
4445
binpath := defaults.PathToEmbeddedClusterBinary("kubectl-preflight")
4546
stdout := bytes.NewBuffer(nil)
46-
stderr := bytes.NewBuffer(nil)
4747
cmd := exec.Command(binpath, "--interactive=false", "--format=json", fpath)
48-
cmd.Env = os.Environ()
49-
cmd.Env = proxyEnv(cmd.Env, proxy)
50-
cmd.Env = pathEnv(cmd.Env)
51-
cmd.Stdout, cmd.Stderr = stdout, stderr
48+
cmd.Env = proxyEnv(proxy)
49+
cmd.Stdout, cmd.Stderr = stdout, io.Discard
5250
if err = cmd.Run(); err == nil {
53-
out, err := OutputFromReader(stdout)
54-
return out, stderr.String(), err
51+
return OutputFromReader(stdout)
5552
}
5653
var exit *exec.ExitError
5754
if !errors.As(err, &exit) || exit.ExitCode() < 2 {
58-
return nil, stderr.String(), fmt.Errorf("error running host preflight: %w, stderr=%q", err, stderr.String())
55+
return nil, fmt.Errorf("unknown error running host preflight: %w", err)
5956
}
60-
out, err := OutputFromReader(stdout)
61-
return out, stderr.String(), err
57+
return OutputFromReader(stdout)
6258
}
6359

6460
// saveHostPreflightFile saves the provided spec to a temporary file and returns
@@ -101,40 +97,20 @@ func dedup[T any](objs []T) []T {
10197
return out
10298
}
10399

104-
func proxyEnv(env []string, proxy *ecv1beta1.ProxySpec) []string {
105-
next := []string{}
106-
for _, e := range env {
100+
func proxyEnv(proxy *ecv1beta1.ProxySpec) []string {
101+
env := []string{}
102+
for _, e := range os.Environ() {
107103
switch strings.SplitN(e, "=", 2)[0] {
108104
// Unset proxy environment variables
109105
case "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "no_proxy":
110-
default:
111-
next = append(next, e)
106+
continue
112107
}
108+
env = append(env, e)
113109
}
114110
if proxy != nil {
115-
next = append(next, fmt.Sprintf("HTTP_PROXY=%s", proxy.HTTPProxy))
116-
next = append(next, fmt.Sprintf("HTTPS_PROXY=%s", proxy.HTTPSProxy))
117-
next = append(next, fmt.Sprintf("NO_PROXY=%s", proxy.NoProxy))
118-
}
119-
return next
120-
}
121-
122-
func pathEnv(env []string) []string {
123-
path := ""
124-
next := []string{}
125-
for _, e := range env {
126-
switch strings.SplitN(e, "=", 2)[0] {
127-
// Unset PATH environment variable
128-
case "PATH":
129-
path = strings.SplitN(e, "=", 2)[1]
130-
default:
131-
next = append(next, e)
132-
}
133-
}
134-
if path != "" {
135-
next = append(next, fmt.Sprintf("PATH=%s:%s", path, defaults.EmbeddedClusterBinsSubDir()))
136-
} else {
137-
next = append(next, fmt.Sprintf("PATH=%s", defaults.EmbeddedClusterBinsSubDir()))
111+
env = append(env, fmt.Sprintf("HTTP_PROXY=%s", proxy.HTTPProxy))
112+
env = append(env, fmt.Sprintf("HTTPS_PROXY=%s", proxy.HTTPSProxy))
113+
env = append(env, fmt.Sprintf("NO_PROXY=%s", proxy.NoProxy))
138114
}
139-
return next
115+
return env
140116
}

0 commit comments

Comments
 (0)