-
-
Notifications
You must be signed in to change notification settings - Fork 867
atc/db: Get worker.ActiveContainers from containers table #6469
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
atc/db: Get worker.ActiveContainers from containers table #6469
Conversation
Hi! I think I'm a little hesitant of changing the output of |
I don't think this PR changes the The only real use right now for it is "fly containers reports far more containers than fly workers - something in the ATC/DB must be wrong." To find out which containers are in the DB and shouldn't be, you still need to somehow exec onto the worker and query Garden directly. I could maybe see a place for |
Oh sorry about that! I misread your pull request description and I had a wrong understanding of the |
@andy-paine I was just wondering if you would be interested in adding the two columns rather than replacing the existing column with new data? Sorry if it sounds like I'm rushing you, I just wanted to know if this PR is in a finished state or if you wanted to add that extra part. It should be just keeping the existing column data and renaming it, then adding a new column with the new data that you added! Thanks! :) |
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
22c2491
to
b6c4c18
Compare
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
c13b802
to
950eae5
Compare
Hey @clarafu - I'm Tom from EngineerBetter. I'll make the changes Andy and yourself suggested here (renaming the existing column and adding a new column). |
I've started with a shallow rename of the DB fields. Just to check, are we suggesting a deep rename of interfaces here such as this interface too? Happy to do this but just wanted to point out that that will touch a few areas of the codebase wherever this interface is used and I'm not sure if that's considered a "breaking change" with versioning considerations. |
Thanks for picking this PR up! I think renaming the DB fields along with the interfaces would be best, I don't think we need to consider this a breaking change because it is just adding a new column in the DB and renaming a field on the |
0e0ae37
to
1765ca6
Compare
Renamed |
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
7e0fa6a
to
68648a1
Compare
Rather than tracking the active container count via the heartbeat, just use the containers table instead. This gives a more accurate representation of how many containers there are from the ATC's point of view since this is what is used for scheduling decisions and brings the `fly workers` and `fly containers` numbers in sync. This data is refreshed from the workers slightly less frequently than the heartbeats but is updated by the ATC as soon as a container is created so has faster initial feedback which may help with scheduling decisions. Signed-off-by: Andy Paine <andy.paine@engineerbetter.com>
This reverts commit 950eae5. Signed-off-by: Tom Godkin <tom.godkin@engineerbetter.com>
Signed-off-by: Tom Godkin <tom.godkin@engineerbetter.com>
39d52e7
to
c429bd3
Compare
Signed-off-by: Tom Godkin <tom.godkin@engineerbetter.com>
c429bd3
to
50d353b
Compare
@clarafu We've added the the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For your question about tsa/cmd/tsa
, I don't think you need to add any tests and your changes seem appropriate where it is just renaming the field. I think you don't need to add any new tests because we arn't changing any behaviour, since we are just renaming a field. As long as there are existing tests that test the new renamed field, I think that is sufficient!
I also see there are some merge conflicts, would you be able to merge or rebase your branch ontop of master?
Thanks! 😄
@@ -0,0 +1 @@ | |||
ALTER TABLE workers RENAME COLUMN active_containers TO expected_containers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we actually needed to rename the active_containers
column to reported_containers
. This is because whenever a worker heartbeats to the ATC, it will report the number of containers that are currently on the worker itself. This is the number of containers that is reported directly from the worker. The other container count that we want to add is expected_containers
and this is the number of containers that the ATC itself thinks "should be" on the worker. This should be the number of containers in the containers
table. Sorry for the confusion, I should have clarified it properly before you made all these changes :(
@@ -140,7 +140,7 @@ func (command *WorkersCommand) tableFor(workers []worker) ui.Table { | |||
for _, w := range workers { | |||
row := ui.TableRow{ | |||
{Contents: w.Name}, | |||
{Contents: strconv.Itoa(w.ActiveContainers)}, | |||
{Contents: strconv.Itoa(w.ExpectedContainers)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can try to add a new column in the fly workers
output by just adding a new TableRow
here and on like 120. We can also rename the containers
column to reported containers
and then add a new column for expected containers
!
@@ -57,7 +58,8 @@ var workersQuery = psql.Select(` | |||
w.ephemeral | |||
`). | |||
From("workers w"). | |||
LeftJoin("teams t ON w.team_id = t.id") | |||
LeftJoin("teams t ON w.team_id = t.id"). | |||
LeftJoin("(SELECT worker_name, COUNT(handle) reported_containers FROM containers GROUP BY worker_name) cs ON w.name = cs.worker_name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be populating the expected_containers
count rather than reported_containers
because the reported_containers
should be containing the number of containers that the worker heartbeating returns back. (but this is the same as what I mentioned in my previous review comment)
I was thinking here that maybe instead of having the expected_containers
count be queried out everytime we select for a worker, we could have a method on the db.Worker
interface called ExpectedWorker() (int, error)
and it will run a query to find the number of containers for that worker in the containers table. The reason for this is that we can separately run the method to find the reported containers when we need it. If we put the query within the workersQuery
then everytime we fetch out a db.Worker
object it will run this query even in places that we don't care about the expected_containers
(for example, grabbing out all the workers for container placement). The only time we will need the expected_containers
is in the api so we can just have the api run the method to grab out the number of expected_containers
. Similar to
concourse/atc/api/present/worker.go
Lines 21 to 24 in 0af59c6
activeTasks, err := workerInfo.ActiveTasks() | |
if err != nil { | |
activeTasks = 0 | |
} |
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
there's one behavioural difference currently - fewest-build-containers previously fetched ActiveContainers from the containers table, rather than the heartbeated value. I implemented it more simply using db.Worker.ActiveContainers since #6469 will take care of this Signed-off-by: Aidan Oldershaw <aoldershaw@pivotal.io>
closing the PR for now. Feel free to reopen it. |
Signed-off-by: Andy Paine andy.paine@engineerbetter.com
What does this PR accomplish?
Bug Fix | Feature | Documentation
Helps (partially) with #4340
Changes proposed by this PR:
Rather than tracking the active container count via the heartbeat, just use the containers table instead. This gives a more accurate representation of how many containers there are from the ATC's point of view since this is what is used for scheduling decisions and brings the
fly workers
andfly containers
numbers in sync. This data is refreshed from the workers slightly less frequently than the heartbeats but is updated by the ATC as soon as a container is created so has faster initial feedback which may help with scheduling decisions.Notes to reviewer:
Release Note
containers
in thefly workers
output will now match the containers returned byfly containers
Contributor Checklist
Reviewer Checklist
BOSH and
Helm packaging; otherwise, ignored for
the integration
tests
(for example, if they are Garden configs that are not displayed in the
--help
text).