Skip to content

Commit 61ee60d

Browse files
committed
sqlc-test-setup: accept a successful mssql-conf setup without stat-ing its conf
On a GitHub runner the tool runs as an unprivileged user, and /var/opt/mssql is readable by the mssql user only, so stat-ing /var/opt/mssql/mssql.conf failed with permission denied even though setup had completed. Treat a successful setup as installed, and when setup fails check for the configuration through sudo before deciding whether the failure was only the service start. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT
1 parent 4b58b94 commit 61ee60d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎cmd/sqlc-test-setup/mssql.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ func installMSSQL() error {
9494
log.Println("running mssql-conf setup")
9595
err = run("sudo", "env", "ACCEPT_EULA=Y", "MSSQL_PID=Developer", "MSSQL_SA_PASSWORD="+mssqlSAPassword,
9696
mssqlConf, "-n", "setup", "accept-eula")
97-
if _, statErr := os.Stat("/var/opt/mssql/mssql.conf"); statErr != nil {
98-
if err != nil {
99-
return fmt.Errorf("mssql-conf setup: %w", err)
100-
}
101-
return fmt.Errorf("mssql-conf setup wrote no /var/opt/mssql/mssql.conf")
97+
if err == nil {
98+
return nil
10299
}
103-
if err != nil {
104-
log.Printf("mssql-conf setup wrote the configuration but could not start the service (%s); start will", err)
100+
// /var/opt/mssql is readable by the mssql user only, so the check goes
101+
// through sudo rather than a stat as this user.
102+
if exec.Command("sudo", "test", "-f", "/var/opt/mssql/mssql.conf").Run() != nil {
103+
return fmt.Errorf("mssql-conf setup: %w", err)
105104
}
105+
log.Printf("mssql-conf setup wrote the configuration but could not start the service (%s); start will", err)
106106
return nil
107107
}
108108

0 commit comments

Comments
 (0)