diff --git a/acceptance/bundle/debug/out.stderr.txt b/acceptance/bundle/debug/out.stderr.txt index e5867e008..031d58082 100644 --- a/acceptance/bundle/debug/out.stderr.txt +++ b/acceptance/bundle/debug/out.stderr.txt @@ -72,7 +72,7 @@ 10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=metadata.AnnotatePipelines 10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize 10:07:59 Debug: Using Terraform from DATABRICKS_TF_EXEC_PATH at [TERRAFORM] pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize -10:07:59 Debug: Using Terraform CLI config from DATABRICKS_TF_CLI_CONFIG_FILE at [DATABRICKS_TF_CLI_CONFIG_FILE] pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize +10:07:59 Debug: DATABRICKS_TF_PROVIDER_VERSION as 1.62.0 does not match the current version 1.65.1, ignoring DATABRICKS_TF_CLI_CONFIG_FILE pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize 10:07:59 Debug: Environment variables for Terraform: ...redacted... pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize 10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit 10:07:59 Debug: No script defined for postinit, skipping pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit diff --git a/acceptance/daemon/child-detaches/script b/acceptance/daemon/child-detaches/script index 77b5fda61..0e83daade 100644 --- a/acceptance/daemon/child-detaches/script +++ b/acceptance/daemon/child-detaches/script @@ -4,3 +4,5 @@ $CLI selftest parent &> out.parentchild.txt echo "waiting for child process to finish" wait_pid $(cat ./child.pid) + +rm ./child.pid diff --git a/acceptance/daemon/child-discards-output/output.txt b/acceptance/daemon/child-discards-output/output.txt new file mode 100644 index 000000000..5fe488ade --- /dev/null +++ b/acceptance/daemon/child-discards-output/output.txt @@ -0,0 +1,9 @@ +Parent process has started +Started the child process +Provided input: Hello from the other side +Released the child process +Parent process is exiting + +wait for child process to finish +Process has ended +the child process should not have written any output. diff --git a/acceptance/daemon/child-discards-output/script b/acceptance/daemon/child-discards-output/script new file mode 100644 index 000000000..94ef19c70 --- /dev/null +++ b/acceptance/daemon/child-discards-output/script @@ -0,0 +1,9 @@ +$CLI selftest parent + +echo " +wait for child process to finish" +wait_pid $(cat ./child.pid) + +echo "the child process should not have written any output." + +rm ./child.pid diff --git a/libs/daemon/daemon.go b/libs/daemon/daemon.go index ff81643b3..1c7dc7e9a 100644 --- a/libs/daemon/daemon.go +++ b/libs/daemon/daemon.go @@ -1,7 +1,6 @@ package daemon import ( - "context" "fmt" "io" "os" @@ -12,11 +11,7 @@ import ( const DatabricksCliParentPid = "DATABRICKS_CLI_PARENT_PID" type Daemon struct { - // TODO: remove this. - ctx context.Context - // If provided, the child process will create a pid file at this path. - // TODO: Can we remove this? PidFilePath string // Environment variables to set in the child process. @@ -48,7 +43,6 @@ func (d *Daemon) Start() error { d.cmd.SysProcAttr = sysProcAttr() // By default redirect stdout and stderr to /dev/null. - // TODO: Test that by default stdout and stderr do not leak to the parent process. d.cmd.Stdout = nil d.cmd.Stderr = nil @@ -101,7 +95,8 @@ func (d *Daemon) Release() error { return nil } - // This does not seem to be strictly necessary, but the docs recommend - // adding it if Wait is not called. Thus we add it here to be safe. + // The docs recommend calling Release if Wait is not called. This does not + // seem to be necessary since the functionality works without it. However, we + // we add it just to be safe. return d.cmd.Process.Release() } diff --git a/libs/process/wait_test.go b/libs/process/wait_test.go index 72a5ee4aa..bc9407a8e 100644 --- a/libs/process/wait_test.go +++ b/libs/process/wait_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/assert" ) -// TODO: Test this in windows. Setup an IDE. func TestWait(t *testing.T) { err := Wait(1000000) assert.EqualError(t, err, "process with pid 1000000 does not exist") diff --git a/libs/process/wait_windows.go b/libs/process/wait_windows.go index 2139601de..c7a8d9ac7 100644 --- a/libs/process/wait_windows.go +++ b/libs/process/wait_windows.go @@ -17,7 +17,7 @@ func waitForPid(pid int) error { uint32(pid), ) if errors.Is(err, windows.ERROR_INVALID_PARAMETER) { - return ErrProcessDoesNotExist{Pid: pid} + return ErrProcessNotFound{Pid: pid} } if err != nil { return fmt.Errorf("OpenProcess failed: %v", err)