- Notifications
You must be signed in to change notification settings - Fork927
fix(agent/agentcontainers): prevent reassigning proc.agent until successful#18609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -188,7 +188,7 @@ func (a *subAgentAPIClient) List(ctx context.Context) ([]SubAgent, error) { | ||
return agents, nil | ||
} | ||
func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (_SubAgent, err error) { | ||
a.logger.Debug(ctx, "creating sub agent", slog.F("name", agent.Name), slog.F("directory", agent.Directory)) | ||
displayApps := make([]agentproto.CreateSubAgentRequest_DisplayApp, 0, len(agent.DisplayApps)) | ||
@@ -233,19 +233,27 @@ func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (SubAgen | ||
if err != nil { | ||
return SubAgent{}, err | ||
} | ||
defer func() { | ||
if err != nil { | ||
// Best effort. | ||
_, _ = a.api.DeleteSubAgent(ctx, &agentproto.DeleteSubAgentRequest{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The steps below should never fail, but if they do, we try to clean up. | ||
Id: resp.GetAgent().GetId(), | ||
}) | ||
} | ||
}() | ||
agent.Name = resp.GetAgent().GetName() | ||
agent.ID, err = uuid.FromBytes(resp.GetAgent().GetId()) | ||
if err != nil { | ||
returnSubAgent{}, err | ||
} | ||
agent.AuthToken, err = uuid.FromBytes(resp.GetAgent().GetAuthToken()) | ||
if err != nil { | ||
returnSubAgent{}, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Review: In either this or above, we could have returned a semi-valid agent and assigned to | ||
} | ||
for _, appError := range resp.GetAppCreationErrors() { | ||
app := apps[appError.GetIndex()] | ||
a.logger.Warn(ctx, "unable to create app", | ||
slog.F("agent_name", agent.Name), | ||
Uh oh!
There was an error while loading.Please reload this page.