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

feat: Cluster scoped workflow template #2451

Merged
merged 144 commits into from
Apr 2, 2020

Conversation

sarabala1979
Copy link
Member

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234". Creating WorkflowTemplate on a cluster level so all namespace can use it #1729
  • I have written unit and/or e2e tests for my change. PRs without these are unlike to be merged.
  • Optional. I've added My organization is added to the USERS.md.
  • I've signed the CLA and required builds are green.

@alexec
Copy link
Contributor

alexec commented Mar 27, 2020

I've requested a few small changes - but given approval anyway to move this forward.

@simster7
Copy link
Member

Please hold off on merging this, I'm adding some review comments.

cmd/argo/commands/clustertemplate/get.go Show resolved Hide resolved
cmd/argo/commands/clustertemplate/root.go Outdated Show resolved Hide resolved
examples/cluster-workflow-template/clustertemplates.yaml Outdated Show resolved Hide resolved
pkg/apiclient/argo-kube-client.go Outdated Show resolved Hide resolved
workflow/common/common.go Show resolved Hide resolved
workflow/controller/controller_test.go Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_template_types.go Outdated Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
sarabala1979 and others added 3 commits March 30, 2020 11:29
Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>

// GetTemplateScope returns the template scope of workflow template.
func (cwftmpl *ClusterWorkflowTemplate) GetTemplateScope() string {
return "cluster/" + cwftmpl.Name
Copy link
Member

@simster7 simster7 Mar 30, 2020

Choose a reason for hiding this comment

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

This is a minor and pedantic comment, but we use different grammar with cluster/<template_name> and namespaced/<template_name>.

In my opinion it should be either:

  • clustered/<template_name> and namespaced/<template_name>; or
  • cluster/<template_name> and namespace/<template_name>

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 am just following Kubernetes conventions

 # either Namespaced or Cluster
  scope: Namespaced

Copy link
Member Author

Choose a reason for hiding this comment

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

// ResourceScope is an enum defining the different scopes available to a custom resource
type ResourceScope string

const (
	ClusterScoped   ResourceScope = "Cluster"
	NamespaceScoped ResourceScope = "Namespaced"
)

Copy link
Member Author

Choose a reason for hiding this comment

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

@jessesuen I would like to get your feedback on this before merging this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Where is this GetTemplateScope method even being used?

Copy link
Member

@jessesuen jessesuen Apr 1, 2020

Choose a reason for hiding this comment

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

Also, based on the name of this method, I would expect it to return a ResourceScope type of either Cluster or Namespaced, but I see it's the scope + name of the resource, which they could already get by metadata.name

Can I learn the intended use of this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@jessesuen jessesuen Apr 1, 2020

Choose a reason for hiding this comment

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

I see, I thought it was being introduced in this change, but could not find the usage in this PR. In any case, I think following kubernetes scope naming of cluster and namespaced is the right choice.

That said, I do believe it would be better to make GetTemplateScope() return a ResourceScope kind, change GetStoredTemplate() to accept both a scope and name, and then inside GetStoredTemplate(), formulate the map key based on concatenating the two with a slash.

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 agreed with you. But TemplateScope word is used across workflowtemplate implantation and workflow spec. Instead of changing one place. I would recommend adding a new function that will return templateBaseID (scope + name) and rename variable, arguments (except spec change). I would like to do it in separate PR, so, it will be easier to review.

@sarabala1979 sarabala1979 merged commit cb739a6 into argoproj:master Apr 2, 2020
@alexec alexec mentioned this pull request Apr 6, 2020
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating WorkflowTemplate on a cluster level so all namespace can use it
6 participants