fix: serialize concurrent property updates

Concurrent commands for the same app could each read a setting, change it, and write it back, so all of them exited successfully while silently dropping changes made by the others. Updates to app settings are now serialized so every change is kept, and readers never see a partially written value.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-10-21 21:21:57 -04:00
1 parent ba1d49576b
commit 9df45f6a6e
42 files changed
+1698 -642

No files matched your search

+21 -2
View File
@@ -126,7 +126,7 @@ func CommandLogin(appName string, server string, username string, password strin
env["DOCKER_CONFIG"] = GetAppRegistryConfigDir(appName)
}
result, err := common.CallExecCommand(common.ExecCommandInput{
result, err := execDockerConfigCommand(env["DOCKER_CONFIG"], common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"login", "--username", username, "--password-stdin", server},
Env: env,
@@ -184,7 +184,7 @@ func CommandLogout(appName string, server string) error {
env["DOCKER_CONFIG"] = GetAppRegistryConfigDir(appName)
}
result, err := common.CallExecCommand(common.ExecCommandInput{
result, err := execDockerConfigCommand(env["DOCKER_CONFIG"], common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"logout", server},
Env: env,
@@ -226,3 +226,22 @@ func CommandSet(appName string, property string, value string) error {
common.CommandPropertySet("registry", appName, property, value, DefaultProperties, GlobalProperties)
return nil
}
// execDockerConfigCommand runs a docker command that rewrites the credentials
// file in configDir. docker merges the file it reads with the change it makes,
// so the directory stays locked for the whole command to keep concurrent logins
// and logouts for one app from dropping each other's credentials. An empty
// configDir means docker's own config, which is left unlocked.
func execDockerConfigCommand(configDir string, input common.ExecCommandInput) (common.ExecCommandResponse, error) {
if configDir == "" {
return common.CallExecCommand(input)
}
var result common.ExecCommandResponse
err := common.LockDirectory(configDir, func() error {
var err error
result, err = common.CallExecCommand(input)
return err
})
return result, err
}