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

EVG-15206: Add CommitQueue to parser project #5085

Merged
merged 6 commits into from
Oct 13, 2021

Conversation

hadjri
Copy link
Contributor

@hadjri hadjri commented Oct 7, 2021

EVG-15206

Description

Parser project struct has been updated to support commit queue configs in the yaml structure and all relevant places where properties are checked on the commit queue configs for a given project will now be checking a merged project ref struct with any necessary overriding properties from the parser project.

@hadjri hadjri marked this pull request as ready for review October 7, 2021 11:23
@hadjri hadjri requested a review from ablack12 October 7, 2021 11:23
Copy link
Contributor

@ablack12 ablack12 left a comment

Choose a reason for hiding this comment

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

This is coming up more and more; I'm leaning towards incorporating it into FindMergedProjectRef. (But I get if we want to do that at the end; should maybe make a ticket for it though)

model/project.go Outdated
@@ -66,7 +66,8 @@ type Project struct {
// The below fields can be set for the ProjectRef struct on the project page, or in the project config yaml.
// Values for the below fields set on this struct when TranslateProject is called for the project parser will
// take precedence over the project page and will be the configs used for a given project during runtime.
DeactivatePrevious bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"`
DeactivatePrevious bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"`
CommitQueue *CommitQueueParams `yaml:"commit_queue" bson:"commit_queue"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The benefit of this being a pointer is that we can use omitempty to prevent saving an empty struct.

@@ -89,7 +89,8 @@ type ParserProject struct {
// The below fields can be set for the ProjectRef struct on the project page, or in the project config yaml.
// Values for the below fields set on this struct will take precedence over the project page and will
// be the configs used for a given project during runtime.
DeactivatePrevious *bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"`
DeactivatePrevious *bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"`
CommitQueue *CommitQueueParams `yaml:"commit_queue" bson:"commit_queue"`
Copy link
Contributor

Choose a reason for hiding this comment

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

also omitempty

@@ -2131,6 +2138,10 @@ func (p *ProjectRef) CommitQueueIsOn() error {
if p.IsPatchingDisabled() {
catcher.Add(errors.Errorf("patching is disabled for project '%s'", p.Id))
}
err := p.MergeWithParserProject("")
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

can combine in one line if err := ... ; err != nil

@@ -2131,6 +2138,10 @@ func (p *ProjectRef) CommitQueueIsOn() error {
if p.IsPatchingDisabled() {
catcher.Add(errors.Errorf("patching is disabled for project '%s'", p.Id))
}
err := p.MergeWithParserProject("")
if err != nil {
catcher.Add(errors.Wrap(err, "can't merge parser project with project ref"))
Copy link
Contributor

Choose a reason for hiding this comment

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

catcher.Wrapf

@@ -419,6 +419,10 @@ func listCommitQueue(ctx context.Context, client client.Communicator, ac *legacy
if err != nil {
return errors.Wrapf(err, "can't find project for queue id '%s'", projectID)
}
err = projectRef.MergeWithParserProject("")
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

combine with 423 (also below)

@@ -690,7 +698,8 @@ func (p *moduleParams) addModule(ac *legacyClient, rc *legacyClient) error {

func showCQMessageForProject(ac *legacyClient, projectID string) {
projectRef, _ := ac.GetProjectRef(projectID)
if projectRef != nil && projectRef.CommitQueue.Message != "" {
err := projectRef.MergeWithParserProject("")
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't combine these checks; MergeWithParserProject will (and rightly should) panic if projectRef is nil

@@ -277,7 +281,8 @@ func (h repoIDPatchHandler) validateBranchesForRepo(ctx context.Context, newRepo
githubCheckIds []string
}{}
for _, p := range mergedRepos {
if !p.IsEnabled() {
err = p.MergeWithParserProject("")
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't actually commit queue; are we allowing overall enabled to also be defined in yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this was mistaken on my end for commit queue enabled check. Reverted.

@@ -235,6 +235,10 @@ func (h *projectIDPatchHandler) Parse(ctx context.Context, r *http.Request) erro
if err != nil {
return errors.Wrap(err, "error finding original project")
}
err = oldProject.MergeWithParserProject("")
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to do this; we use this to determine what the new project ref to be saved to the DB should be, so we'll end up saving project ref values.

@@ -150,6 +150,11 @@ func (uis *UIServer) projectPage(w http.ResponseWriter, r *http.Request) {
CQConflictingRefs := []string{}
githubChecksConflictingRefs := []string{}
for _, ref := range matchingRefs {
err = ref.MergeWithParserProject("")
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to display yaml values on the UI like this

@hadjri
Copy link
Contributor Author

hadjri commented Oct 8, 2021

This is coming up more and more; I'm leaning towards incorporating it into FindMergedProjectRef. (But I get if we want to do that at the end; should maybe make a ticket for it though)

I've thought about it more and I agree - I've created a small 2 point ticket to cover this refactoring to be done next sprint: https://jira.mongodb.org/browse/EVG-15562

@hadjri hadjri requested a review from ablack12 October 8, 2021 09:12
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" {
grip.Info(projectRef.CommitQueue.Message)
if projectRef != nil && projectRef.CommitQueue.Message != "" {
if err := projectRef.MergeWithParserProject(""); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not catching earlier; you can't do this for the CLI; it needs to use rest routes to communicate with Evergreen, i.e. to get the version. GetProjectRef is an example of this. I would modify that function to send over the already merged project.

err := projectRef.MergeWithParserProject("")
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" {
grip.Info(projectRef.CommitQueue.Message)
if projectRef != nil && projectRef.CommitQueue.Message != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

You're moving this anyway but you'd want to look this up even if Message == ""

@hadjri hadjri requested a review from ablack12 October 8, 2021 20:11
@hadjri hadjri merged commit a9f9e0f into evergreen-ci:main Oct 13, 2021
ablack12 added a commit that referenced this pull request Oct 14, 2021
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.

2 participants