@@ -195,6 +195,21 @@ func (s *cluster) Initialize(ctx context.Context) context.Context {
195
195
s .agentVersion = s .managerVersion
196
196
}
197
197
198
+ // We cannot use t.TempDir() here, because it will not mount correctly in
199
+ // rancher-desktop and docker-desktop (unless they are configured to allow
200
+ // mounts directly from /tmp). So we use a tempdir in BUILD_OUTPUT instead
201
+ // because it's believed to be both mountable and writable.
202
+ tempDir := dos .Getenv (ctx , "TELEPRESENCE_TEMP_DIR" )
203
+ if tempDir == "" {
204
+ tempDir = filepath .Join (BuildOutput (ctx ), "tmp" )
205
+ }
206
+ _ = dos .RemoveAll (ctx , tempDir )
207
+ require .NoError (t , dos .MkdirAll (ctx , tempDir , 0o777 ))
208
+ ctx = withTempDirBase (ctx , & tempDirBase {tempDir : tempDir })
209
+ t .Cleanup (func () {
210
+ _ = os .RemoveAll (tempDir )
211
+ })
212
+
198
213
registry := dos .Getenv (ctx , "TELEPRESENCE_REGISTRY" )
199
214
if registry == "" {
200
215
registry = "ghcr.io/telepresenceio"
@@ -290,11 +305,8 @@ func (s *cluster) Initialize(ctx context.Context) context.Context {
290
305
291
306
s .ensureQuit (ctx )
292
307
s .ensureNoManager (ctx )
293
- _ = Run (ctx , "kubectl" , "delete" , "ns" , "-l" , AssignPurposeLabel )
294
308
_ = Run (ctx , "kubectl" , "delete" , "-f" , filepath .Join ("testdata" , "k8s" , "client_rbac.yaml" ))
295
- _ = Run (ctx , "kubectl" , "delete" , "ns" , "-l" , AssignPurposeLabel )
296
- _ = Run (ctx , "kubectl" , "delete" , "pv" , "-l" , AssignPurposeLabel )
297
- _ = Run (ctx , "kubectl" , "delete" , "storageclass" , "-l" , AssignPurposeLabel )
309
+ _ = Run (ctx , "kubectl" , "delete" , "all" , "-l" , AssignPurposeLabel )
298
310
return ctx
299
311
}
300
312
@@ -354,10 +366,7 @@ func (s *cluster) tearDown(ctx context.Context) {
354
366
if s .kubeConfig != "" {
355
367
ctx = WithWorkingDir (ctx , GetOSSRoot (ctx ))
356
368
_ = Run (ctx , "kubectl" , "delete" , "-f" , filepath .Join ("testdata" , "k8s" , "client_rbac.yaml" ))
357
- _ = Run (ctx , "kubectl" , "delete" , "--wait=false" , "ns" , "-l" , AssignPurposeLabel )
358
- _ = Run (ctx , "kubectl" , "delete" , "--wait=false" , "pv" , "-l" , AssignPurposeLabel )
359
- _ = Run (ctx , "kubectl" , "delete" , "--wait=false" , "storageclass" , "-l" , AssignPurposeLabel )
360
- _ = Run (ctx , "kubectl" , "delete" , "--wait=false" , "mutatingwebhookconfigurations" , "-l" , AssignPurposeLabel )
369
+ _ = Run (ctx , "kubectl" , "delete" , "--wait=false" , "all" , "-l" , AssignPurposeLabel )
361
370
}
362
371
}
363
372
@@ -439,7 +448,7 @@ func (s *cluster) withBasicConfig(c context.Context, t *testing.T) context.Conte
439
448
require .NoError (t , err )
440
449
configYamlStr := string (configYaml )
441
450
442
- configDir := t . TempDir ()
451
+ configDir := TempDir (c )
443
452
c = filelocation .WithAppUserConfigDir (c , configDir )
444
453
c , err = SetConfig (c , configDir , configYamlStr )
445
454
require .NoError (t , err )
@@ -1071,7 +1080,7 @@ func WithConfig(c context.Context, modifierFunc func(config client.Config)) cont
1071
1080
configYaml , err := configCopy .(client.Config ).MarshalYAML ()
1072
1081
require .NoError (t , err )
1073
1082
configYamlStr := string (configYaml )
1074
- configDir , err := os .MkdirTemp (t . TempDir (), "config" )
1083
+ configDir , err := os .MkdirTemp (TempDir (c ), "config" )
1075
1084
require .NoError (t , err )
1076
1085
c , err = SetConfig (c , configDir , configYamlStr )
1077
1086
require .NoError (t , err )
0 commit comments