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

Remove --mutex network argument for Yarn builds #625

Merged
merged 11 commits into from Nov 7, 2022

Conversation

scherler
Copy link
Contributor

@scherler scherler commented Oct 28, 2022

add profile for yarn 2 which do not support the mutex argunment anymore

Signed-off-by: Thorsten Scherler scherler@gmail.com

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

…nt anymore

Signed-off-by: Thorsten Scherler <scherler@gmail.com>
pom.xml Outdated
<id>yarn2-execution</id>
<activation>
<file>
<exists>.mvn_exec_yarn2</exists>
Copy link
Member

Choose a reason for hiding this comment

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

I guess the same applied for yarn3? (the --mutex flag is a yarn 1 thing right?)

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

I am wondering rather than replicate the entire profile except the argument should the extra argument just be pulled out as a property and referenced?

Then if you want to use yarn2+ you set the argument to empty in your projects <properties>.

@jtnord jtnord changed the title [yarn2] add profile for yarn 2 which do not support the mutex argunme… [yarn2] support yarn2 Oct 28, 2022
@scherler
Copy link
Contributor Author

@jtnord yeah what you recommend is much cleaner, how could I do that?

@jtnord
Copy link
Member

jtnord commented Oct 28, 2022

@jtnord yeah what you recommend is much cleaner, how could I do that?

in the existing profile remove the --mutex blah blah and instead add ${yarn.extraArguments}

then in the top level <properties> add a new property like
<yarn.extraArguments>install --mutex blah blah</yarn.extraArguments> <!-- yarn 1 requires a mutex but this is not supported in yarn2+ yarn2 users can just use install here-->

infact looking at the frontend plugin code... you can remove the setting in both places and just set the property frontend.yarn.arguments to install --mutex with a comment can be set to the empty string or install for yarn2

@NotMyFault NotMyFault changed the title [yarn2] support yarn2 Add support for yarn 2 Oct 30, 2022
…ridden

Signed-off-by: Thorsten Scherler <scherler@gmail.com>
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Commit 7556d86 re-indents the whole file. Do not include unrelated formatting changes in this pull request.

Signed-off-by: Thorsten Scherler <scherler@gmail.com>
@scherler
Copy link
Contributor Author

scherler commented Nov 2, 2022

@basil fix it, sorry about that. @jtnord like this?

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated
<!-- ensure only one concurrent 'yarn install' -->
<!-- when yarn cache is empty, multiple yarns performing network fetches frequently results in opaque errors -->
<arguments>--mutex network</arguments>
<arguments>${yarn.args}</arguments>
Copy link
Member

Choose a reason for hiding this comment

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

frontend-maven-plugin already uses the value of the frontend.yarn.arguments property, if defined, so for consistency I suggest using that same property name rather than yarn.args. That would allow you to delete this <arguments> line (and therefore its parent <configuration>).

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok @basil , the only thing is that we do

 <properties>
    <yarn.version>1.22.19</yarn.version>
  </properties>

So you are suggesting that would now become

 <properties>
    <yarn.version>1.22.19</yarn.version>
    <frontend.yarn.arguments>1.22.19</frontend.yarn.arguments>
  </properties>

I am fine with it, but personally would find it more readable, if we would drop the frontend prefix since it just forces us to remember it. Better like:

 <properties>
    <yarn.version>1.22.19</yarn.version>
    <yarn.arguments>1.22.19</yarn.arguments>
  </properties>

wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

should be clearer now my previously unpublished comments are published, the question remains is what (if anything) should the default be (keep the default as yarn1 or remove it and make users specify it if they use yarn1)

thanks for spotting

Co-authored-by: Basil Crow <me@basilcrow.com>
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

forgot to sumbit my review

pom.xml Outdated
<!-- can be set to the empty string or install for yarn2 -->
<!-- ensure only one concurrent 'yarn install' -->
<!-- when yarn cache is empty, multiple yarns performing network fetches frequently results in opaque errors -->
<yarn.args>---mutex network</yarn.args>
Copy link
Member

Choose a reason for hiding this comment

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

given we now require you to specify the yarn version (the previous release) I think we should just remove the property and the use of it on line 1333.

Then we document that users of yarn1 will need to add a property frontend.yarn.arguments to ---mutex network

@basil removed the node/yarn properties so I think this may well be better suited.
if not and we want to keep the default the property needs to be changed to <frontend.yarn.arguments>---mutex network</frontend.yarn.arguments> <!-- extra arguments needed for yarn --> to match the property of the plugin to make the understanding and override of it easier.

Suggested change
<yarn.args>---mutex network</yarn.args>
<frontend.yarn.arguments>---mutex network</frontend.yarn.arguments> <!-- extra arguments needed for yarn, --mutex network is needed for yarn1, yarn2+ do not need this flag -->

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yarnpkg/yarn#2146 (comment) you can as well create a .yarnrc and add --install.mutex network in case you want it.

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated
<!-- ensure only one concurrent 'yarn install' -->
<!-- when yarn cache is empty, multiple yarns performing network fetches frequently results in opaque errors -->
<arguments>--mutex network</arguments>
<arguments>${yarn.args}</arguments>
Copy link
Member

Choose a reason for hiding this comment

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

should be clearer now my previously unpublished comments are published, the question remains is what (if anything) should the default be (keep the default as yarn1 or remove it and make users specify it if they use yarn1)

@scherler
Copy link
Contributor Author

scherler commented Nov 3, 2022

I personally think that the default behavior should be not adding anything. The mutex option is really a safeguard and I wonder which percent of cases really need these defaults. Further most likely only on the CI build, so you could create a .yarnrc in a pipeline step like echo '--install.mutex network' >> .yarnrc so you really only use it if needed.

@scherler
Copy link
Contributor Author

scherler commented Nov 3, 2022

@basil @jtnord as soon we have reached a decision on whether we want to keep the old default config or we drop it, I can apply the code suggestion from @jtnord

@jtnord
Copy link
Member

jtnord commented Nov 3, 2022

I personally think that the default behavior should be not adding anything.

I would normally be in agreement - however there would appear to be no users of yarn2+ as you are the first to hit the issue, so that would mean everyone using yarn would need to add it. That said that was the approach in setting the yarn versions.

Further most likely only on the CI build, so you could create a .yarnrc in a pipeline step like echo '--install.mutex network' >> .yarnrc so you really only use it if needed.

That would mean that the standard pipeline would need to know you are going to be running yarn1 vs yarn2 or 3 in order to only set it for the legacy case (setting it for yarn2+ should IIUC cause yarn to fail as it does not understand that switch)?

@timja
Copy link
Member

timja commented Nov 3, 2022

I personally think that the default behavior should be not adding anything. The mutex option is really a safeguard and I wonder which percent of cases really need these defaults. Further most likely only on the CI build, so you could create a .yarnrc in a pipeline step like echo '--install.mutex network' >> .yarnrc so you really only use it if needed.

Not needed on ci.jenkins.io which only runs one build at a time on an executor, only needed if someones running internally with multiple executors

@basil
Copy link
Member

basil commented Nov 3, 2022

+1 from me for removing any custom arguments and requiring consumers to specify any such arguments via the <frontend.yarn.arguments> property (if desired), especially if the existing custom argument is only relevant for Yarn 1.x and not needed on ci.jenkins.io anyway.

@scherler
Copy link
Contributor Author

scherler commented Nov 4, 2022

To summarize, I will prepare the PR removing the old defaults but allowing passing arguments. Thanks all!

scherler and others added 2 commits November 4, 2022 08:02
Co-authored-by: James Nord <jtnord@users.noreply.github.com>
Signed-off-by: Thorsten Scherler <scherler@gmail.com>
@scherler
Copy link
Contributor Author

scherler commented Nov 4, 2022

@jtnord @basil @timja if you could validate the last commit, whether it is as we decided?

Signed-off-by: Thorsten Scherler <scherler@gmail.com>
Signed-off-by: Thorsten Scherler <scherler@gmail.com>
pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated
<!-- ensure only one concurrent 'yarn install' -->
<!-- when yarn cache is empty, multiple yarns performing network fetches frequently results in opaque errors -->
<arguments>--mutex network</arguments>
<arguments>${frontend.yarn.arguments}</arguments>
Copy link
Member

Choose a reason for hiding this comment

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

this is the default - you can just remove the entire configuration section (lines 1331 - 1333)

@jtnord jtnord self-requested a review November 4, 2022 12:36
@basil
Copy link
Member

basil commented Nov 4, 2022

As James mentioned a few hours ago, and as I previously wrote in #625 (comment), there is no need to declare an empty property and pass it through to frontend-maven-plugin when frontend-maven-plugin is already defaulting to the same thing, so the property and <configuration> section can be deleted. See also #628, including the description of the Testing done in the last sentence.

Co-authored-by: James Nord <jtnord@users.noreply.github.com>
@scherler
Copy link
Contributor Author

scherler commented Nov 4, 2022

Thank you for the clarification and sorry for being slow, but I think I understand now.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

The whole <configuration> section can be deleted, since it no longer contains any customizations from the upstream default. Did you have a draft of what should be published in the release notes explaining how Yarn 1.x users should adapt to this change?

Signed-off-by: Thorsten Scherler <scherler@gmail.com>
@basil
Copy link
Member

basil commented Nov 7, 2022

Do we have a proposed entry for the release notes that describes the impact this change will have on plugins?

@scherler
Copy link
Contributor Author

scherler commented Nov 7, 2022

@basil for the release note:

Breaking change in yarn. In case you rely on the extra argument --mutex network that has been injected until now, you have to now define a property like <frontend.yarn.arguments>--mutex network</frontend.yarn.arguments>

WDYT?

@basil
Copy link
Member

basil commented Nov 7, 2022

Sounds fine. How has this change been tested? I would expect this change to be tested under two use cases:

  • Ensure that a plugin that relied on --mutex network still gets that setting plumbed through to Yarn when upgrading to the POM from this PR and defining the <frontend.yarn.arguments>--mutex network</frontend.yarn.arguments> property (i.e. no regression has occurred for existing use cases)
  • That a plugin that wishes to use Yarn 2 can use it when upgrading to the POM from this PR and defining yarn.version to a 2.x version (i.e., the new use case is supported)

@scherler
Copy link
Contributor Author

scherler commented Nov 7, 2022

How can I provide these test cases?

@basil
Copy link
Member

basil commented Nov 7, 2022

I would run mvn clean install -Dinvoker.skip, then find a plugin that uses Yarn 1.x and relies on --mutex network, update its plugin parent POM to 4.50-SNAPSHOT, add <frontend.yarn.arguments>--mutex network</frontend.yarn.arguments>, then verify that the argument is still getting plumbed through to Yarn. Then I would find a plugin where Yarn 2.x is desired, update its plugin parent POM to 4.50-SNAPSHOT, update yarn.version to a 2.x version, and verify that Yarn 2.x is successfully invoked when running mvn clean verify.

@scherler
Copy link
Contributor Author

scherler commented Nov 7, 2022

image
jenkinsci/design-library-plugin#158 is passing with your instructions now on my local system and I have pushed but I would imagine that the build will fail. Before the build failed locally due to the --mutex problem. Adding the arguments make it fails again
image

@scherler
Copy link
Contributor Author

scherler commented Nov 7, 2022

I first used yarn.arguments and that passes since it is not frontend.yarn.arguments. IMHO the first makes more sense on an user perspective. ...or you should use frontend.yarn.version as well.

@basil basil added breaking and removed enhancement labels Nov 7, 2022
@basil basil changed the title Add support for yarn 2 Remove --mutex networ argument for Yarn builds Nov 7, 2022
@basil basil changed the title Remove --mutex networ argument for Yarn builds Remove --mutex network argument for Yarn builds Nov 7, 2022
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I will try to do a release of this tomorrow once the this week's weekly release is out.

@basil basil merged commit 0140be6 into jenkinsci:master Nov 7, 2022
@scherler
Copy link
Contributor Author

scherler commented Nov 7, 2022

@basil thanks for your big help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants