-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update the builder to use a consistent binary name. #5651
Update the builder to use a consistent binary name. #5651
Conversation
cmd/builder/internal/command.go
Outdated
@@ -59,7 +59,7 @@ func Command() (*cobra.Command, error) { | |||
} | |||
|
|||
// the external config file | |||
cmd.Flags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.otelcol-builder.yaml)") | |||
cmd.Flags().StringVar(&cfgFile, "config", "$HOME/.ocb.yaml", "config file (default is $HOME/.ocb.yaml)") |
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.
This is a breaking change right? Is it ok to break this in 1 release or do we need to take a deprecated approach? I'm thinking of situations where users of the ocb are already taking advantage of the default .otelcol-builder.yaml
file and that would stop working when this is released. Could break CICD pipelines.
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.
Yeh, it's a breaking change. We could revert (at the cost of some inconsistency), or we could fall back to .otelcol-builder.yaml
if .ocb.yaml
isn't present.
Medium term, I'm wondering whether it makes sense to take the config file only as an argument, not a flag, but I need to do some more research and learning beforehand so that I can make a good proposal :)
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.
Falling back to .otelcol-builder.yaml
and adding a warning about it being deprecated in the future seems like a safe way to go.
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.
Since we need to add a fallback, what I propose is
- deprecate the required
--config
flag - retain the current
--config
flag implementation for backward compatibility - default to requiring a single argument that is the path to the config file to build
From my perspective, the default $HOME location for config isn't that useful, since the config ought to be under source control. Compulsory options are better expressed as arguments than flags.
I'll push an update later today.
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 am good with this approach, but it does deviate from the collector's ergonomics of passing in configuration via a --config flag.
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.
does deviate from the collector's ergonomics of passing in configuration via a --config flag
Yep, IMHO distinction is that ocb is a compiler that takes a config input and generates a corresponding output, whereas the collector is a long-running service, where it's config is part of the system.
aa1fb56
to
6bd2d58
Compare
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 fixing the inconsistencies! Just a few suggestions, please add an entry to the changelog as well
cmd/builder/internal/command.go
Outdated
@@ -59,7 +59,7 @@ func Command() (*cobra.Command, error) { | |||
} | |||
|
|||
// the external config file | |||
cmd.Flags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.otelcol-builder.yaml)") | |||
cmd.Flags().StringVar(&cfgFile, "config", "$HOME/.ocb.yaml", "config file (default is $HOME/.ocb.yaml)") |
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.
Falling back to .otelcol-builder.yaml
and adding a warning about it being deprecated in the future seems like a safe way to go.
6bd2d58
to
563d003
Compare
Using the flag:
Using the arg:
Using both:
Using none:
If this everyone agrees and this is merged, I'll also update the main website docs on the next release. |
This should not happen. An info or warn-level message should be logged that the default config is being used, not an error with a stack trace. |
This is the standard ocb behavior when the config file isn't found. There's a couple of things I can do here:
|
I verified with release build from github, and there is no code to expand the default So I can revert all the args changes and just make the --config flag required. Alternatively, I can press on and remove the default since there’s no backwards compatibility issue AFAICT. LMK what approach you prefer. |
563d003
to
3bcf6e4
Compare
I was sure it used to work, so I picked an old version (0.45.0) and ran
This means this has not been working since February and we just found out about it. I agree there's no backwards compatibility problem here then. I would be OK with not having a default location for the file, but we should still have a reasonable default configuration, so that the naked command still produces a reasonable binary (like, one with OTLP components). |
cmd/builder/internal/command.go
Outdated
// Since ocb is a compiler, the input file (if present) should | ||
// be the first (and only) command argument. This flag is preserved | ||
// for backwards compatibility with pre-1.0 releases. | ||
if err := cmd.Flags().MarkDeprecated("config", "pass the build configuration as the first argument instead"); err != nil { | ||
panic(err) // Only fails if the usage message is empty, which is a programmer error. | ||
} |
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.
Why this change? Unrelated with PR description and issue. Please fix the PR to only do one thing.
@jpkrohling OK, so I propose to revert all the args changes, and just update the
Since the regression you found, anyone depending on the default would get silently incorrect results. Because the binary that is produced without any configuration doesn't have any components, I think it's better to always require the I can post a follow-up PR that relaxes that and uses the |
Sounds good. |
Update the builder to consistently use "ocb" in the name of the command, version. Since the builder does not expand environment variables in the config file pathname, the default value for `--config` does not work, so we can make this flag required so that users don't silently build an inoperative collector. This fixes open-telemetry#5581. Signed-off-by: James Peach <[email protected]>
3bcf6e4
to
b28413c
Compare
Done, and pushed the change. |
Codecov Report
@@ Coverage Diff @@
## main #5651 +/- ##
=======================================
Coverage 91.53% 91.53%
=======================================
Files 192 192
Lines 11398 11411 +13
=======================================
+ Hits 10433 10445 +12
- Misses 770 771 +1
Partials 195 195
Continue to review full report at Codecov.
|
Description:
Update the builder to consistently use "ocb" in the name of the command,
version and configuration file.
Link to tracking Issue:
This fixes #5581.
Testing:
Manually looked at version output.
Documentation:
None