Skip to content

op-node: Fix logging flags with incorrect prefix#5234

Merged
mergify[bot] merged 2 commits intodevelopfrom
jg/fix_flags
Mar 23, 2023
Merged

op-node: Fix logging flags with incorrect prefix#5234
mergify[bot] merged 2 commits intodevelopfrom
jg/fix_flags

Conversation

@trianglesphere
Copy link
Contributor

@trianglesphere trianglesphere commented Mar 22, 2023

Description

During the migration to using shared logging flags in PR #5085 the env var flags for the logging options got messed up for just the op-node. They had an extra underscore between the OP_NODE prefix and the LOG_FLAG value.

TODOs

@trianglesphere trianglesphere requested a review from a team as a code owner March 22, 2023 21:25
@changeset-bot
Copy link

changeset-bot bot commented Mar 22, 2023

⚠️ No Changeset found

Latest commit: 9222202

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Mar 22, 2023

Deploy Preview for opstack-docs ready!

Name Link
🔨 Latest commit 9222202
🔍 Latest deploy log https://app.netlify.com/sites/opstack-docs/deploys/641ca65ee7e36d0008532f3f
😎 Deploy Preview https://deploy-preview-5234--opstack-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #5234 (9222202) into develop (3152615) will decrease coverage by 3.76%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5234      +/-   ##
===========================================
- Coverage    40.35%   36.59%   -3.76%     
===========================================
  Files          372      218     -154     
  Lines        23676    19187    -4489     
  Branches       832        0     -832     
===========================================
- Hits          9555     7022    -2533     
+ Misses       13395    11471    -1924     
+ Partials       726      694      -32     
Flag Coverage Δ
bedrock-go-tests 36.59% <100.00%> (-0.01%) ⬇️
common-ts-tests ?
contracts-bedrock-tests ?
contracts-tests ?
core-utils-tests ?
dtl-tests ?
fault-detector-tests ?
sdk-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
op-node/flags/flags.go 28.57% <100.00%> (ø)

... and 155 files with indirect coverage changes

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

It took me quite a bit of digging to work out why it had to be this way since this looks very much like a no-op. Would be great to add a test to cover this. You may come up with something better but I got to:

func TestCorrectEnvVarPrefix(t *testing.T) {
	for _, flag := range Flags {
		values := reflect.ValueOf(flag)
		envVarValue := values.FieldByName("EnvVar")
		if envVarValue == (reflect.Value{}) {
			t.Errorf("Failed to find EnvVar for flag %v", flag.GetName())
			continue
		}
		envVar := envVarValue.String()
		if envVar[:len("OP_NODE_")] != "OP_NODE_" {
			t.Errorf("Flag %v env var (%v) does not start with OP_NODE_", flag.GetName(), envVar)
		}
		if strings.Contains(envVar, "__") {
			t.Errorf("Flag %v env var (%v) has duplicate underscores", flag.GetName(), envVar)
		}
	}
}

@trianglesphere
Copy link
Contributor Author

@ajsutton I found this after noticing that the flag (as an env var) wasn't working on the internal devnet. I had tested this locally with the flag value. EnvVars are way harder to test because it's not an error to have undefined env vars.

@ajsutton
Copy link
Contributor

@trianglesphere

@ajsutton I found this after noticing that the flag (as an env var) wasn't working on the internal devnet. I had tested this locally with the flag value. EnvVars are way harder to test because it's not an error to have undefined env vars.

We could just skip things with undefined env vars - though currently that test passes with your fix. I've come across a few bugs with our CLI flags so would be good to start improving testing around them even if it's not perfect to start with.

Copy link
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify
Copy link
Contributor

mergify bot commented Mar 23, 2023

This PR has been added to the merge queue, and will be merged soon.

@mergify
Copy link
Contributor

mergify bot commented Mar 23, 2023

This PR is next in line to be merged, and will be merged as soon as checks pass.

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Mar 23, 2023

This PR is next in line to be merged, and will be merged as soon as checks pass.

@mergify mergify bot merged commit 3276f6f into develop Mar 23, 2023
@mergify mergify bot deleted the jg/fix_flags branch March 23, 2023 19:37
@mergify mergify bot removed the on-merge-train label Mar 23, 2023
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.

4 participants