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

pkg/plugin/v3: add plugin v3-alpha #1551

Merged
merged 1 commit into from
Jun 16, 2020

Conversation

estroz
Copy link
Contributor

@estroz estroz commented Jun 4, 2020

A new plugin version v3-alpha will contain all new plugin/scaffold changes/features. Since plugin version v2 is tested with project version 2, we probably should just test the new plugin with project version 3-alpha. This won't necessarily be the case going forward, ex. once 4-alpha is created we should generate separate testdata.

/cc @DirectXMan12 @camilamacedo86 @joelanford @mengqiy

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 4, 2020
@estroz
Copy link
Contributor Author

estroz commented Jun 4, 2020

/test pull-kubebuilder-e2e-k8s-1-17-0

@estroz
Copy link
Contributor Author

estroz commented Jun 4, 2020

A thought on bumping plugin version stages, ex. alpha to beta and beta to "" (stable): we should probably:

  1. Just change the plugin's stage string instead of creating a new package.
  2. Build a mechanism into pkg/cli that auto-upgrades an alpha or beta to the next stage if available. This should never be an issue because the next stage should be no different from the previous one, just more stable. This could be an issue if we remove something from alpha when upgrading to beta, perhaps a migration guide and something like --latest would work.

Nothing needs to be done in this PR regarding ^.

@estroz
Copy link
Contributor Author

estroz commented Jun 5, 2020

We may want to consider adding e2e test for plugin version v3-alpha too. Will likely follow up with these.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @estroz,

As we spoke, following my POV.

  • We do not need to make v2 plugins support V2 and V3 projects

v2 plugin just support v2 projects
v3-alpha and future versions support V3* projects.

It would make the things simpler and remove the need to change the generate_tesdata.sh script.

  • We do not copy all plugin/v2 scaffold files to plugin/v3
    It is possible to have in plugin/v3 only what is diff as it is done between v1 to v2. See here.

The above suggestions are applied in the PR; #1498 where is possible to check that all will work as expected.

I hope that it helps to reach out to the final decision.

@estroz
Copy link
Contributor Author

estroz commented Jun 10, 2020

  1. Is it reasonable to have an alpha plugin as the default for any project version?
  2. Can we assume that any given project scaffold will not change over time?

If the answer to 1 is no (alpha implies the plugin is unstable), then the previous stable plugin version should be the default (v2 in this case). If yes, then v3-alpha is fine.

If the answer to 2 is no, then we should copy all scaffolds to a new plugin whenever we create one. If yes (or a given scaffold can be considered stable in the long term), then we should selectively copy scaffolds.

Regardless #1498 makes changes unrelated to creating a new plugin version, which we should make separately from creation.

@camilamacedo86
Copy link
Member

Hi @estroz,

Just to clarifies. The #1498 was just added to show that it is a possible solution and will work fine for we add new changes to the plugins. However, if you be ok to move with the proposed solution we can split the #1498 as you suggested(add plugin/add new changes)

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

looked over the scaffolding code, only skimmed the templates. comments inline (expect some of it's copy-pasted from v2, but there's some stuff that was surprising)


// (used only to gen api with --pattern=addon)
// KbDeclarativePatternVersion is the sigs.k8s.io/kubebuilder-declarative-pattern version
const KbDeclarativePatternVersion = "v0.0.0-20200522144838-848d48e5b073"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this? I'm assuming going forward we just want --plugin declarative or something

Copy link
Contributor Author

@estroz estroz Jun 11, 2020

Choose a reason for hiding this comment

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

I think this attempts to fix a CI issue where the testdata scaffolded with addons enabled will pull the latest kubebuilder-declarative-pattern commit, which messes up git diff.

We should probably scaffold a tools.go containing a pinned version of this. I could also see kustomize and controller-tools versions being pinned this way, which are currently dealt with in the Makefile.

Copy link
Member

@camilamacedo86 camilamacedo86 Jun 12, 2020

Choose a reason for hiding this comment

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

