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

Add phase 1 of podman farm subcommands #19358

Merged
merged 9 commits into from
Aug 10, 2023

Conversation

umohnani8
Copy link
Member

@umohnani8 umohnani8 commented Jul 25, 2023

This PR is phase 1 of adding the new podman farm subcommands.
Add farm create, list, remove, an update subcommands - complete with docs and tests.
Update the podman system connection add & remove commands to add and remove connections to and from farms - complete with docs and tests.

The podman farm command is currently hidden till it is fully ready, which will be in a follow up PR once this gets in.

Does this PR introduce a user-facing change?

Add podman farm create, list, remove, and update commands.
Update podman system connection add & remove to add and remove connections to and from farms.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 25, 2023
@umohnani8
Copy link
Member Author

@rhatdan @vrothberg @mheon @nalind PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Can we remove or comment-out those flags that are currently NOPs? Many flags being added have no test. If we add the functionality later on, it's easy to loose track of what's implemented and what not making reviews hard.

Please break future PRs into smaller commits. It's quite hard to review so much functionality at once. I'm mostly afraid to oversee things during review. Once released, it's hard to correct after the fact.

cmd/podman/buildfarm/create.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/inspect.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/list.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/prune.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/prune.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/remove.go Outdated Show resolved Hide resolved
cmd/podman/buildfarm/remove.go Outdated Show resolved Hide resolved
test/e2e/buildfarm_test.go Outdated Show resolved Hide resolved
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm3\" updated"))

// update farm2 to be the default farm
cmd = []string{"buildfarm", "update", "--default", "farm2"}
Copy link
Member

Choose a reason for hiding this comment

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

What if farm1 is already default and I do a buildfarm update --default=false farm1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question - if that is the case we set DefaultFarm to "" so that none of the existing farms are set as the default.
Added a test case for this.

@umohnani8
Copy link
Member Author

@vrothberg I broke the PR into as small commits as possible to help make reviews easier.

@vrothberg
Copy link
Member

@vrothberg I broke the PR into as small commits as possible to help make reviews easier.

Thanks!

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2023
@umohnani8 umohnani8 force-pushed the buildfarm-2 branch 4 times, most recently from 660f34e to c31cd12 Compare August 1, 2023 18:31
@umohnani8 umohnani8 force-pushed the buildfarm-2 branch 5 times, most recently from a6f4fae to 2f4921c Compare August 2, 2023 14:23
@umohnani8
Copy link
Member Author

umohnani8 commented Aug 2, 2023

So the man page and help menu scripts are unhappy because buildfarm is a hidden subcommand and doesn't show up in the help menu even though it is in the man pages. But if I remove it from the podman.1.md man page, the other script complains that buildfarm is not listed in podman.1.md - should I just not add man pages for this? Or is there another possible workaround? Fixing it for one of the scripts makes the other script unhappy https://github.com/containers/podman/pull/19358/checks?check_run_id=15557073962

Nvm, I found a way to ignore it as it is a hidden command.

@umohnani8 umohnani8 changed the title [WIP] Add phase 1 of podman buildfarm subcommands Add phase 1 of podman buildfarm subcommands Aug 2, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 2, 2023
docs/source/markdown/podman-buildfarm.1.md Outdated Show resolved Hide resolved
docs/source/markdown/podman-buildfarm.1.md Outdated Show resolved Hide resolved
cmd/podman/buildfarm/create.go Outdated Show resolved Hide resolved
}

if _, ok := cfg.Farms.List[farmName]; ok {
// if farm exists return an error
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a --replace option?

Copy link
Member Author

Choose a reason for hiding this comment

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

we could, but we already have buildfarm update that let's you add or remove connections from a farm and buildfarm rm can be used to remove a farm completely to create a new one.
I don't mind adding it, just think there are already other ways of doing a replace.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest to go ahead and implement the core functionality. We can always improve UX at a later point. At the moment, the core functionality of actually using buildfarm is missing and I think we need to make progress there first.

cmd/podman/buildfarm/create.go Outdated Show resolved Hide resolved
}

for _, k := range deletedFarms {
fmt.Printf("Farm %q deleted\n", k)
Copy link
Member

Choose a reason for hiding this comment

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

Do we do this when we remove containers from pods? Or does it just silently exit.

Copy link
Member Author

Choose a reason for hiding this comment

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

We print the container ID when it is successfully removed

docs/source/markdown/podman-buildfarm-remove.1.md Outdated Show resolved Hide resolved
cmd/podman/buildfarm/update.go Outdated Show resolved Hide resolved

## EXAMPLE
```
$ podman buildfarm update --add f35,f38 farm1
Copy link
Member

Choose a reason for hiding this comment

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

Should we have podman buildfarm add and podman buildfarm remove?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think buildfarm update is a better option. I feel like add and create are very similar and can be confusing (I think they are basically the same thing for system connection). And buildfarm remove is already used for removing farms.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed

cmd/podman/system/connection/add.go Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Aug 3, 2023

Very nice work.

@rhatdan
Copy link
Member

rhatdan commented Aug 8, 2023

We agreed at the meeting today to sed 's/buildfarm/farm/g'

Vendor latest c/common with changes to add a new Farms
table to containers.conf and update system connection to
add a connection to a farm when --farm is set.

Signed-off-by: Urvashi Mohnani <[email protected]>
Signed-off-by: Urvashi Mohnani <[email protected]>
@umohnani8 umohnani8 changed the title Add phase 1 of podman buildfarm subcommands Add phase 1 of podman farm subcommands Aug 9, 2023
@umohnani8
Copy link
Member Author

Moved from podman buildfarm to podman farm.

Signed-off-by: Urvashi Mohnani <[email protected]>
The podman farm create command allows users to create
farms from the avaiable podman system connections.

Signed-off-by: Urvashi Mohnani <[email protected]>
The podman farm list command allows users to list
the existing farms.

Signed-off-by: Urvashi Mohnani <[email protected]>
Podman farm remove allows users to remove one or more
existing farms.

Signed-off-by: Urvashi Mohnani <[email protected]>
Podman farm update allows users to update a farm by addig
connections, removing connections, or changing the default farm.

Signed-off-by: Urvashi Mohnani <[email protected]>
Add tests for podman farm create, remove, and update.

Signed-off-by: Urvashi Mohnani <[email protected]>
Add new --farm flag to podman system connection add so that
a user can add a new connection to a farm immediately.
Update system connection remove such that when a connection is
removed, the connection is also removed from any farms that have it.
Add docs and tests for these changes.

Signed-off-by: Urvashi Mohnani <[email protected]>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, umohnani8, vrothberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [rhatdan,umohnani8,vrothberg]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Aug 10, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2023
@openshift-merge-robot openshift-merge-robot merged commit 14e290a into containers:main Aug 10, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Nov 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants