Skip to content

Conversation

@MakarkinSAkvelon
Copy link
Contributor

resolves #24200
This PR add config.g.dart file with standard volumes
Change build.gradle.kts file (changing values in config.g.dart file during execution)


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

Copy link
Contributor

@alexeyinkin alexeyinkin left a comment

Choose a reason for hiding this comment

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

LGTM (internal review) except for a note below.

Copy link
Contributor

@rshamunov rshamunov left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +298 to +316
val lines = file.readLines()
val endOfSlice = lines.indexOfFirst { it.contains("Generated content below") }
if (endOfSlice != -1) {
val oldContent = lines.slice(0 until endOfSlice)
val flagDelete = file.delete()
if (!flagDelete) {
throw kotlin.RuntimeException("Deleting file failed")
}
val sb = kotlin.text.StringBuilder()
val lastLine = oldContent[oldContent.size - 1]
oldContent.forEach {
if (it == lastLine) {
sb.append(it)
} else {
sb.appendLine(it)
}
}
file.writeText(sb.toString())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This Gradle task can be executed in these two cases:

  1. The user has just typed in the command to deploy the system for the first time after checking it out. config.g.dart is as the version-controlled copy. It has the production URLs which developers normally use for their local runs. They are of no meaning to the deployment and must be overwritten. Here the string "Generated content below" is the flag that this script uses to detect that config.g.dart has not been written with the deployment URLs. It then overwrites config.g.dart using dns-name property value. This property value must be provided.
  2. The user is re-deploying the system from the same checked-out directory, so config.g.dart already contains the deployment URLs. The idea was to allow the user to re-run the task without specifying dns-name to use the same value as before. Since config.g.dart now does not contains "Generated content below" line, it will not be overwritten. Handling this case is the only purpose of preserving the content.

If we must accept this fast, then this is the way to go because normally we will only run this once per check-out-and-deploy cycle. This is my guess because I am not an expert in Gradle.

But if we have time to clean this up, I suggest doing so, because:

  1. Seems like we do not support re-running the task. Since "Generated content below" will not be found in the overwritten file, file.delete() will not be called, and so config.g.dart will be appended with new values, which in Dart means duplicate definition of constants, so it will not build.
  2. If we fix this, the very search for a content in the file is an unreliable flag for a need to overwrite it because the content may change for reasons outside of this script. I see the following as more reliable:
  • Always overwrite the file if dns-name property is given. Always skip any writes if dns-name is not given.
  • Always require dns-name and throw if it is not provided.

I personally think that we should require all parameters be given when running the task. I can foresee other configurable options that are deployment-specific:

  • Google Analytics counter ID.
  • Debug flags.

While it is easy to add -Pname=value flags for them to a Gradle task and to write them into config.g.dart, it is increasingly hard to allow omitting any of them.

@damondouglas what do you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

@MakarkinSAkvelon / @alexeyinkin Do we really need a gradle task wrapper to generate the config.g.dart file? What would be the consequences if we do not automate its generation?

Copy link
Contributor

@alexeyinkin alexeyinkin Jan 18, 2023

Choose a reason for hiding this comment

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

I am not an expert in deployment. config.g.dart already generated with Gradle, and this PR just allows this file to pre-exist under some conditions. Given that we are tired of copying config.example.dart to config.g.dart manually, I think this is worthy short-term.

Mid-term I just want something clean and simple, idempotent with respect to command runs, and that will allow me any changes in the version-controlled copy. This currently is not idempotent and requires us to preserve a specific comment in the version-controlled copy.

Whether we should merge this first or go directly with the mid-term goal is not up to me because I do not know the priorities in DevOps.

I also think we also need a diagram of runs, like what starts what, because I am currently lost in this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case we leave this file - config.g.dart - "as-is" Frontend will use the wrong Backend URLs and the playground will not work at all

@MakarkinSAkvelon MakarkinSAkvelon marked this pull request as ready for review January 17, 2023 11:42
@MakarkinSAkvelon
Copy link
Contributor Author

R @damondouglas

Copy link
Contributor

@damondouglas damondouglas left a comment

Choose a reason for hiding this comment

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

@MakarkinSAkvelon see question/comments.

Comment on lines +298 to +316
val lines = file.readLines()
val endOfSlice = lines.indexOfFirst { it.contains("Generated content below") }
if (endOfSlice != -1) {
val oldContent = lines.slice(0 until endOfSlice)
val flagDelete = file.delete()
if (!flagDelete) {
throw kotlin.RuntimeException("Deleting file failed")
}
val sb = kotlin.text.StringBuilder()
val lastLine = oldContent[oldContent.size - 1]
oldContent.forEach {
if (it == lastLine) {
sb.append(it)
} else {
sb.appendLine(it)
}
}
file.writeText(sb.toString())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@MakarkinSAkvelon / @alexeyinkin Do we really need a gradle task wrapper to generate the config.g.dart file? What would be the consequences if we do not automate its generation?

@alexeyinkin
Copy link
Contributor

config.g.dart is deleted here instead:

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.

[Task]: Version-control the default config.g.dart

4 participants