Skip to content

Refactor cmd/nerdctl - #3379

Merged
AkihiroSuda merged 16 commits into
containerd:mainfrom
apostasie:refactor-cmd
Sep 2, 2024
Merged

AkihiroSuda merged 16 commits into
containerd:mainfrom
apostasie:refactor-cmd

Conversation

@apostasie

@apostasie apostasie commented Aug 29, 2024 •

Copy link
Copy Markdown
Contributor

This is in light of #3375 and #1680

The overall goal is to break down cmd/nerdctl.

These commits do:

  • move some commonly used functions into cmd/nerdctl/helpers
    • these have been roughly split into distinct files that belong to different categories (testing, cobra, etc.)
    • see final note below on not attempting to clean these up further for now
  • move to subpackages:
    • cmd/nerdctl/completion
    • cmd/nerdctl/login
    • cmd/nerdctl/namespace
    • cmd/nerdctl/network
    • cmd/nerdctl/volume
    • cmd/nerdctl/image
    • cmd/nerdctl/builder
    • cmd/nerdctl/apparmor
    • cmd/nerdctl/internal

This is purely refactoring, and there is no functional or logic change (see testing note at the bottom though).

Further note that this PR does not try to "cleanup" anything besides that. Specifically out of scope for now (could be done in a subsequent PR):

  • name stuttering reduction
  • possible cleanup of the "helpers" folder

Also, this PR is big enough now - what remains to be done (containers and compose) are big chunks on their own, and I would rather merge this first then tackle these two in the next PR.

This is on-top of #3384 that should be merged first.

@apostasie
apostasie marked this pull request as draft August 29, 2024 19:17
@apostasie apostasie changed the title Refactor cmd/nerdctl [WIP] Refactor cmd/nerdctl Aug 29, 2024
@apostasie
apostasie force-pushed the refactor-cmd branch 4 times, most recently from cba2c35 to aca4bf9 Compare August 29, 2024 19:35
@apostasie
apostasie marked this pull request as ready for review August 29, 2024 19:48
@apostasie

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @djdongjin and others: lmk if you think this is going in the right direction (before I invest more effort into this).

@apostasie apostasie changed the title [WIP] Refactor cmd/nerdctl Refactor cmd/nerdctl Aug 29, 2024
@AkihiroSuda
AkihiroSuda requested a review from Zheaoli August 30, 2024 08:42
Comment thread cmd/nerdctl/completion/completion.go Resolved

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I think this direction is fine, as long as the CI can remain green

@apostasie

Copy link
Copy Markdown
Contributor Author

@Zheaoli lmk what you think.
Otherwise, happy to have this first one merged at your convenience folks.
Will move forward in that direction then.

@apostasie

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda I am sending atomic commits on this, where each commit does one simple/clear thing.
Hopefully, that should help reviewers - as my latest PRs have been a big too big/compact and people have been asking me for more broken down, easier to review chunks.

In the case here, though, lmk if you folks would prefer me to squash.

@AkihiroSuda

Copy link
Copy Markdown
Member

Thanks, in this case commits should remain unsquashed 👍

@apostasie
apostasie force-pushed the refactor-cmd branch 4 times, most recently from 022a974 to db02b9e Compare August 30, 2024 18:05
@apostasie
apostasie marked this pull request as draft August 30, 2024 18:53
@apostasie

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda I clearly hit a snag wrt testing (maybe that is what stopped the previous refactoring attempt).
Will investigate and fix (but reverting to draft until the CI is green).

This is still good to review right now - at least to validate that in principle we are all fine with the direction and that "what was moved where" does make sense.

@Zheaoli

Zheaoli commented Aug 30, 2024

Copy link
Copy Markdown
Member

@Zheaoli lmk what you think. Otherwise, happy to have this first one merged at your convenience folks. Will move forward in that direction then.

This PR is mostly LGTM. BTW I think maybe we can split it into multiple some PR.

@apostasie
apostasie force-pushed the refactor-cmd branch 2 times, most recently from 80ebbe2 to 7e87989 Compare August 30, 2024 22:19
@apostasie

Copy link
Copy Markdown
Contributor Author

@Zheaoli lmk what you think. Otherwise, happy to have this first one merged at your convenience folks. Will move forward in that direction then.

This PR is mostly LGTM. BTW I think maybe we can split it into multiple some PR.

Thanks a lot @Zheaoli !
Appreciate your review.

I did split this into a bunch of separate commits - so, that should be easing review in the same way different PRs would.

That being said, I also split it into two PRs (next one being: #3383) as it was indeed growing out of control.

@apostasie
apostasie force-pushed the refactor-cmd branch 3 times, most recently from 8d6aee1 to 4184037 Compare August 31, 2024 00:23
@apostasie
apostasie force-pushed the refactor-cmd branch 2 times, most recently from 0b00798 to 9595679 Compare September 1, 2024 00:05
@apostasie

apostasie commented Sep 1, 2024 •

Copy link
Copy Markdown
Contributor Author

🤦‍♂️

@sondavidb

This PR last commit breaks windows: 9595679

It does work fine before this commit.

The test that breaks down is TestImageInspectContainsSomeStuff (great test name), but this might be a red herring.

The failure message is Klingon to me: "failed to extract layer sha256:f2032cdb21dfb9f3d6fdd3797ea992ec05415e5a6a57f9eb36b6646496db8d09: hcsshim::ProcessUtilityVMImage \\?\C:\ProgramData\containerd\root\io.containerd.snapshotter.v1.windows\snapshots\2\UtilityVM: Incorrect function.: unknown""

I have read this commit over and over, and cannot find anything blatantly wrong - my current intuition is that it breaks because the tests order changed, or because the test got relocated (before that commit, that test was ran under cmd/nerdctl, and after all the containerx_test tests).

So, either the location change has an impact, or something happening in containers tests that somehow "leak" into this test.

At this point, I cannot go anywhere without a windows rig, so, I will bite it and go get some windows rig... (or is it doable inside a VM on mac?)

But on the off-chance you could take a look, I thought I would ask you:
- is the error message any familiar?
- would you be able to play around with/without that commit and see if you get anywhere?

Thanks :-)

@apostasie apostasie changed the title [WIP] Refactor cmd/nerdctl Refactor cmd/nerdctl Sep 1, 2024
@apostasie
apostasie marked this pull request as ready for review September 1, 2024 06:01
@apostasie

apostasie commented Sep 1, 2024 •

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @Zheaoli CI is green.

This is ready AFAIC.

We need to merge #3384 first as it has important fixes for testing, and then this (will keep here in sync as #3384 gets modified following review)

Comment thread .github/workflows/test-canary.yml Resolved
Signed-off-by: apostasie <[email protected]>
AddIntFlag AddDurationFlag AddStringFlag checkExperimental createBuildContext testComposeUp requiresStargz newJWEKeyPair rmiAll

Signed-off-by: apostasie <[email protected]>
Signed-off-by: apostasie <[email protected]>

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda
AkihiroSuda merged commit f2bfc60 into containerd:main Sep 2, 2024
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants