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

Package List (Parameters | Tasks | Plans) #1223

Merged
merged 12 commits into from
Jan 7, 2020
Merged

Package List (Parameters | Tasks | Plans) #1223

merged 12 commits into from
Jan 7, 2020

Conversation

kensipe
Copy link
Member

@kensipe kensipe commented Dec 24, 2019

What this PR does / why we need it:

Consolidating "list" as a verb under "package". Instead of kudo package params list, this PR changes to kudo package list parameters and adds kudo package list tasks and kudo package list plans.

This CLI utility functions are useful when:

  1. you are a operator dev and building an operator locally
  2. you want to "discover" what an operator can do (locally or from a repository)

Tasks

go run cmd/kubectl-kudo/main.go package list tasks cassandra
Name	Kind 	Resources                                                                                                                                                                            
node	Apply	[service.yaml cassandra-yaml.yaml cassandra-env-sh.yaml jvm-options.yaml stateful-set.yaml cassandra-exporter-config-yml.yaml service-monitor-yaml.yaml node-readiness-probe-sh.yaml]
go run cmd/kubectl-kudo/main.go package list tasks ../operators/repository/cowsay/operator/
Name  	Kind 	Resources        
app   	Apply	[deployment.yaml]
genwww	Pipe 	pipe-pod.yaml    
go run cmd/kubectl-kudo/main.go package list tasks zookeeper
Name              	Kind  	Resources                                                     
infra             	Apply 	[bootstrap.sh.yaml healthcheck.sh.yaml services.yaml pdb.yaml]
app               	Apply 	[statefulset.yaml]                                            
validation        	Apply 	[validation.yaml]                                             
validation-cleanup	Delete	[validation.yaml]                                             
not-allowed       	Apply 	[]    

** Plans **

go run cmd/kubectl-kudo/main.go package list plans zookeeper
zookeeper is a repository package from { name:community, url:https://kudo-repository.storage.googleapis.com }
plans
├── deploy (serial)
│   ├── [phase]  zookeeper (parallel)
│   │   └── [step]  deploy
│   │       ├── infra
│   │       └── app
│   └── [phase]  validation (serial)
│       ├── [step]  validation
│       │   └── validation
│       └── [step]  cleanup
│           └── validation-cleanup
└── validation (serial)
    └── [phase]  connection (serial)
        ├── [step]  connection
        │   └── validation
        └── [step]  cleanup
            └── validation-cleanup

or

go run cmd/kubectl-kudo/main.go package list plans zookeeper -t
plans
├── deploy (serial)
│   ├── [phase]  zookeeper (parallel)
│   │   └── [step]  deploy
│   │       ├── [apply]  infra
│   │       │   ├── bootstrap.sh.yaml
│   │       │   ├── healthcheck.sh.yaml
│   │       │   ├── services.yaml
│   │       │   └── pdb.yaml
│   │       └── [apply]  app
│   │           └── statefulset.yaml
│   └── [phase]  validation (serial)
│       ├── [step]  validation
│       │   └── [apply]  validation
│       │       └── validation.yaml
│       └── [step]  cleanup
│           └── [delete]  validation-cleanup
│               └── validation.yaml
└── validation (serial)
    └── [phase]  connection (serial)
        ├── [step]  connection
        │   └── [apply]  validation
        │       └── validation.yaml
        └── [step]  cleanup
            └── [delete]  validation-cleanup
                └── validation.yaml
go run cmd/kubectl-kudo/main.go package list plans ../operators/repository/cowsay/operator/
Name  	Phase	Strategy	Step    	Task    
deploy	main 	serial  	genfiles	[genwww]
      	     	        	app     	[app] 

** Parameters **

go run cmd/kubectl-kudo/main.go package list parameters zookeeper
Name         	Default	Required
CLIENT_PORT  	2181   	true    
CPUS         	250m   	true    
CPUS_LIMIT   	1000m  	true    
DISK_SIZE    	5Gi    	true    
ELECTION_PORT	3888   	true    
MEMORY       	1024Mi 	true    
MEM_LIMIT    	2048Mi 	true    
NODE_COUNT   	3      	true    
SERVER_PORT  	2888   	true    
STORAGE_CLASS	       	false  

Fixes #

… to add a number of other list types for operators

Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
@kensipe
Copy link
Member Author

kensipe commented Dec 24, 2019

needs tests otherwise good to go

Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

Love the rename of the command 👏 much more consistent now. We should not forget to mention it as breaking change though.

I have couple of issues with this:

  • I don't really understand the use case for the tasks command. As operator I cannot invoke tasks, as developer, I am editing the yaml so why would I list it through CLI when I can just directly open the yaml?
  • I think the plans list should probably use tree view (just a suggestion)? I think using something like "github.com/xlab/treeprint" as in plan_status would be much nicer. Or we could just list plans without phases?
  • I think the PR should reference an issue that should be in this iteration with meaningful description. If I remember correctly you were the one proposing everyone follows this :-)
  • we need tests

plus the comments I had inline :-)

pkg/kudoctl/cmd/package_list.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_plans.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_plans.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_tasks.go Outdated Show resolved Hide resolved
Signed-off-by: Ken Sipe <kensipe@gmail.com>
@kensipe
Copy link
Member Author

kensipe commented Dec 31, 2019

@alenkacz pushed updates for basic changes... I love the treeprint idea a lot. I will work on that next.

regarding task list and desire to have it... I'm thinking of 2 users:

  1. operator dev (that is new but maintaining or updating an operator
  2. kudo user (admin)

The question is: what does this opaque operator named x (mysql) do? what does it consist of?
For user 1. I want to create a new plan and would like to know what tasks exist and if any are not used.
for user 2. I see this plan with phases and steps that link to this task... but what does that task link to.

It is a reasonable argument that all you will get is a list of tasks with a list of template files.... but hopefully the naming of these things will be valuable... or perhaps we add an output for a file for viewing.

@kensipe
Copy link
Member Author

kensipe commented Dec 31, 2019

LOVE the tree view! thanks @alenkacz !

Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Love the tree view and cmd consistency! Left a few nits, but nothing critical.

pkg/kudoctl/cmd/package_list.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list.go Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_params.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_plans.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_plans.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_plans.go Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_tasks.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_tasks.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_tasks.go Outdated Show resolved Hide resolved
@@ -0,0 +1,11 @@
plans
Copy link
Contributor

Choose a reason for hiding this comment

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

I like golden files but this seems to be too small to be one. wdyt about putting it into a multiline var in the test above? Same for the other two golden files below.

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 actually like this one a lot. it is a great output example that could be referenced via documentation (when using asciidoc). It is also easy for a developer to "see" what the output is intended to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, it's not exactly YAML files so that they absolutely must be referenced to stay consistent with the codebase. And a developer can "see" them even better if they're in the same test file, where they're used. But I don't feel too strongly about it so if you insist 🤷‍♂

Copy link
Member

Choose a reason for hiding this comment

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

👍 for referencing these files in our documentation -- is there already a docs PR for this feature?

Signed-off-by: Ken Sipe <kensipe@gmail.com>
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

🚢

@kensipe kensipe dismissed alenkacz’s stale review January 6, 2020 15:01

concerns addressed and it isn't clear if she will return

Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

Thanks, this is a great addition, awesome to have these consistent set of subcommands to investigate operators.

My comments are mostly nits or small corrections, overall this looks great!

@@ -0,0 +1,11 @@
plans
Copy link
Member

Choose a reason for hiding this comment

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

👍 for referencing these files in our documentation -- is there already a docs PR for this feature?

pkg/kudoctl/cmd/package_list.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_params.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/package_list_params.go Outdated Show resolved Hide resolved
}

func sortedPlanNames(pf *packages.Files) []string {
planNames := make([]string, 0, len(pf.Operator.Plans))
Copy link
Member

Choose a reason for hiding this comment

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

sort.Strings also calls sort.Sort which is using interface{}. So
sort.Sort(funk.Keys(pf.Operator.Plans)) would do the same.

}

f := cmd.Flags()
f.StringVar(&lc.RepoName, "repo", "", "Name of repository configuration to use. (default defined by context)")
Copy link
Member

Choose a reason for hiding this comment

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

Not yours, more a general question: Given that repo and version are variables shared by all these subcommands, is it possible in cobra to "inherit" them here so that they don't have to be defined again for every subcommand?


gp := filepath.Join("testdata", file+".golden")

if *updateGolden {
Copy link
Member

Choose a reason for hiding this comment

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

Probably not yours, but why would we update files in a test? Especially if it's the file we're testing against?

Copy link
Member Author

Choose a reason for hiding this comment

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

it is to easy the burden on "known" output changes... it's a pretty standard technique

Co-Authored-By: Jan Schlicht <jan@d2iq.com>
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

LGTM!

@kensipe kensipe merged commit 52ecf33 into master Jan 7, 2020
@kensipe kensipe deleted the ken/package-lists branch January 7, 2020 19:58
porridge added a commit that referenced this pull request Jan 8, 2020
Make lint happy again.
This was result of a race between merging #1223 and #1245
ANeumann82 pushed a commit that referenced this pull request Feb 13, 2020
Co-authored-by: Jan Schlicht <jan.schlicht+gh@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
ANeumann82 pushed a commit that referenced this pull request Feb 13, 2020
Make lint happy again.
This was result of a race between merging #1223 and #1245

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
@porridge porridge added release/highlight This PR is a highlight for the next release and removed release-highlight labels Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review release/highlight This PR is a highlight for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants