Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): starting with past units should not increase the process units #2614

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nettoclaudio
Copy link
Member

Prior to this PR, running consecutive app-stop and app-start could increase the number of replicas since we didn't check the status of the pods. This implementation delegates to the provisioner a new method to get the desired replicas number.

@nettoclaudio nettoclaudio marked this pull request as ready for review April 19, 2023 00:12
Copy link
Member

@morpheu morpheu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! To ensure future modifications won't break this again, I would add an extra check on TestStart_StartProcessesUsingReplicasFromLastAppStop for a subsequent err = a.Start(context.TODO(), &output, "", "") should return empty output

@nettoclaudio
Copy link
Member Author

LGTM! To ensure future modifications won't break this again, I would add an extra check on TestStart_StartProcessesUsingReplicasFromLastAppStop for a subsequent err = a.Start(context.TODO(), &output, "", "") should return empty output

Sure... lemme improve this test case.

@@ -451,6 +451,12 @@ type InterAppProvisioner interface {
InternalAddresses(ctx context.Context, a App) ([]AppInternalAddress, error)
}

// CurrentReplicasGetter implements how to get the current (desired)
// number of replicas (units) of an app.
type CurrentReplicasGetter interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nettoclaudio could you rename to CurrentReplicasProvisioner to be like other interfaces ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

app/app.go Outdated

fmt.Fprintf(w, "Before being stopped, the %q process had %d replicas... re-adding them.\n", p, replicas)

err := prov.AddUnits(ctx, app, uint(replicas), p, version, w)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nettoclaudio to perfectly achieve the number of replicas without risky of race-condition, we should implement the SetUnits method instead of AddUnits, but it is a nice to have.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the name, the implementation on provisioner side is set-like already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... it isn't. So you found a bug. 🎉

@arthurcgc
Copy link
Member

lgtm 👍🏻

@nettoclaudio
Copy link
Member Author

nettoclaudio commented Apr 24, 2023

Please don't merge this PR yet. I found a problem when user doesn't pass a specific version - in this case, the PR doesn't do anything at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants