-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: add PreservedBranches config for branchcleaner to preserve branches #23735
feat: add PreservedBranches config for branchcleaner to preserve branches #23735
Conversation
Welcome @Colstuwjx! |
Hi @Colstuwjx. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
One concern is that the PR implements a global set of branches, but branch names are per-repo entities, so I think this config should allow per-repo (and possibly per-org) configuration.
OK, I'll change it. |
I've change to |
@petr-muller Could you help me clarify the CI issue, I don't know how to fix the bazel issue... |
Looks like a bunch of generated content needs to be updated:
|
Yes, I've been tried to fix it, but it seems doesn't work:
|
Update: I've been installed python27 on macOS, and alias it with
I have no idea about how to fix this issue.. |
Hi @petr-muller Thanks for your reminder, I've met issue protobuf 5376 and I've fixed it. Now it's ready for review, PTAL! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last thing, then I think this looks good!
@petr-muller Updated! PTAL! |
/cc @cjwagner @stevekuznetsov Could you help me review this PR? Many thanks!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but please also update the PluginHelp information for the plugin now that it is configurable.
prow/plugins/config.go
Outdated
if _, existsRepo := b.PreservedBranches[fullRepoName]; existsRepo { | ||
for _, pb := range b.PreservedBranches[fullRepoName] { | ||
if branch == pb { | ||
return true | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Go makes it safe to iterate over nil slices. So both of the repo check and the org check can drop the outer conditional.
if _, existsRepo := b.PreservedBranches[fullRepoName]; existsRepo { | |
for _, pb := range b.PreservedBranches[fullRepoName] { | |
if branch == pb { | |
return true | |
} | |
} | |
} | |
for _, pb := range b.PreservedBranches[fullRepoName] { | |
if branch == pb { | |
return true | |
} | |
} |
@@ -41,26 +41,31 @@ func helpProvider(config *plugins.Configuration, _ []config.OrgRepo) (*pluginhel | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the helpProvider
to include include Config
now that this plugin has configurable behavior. e.g.
and consider adding the YAML config snippet like this:
test-infra/prow/plugins/retitle/retitle.go
Lines 54 to 61 in f7e21a3
yamlSnippet, err := plugins.CommentMap.GenYaml(&plugins.Configuration{ | |
Retitle: plugins.Retitle{ | |
AllowClosedIssues: true, | |
}, | |
}) | |
if err != nil { | |
logrus.WithError(err).Warnf("cannot generate comments for %s plugin", pluginName) | |
} |
Full details about
PluginHelp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation. I've been tried to change the plugin helper content, but I found the prow/plugins/plugin-config-documented.yaml
didn't change.
What's more, I have two confusions after you clarified the plugin help:
- BranchCleaner is a passive plugin and don't give comment command, rather than
lgtm
orretitle
, and I'm confused about how it could be configured, there are two styles of configuration formats:
# format 1
triggers:
- repos:
- org_a
- repos:
- org_a/repo_a1
only_org_members: true
# format 2
plugins:
org_a:
plugins:
- approve # Allow OWNERS to /approve
We can see, format 1 is static config, and it could set different config options for each org/repo set. And format 2 is a list of plugins, and each org/repo has a list of configured plugins with their config options. In format 2, it seems a little-bit redundant if we set map[repo]config inside the list, e.g.
plugins:
org_a:
plugins:
- branch_cleaner:
preserved_branches:
"org_a": ["master"]
"org_a/repo_a1": ["master"]
The nested configuration looks so bad, right? I'm wondering if we need to change the config.BranchCleaner
config struct, and turn to use format 1. I'm also confused about these two formats, which one is suitable to BranchCleaner
such plugin, why?
- As I mentioned, I've been tried
UPDATE=true go test ./prow/plugins/... -run TestGenYamlDocs
and the yaml content didn't change. So what's the process to update and plugin helper and its document yaml ? Besides the annotations you given, I can't find any document about this process :(
Could you help me clarify these confusions?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been tried to change the plugin helper content, but I found the
prow/plugins/plugin-config-documented.yaml
didn't change.
It is not expected to, that file is generated based on an empty plugins.Configuration
struct and doesn't involve PluginHelp.
PluginHelp information is displayed via Prow's front end. Try clicking on the "Details" button for the "Approve" plugin card on this page to see an example of the configuration section and the example snippet section. https://prow.k8s.io/plugins?repo=kubernetes%2Ftest-infra Notice that the configuration section depends on the repo selected, but the snippet is just a static example.
- BranchCleaner is a passive plugin and don't give comment command, rather than
lgtm
orretitle
, and I'm confused about how it could be configured, there are two styles of configuration formats
Passive plugins can have configuration, the addition you made to the plugins.Configuration
struct is exactly what I'm talking about. The configuration format you already added looks good and is consistent with other plugin configurations, so no need to change it.
# branches in this allow map would be exempt from branch gc | ||
# even if the branches are already merged into the target branch | ||
preserved_branches: | ||
"": null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Populating the PluginHelp.Snippet
field as I mentioned in the other comment will result in a commented version of the YAML config like this, but with the currently configured values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was confusing and not quite accurate. I didn't mean to suggest that this file would update, just that the commented config snippet would look similar to this due to being generated with the same mechanism. I was wrong about the config snippet showing the currently configured values, it should just be a static example config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the PluginHelp info!
# branches in this allow map would be exempt from branch gc | ||
# even if the branches are already merged into the target branch | ||
preserved_branches: | ||
"": null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was confusing and not quite accurate. I didn't mean to suggest that this file would update, just that the commented config snippet would look similar to this due to being generated with the same mechanism. I was wrong about the config snippet showing the currently configured values, it should just be a static example config.
@@ -41,26 +41,31 @@ func helpProvider(config *plugins.Configuration, _ []config.OrgRepo) (*pluginhel | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been tried to change the plugin helper content, but I found the
prow/plugins/plugin-config-documented.yaml
didn't change.
It is not expected to, that file is generated based on an empty plugins.Configuration
struct and doesn't involve PluginHelp.
PluginHelp information is displayed via Prow's front end. Try clicking on the "Details" button for the "Approve" plugin card on this page to see an example of the configuration section and the example snippet section. https://prow.k8s.io/plugins?repo=kubernetes%2Ftest-infra Notice that the configuration section depends on the repo selected, but the snippet is just a static example.
- BranchCleaner is a passive plugin and don't give comment command, rather than
lgtm
orretitle
, and I'm confused about how it could be configured, there are two styles of configuration formats
Passive plugins can have configuration, the addition you made to the plugins.Configuration
struct is exactly what I'm talking about. The configuration format you already added looks good and is consistent with other plugin configurations, so no need to change it.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cjwagner, Colstuwjx, petr-muller 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 |
Fixed #23732.