The fix was done in https://github.com/kubernetes-sigs/kubebuilder/pull/1527/files?
I just n understand why we are changing its implementation here. Should not we just keep the scope to add new plugin version in this PR? I mean, why change it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't be changed here, just added a TODO.

Copy link
Member

@camilamacedo86 camilamacedo86 Jun 12, 2020

Choose a reason for hiding this comment

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

OK. Yep, we have an issue tracked for we create a plugin for that. See: #1543. The solution made was just to fix it until we are able to move forward and provide a plugin for that.

c/c @DirectXMan12

Comment on lines +111 to +116
if os.Getenv("KUBEBUILDER_ENABLE_PLUGINS") != "" {
fs.StringVar(&p.pattern, "pattern", "",
"generates an API following an extension pattern (addon)")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto here

reader := bufio.NewReader(os.Stdin)
if !p.resourceFlag.Changed {
fmt.Println("Create Resource [y/n]")
p.doResource = util.YesNo(reader)
Copy link
Contributor

Choose a reason for hiding this comment

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

at some point we should re-evaluate the yes/no stuff. IIRC we had wanted to do it for v2, but didn't want to break compat

pkg/plugin/v3/api.go Outdated Show resolved Hide resolved
pkg/plugin/v3/api.go Outdated Show resolved Hide resolved
return err
}

err = util.RunCmd("Running make", "make")
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be conditional on the make flag defined in the other file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently there's no init --make flag unlike create api. Perhaps we should add one.

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 not here just replicate so the code to v3? IMO we should not change any impl in this pr just add the v3-alpha plugin and then we can check each case/scenario in new pr's.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't be changed here, just added a TODO.

s.config.AddResource(s.resource.GVK())

if err := machinery.NewScaffold(s.plugins...).Execute(
s.newUniverse(),
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we be passing the universe between scaffold calls here?

Copy link
Member

Choose a reason for hiding this comment

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

I think that it also can be a TODO @estroz ?

bpFile.License = s.license
bpFile.Owner = s.owner
if err := machinery.NewScaffold().Execute(
s.newUniverse(""),
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto here and elsewhere re: re-using the universe

Copy link
Member

Choose a reason for hiding this comment

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

I think that it also can be a TODO @estroz ?

@DirectXMan12
Copy link
Contributor

If the answer to 1 is no (alpha implies the plugin is unstable), then the previous stable plugin version should be the default (v2 in this case). If yes, then v3-alpha is fine.

Per the meeting, IIRC we decided that the answer was "no", and that the default scaffolding for the v3 project version was going to be v2 till v3 stable was ready

testdata: modify project-v3.* testdata to use go/v3-alpha plugin,
since project-v2.* already tests plugin go/v2

generate_testdata.sh: add --plugin option
@estroz
Copy link
Contributor Author

estroz commented Jun 11, 2020

@DirectXMan12 fixed what was easy/reasonable and added TODO's for the rest.

project will prompt the user to run 'dep ensure' after writing the project files.
`
ctx.Examples = fmt.Sprintf(` # Scaffold a project using the apache2 license with "The Kubernetes authors" as owners
%s init --project-version=2 --domain example.org --license apache2 --owner "The Kubernetes authors"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
%s init --project-version=2 --domain example.org --license apache2 --owner "The Kubernetes authors"
%s init --project-version=3-alpha --domain example.org --license apache2 --owner "The Kubernetes authors"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow-up

)

func (p *initPlugin) UpdateContext(ctx *plugin.Context) {
ctx.Description = `Initialize a new project including vendor/ directory and Go package directories.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ctx.Description = `Initialize a new project including vendor/ directory and Go package directories.
ctx.Description = `Initialize a new project including Go package directories.

I should be removed already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow-up

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Just a few nits. Otherwise

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, estroz

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:

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2020
@DirectXMan12
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 16, 2020
@k8s-ci-robot k8s-ci-robot merged commit 26e468a into kubernetes-sigs:master Jun 16, 2020
@estroz estroz deleted the chore/add-plugin-v3 branch June 17, 2020 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants