Skip to content

feat(pricing): add -pricingUnitSize flag, deprecate -pixelsPerUnit - #3942

Open
rickstaa wants to merge 3 commits into
masterfrom
rs/deprecate-pixelsperunit-flag
Open

feat(pricing): add -pricingUnitSize flag, deprecate -pixelsPerUnit#3942
rickstaa wants to merge 3 commits into
masterfrom
rs/deprecate-pixelsperunit-flag

Conversation

@rickstaa

@rickstaa rickstaa commented Jun 9, 2026

Copy link
Copy Markdown
Member

What

pixelsPerUnit is really just a pricing scale factor: it's the number of work units that one quoted price covers (price_per_work_unit = pricePerUnit / pixelsPerUnit). The "pixels" name is transcoding-era legacy and is confusing for non-video / BYOC / general-runner workloads, where there are no pixels.

This adds -pricingUnitSize as the clearer primary flag and keeps -pixelsPerUnit as a deprecated alias writing to the same config value, following the existing datadir/dataDir deprecation pattern.

Why pricingUnitSize?

The value is the size of one pricing unit, measured in work units: pricePerUnit is the price for pricingUnitSize work units, so price_per_work_unit = pricePerUnit / pricingUnitSize.

  • "size" (vs "scale") makes the direction unambiguous: a larger value means a bigger bucket, i.e. coarser price granularity.
  • The "pricing" qualifier keeps the flag self-documenting in isolation (config files, run commands) where the neighbouring price flags aren't visible.
  • It reads as a matched set with pricePerUnit / maxPricePerUnit, all rooted in pric-.
  • Avoids the "unit of price" (currency-denomination) misread that priceUnitSize invites, and the doubled-"unit" confusion of workUnitsPerUnit.

Changes

  • -pricingUnitSize flag (primary) + -pixelsPerUnit kept as a [Deprecated] alias to the same cfg.PixelsPerUnit.
  • Updated -pricePerUnit / -maxPricePerUnit help text to reference pricingUnitSize.
  • Added a unit test asserting both flags set PixelsPerUnit.

Compatibility

No wire or config-format changes. The proto field (PriceInfo.pixelsPerUnit), the config struct field, discovery JSON, and the pixels_per_unit / pixelsperunit keys in -maxPricePerCapability / -pricePerGateway JSON are all untouched, so existing clients and deployments keep working. Only the user-facing flag is renamed, with the old name still accepted.

A follow-up could rename the proto/JSON field in a coordinated, versioned way, but that is intentionally out of scope here to avoid breaking clients.

Summary by CodeRabbit

Summary

  • New Features

    • Added a -pricingUnitSize command-line flag to configure work-unit pricing scale (mapped to the existing per-unit pricing configuration).
  • Documentation

    • Updated per-unit pricing flag help text to use “work units” terminology.
    • Marked -pixelsPerUnit as deprecated and clarified it aliases -pricingUnitSize.
  • Tests

    • Added coverage to verify default PixelsPerUnit behavior, -pricingUnitSize parsing, and backward compatibility with -pixelsPerUnit.
  • Chores

    • Updated the pending changelog entry for the Orchestrator section.

Checklist:

@github-actions github-actions Bot added the go Pull requests that update Go code label Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR renames the CLI pricing scale flag from pixelsPerUnit to pricingUnitSize (marking the old name as deprecated) and updates help text to describe pricing in terms of work units. A test verifies both flag names correctly populate the underlying configuration field.

Changes

Pricing Unit Size Flag Aliasing

Layer / File(s) Summary
Pricing unit size flag definition and help text updates
cmd/livepeer/starter/flags.go
The maxPricePerUnit help text is updated to reference work units, and -pricingUnitSize is introduced as the primary flag with -pixelsPerUnit retained as a deprecated alias; both set the same PixelsPerUnit config field.
Flag parsing test
cmd/livepeer/starter/starter_test.go
TestNewLivepeerConfig_UnitSizeFlag verifies that -pricingUnitSize and the deprecated -pixelsPerUnit flag both correctly parse into cfg.PixelsPerUnit.
Changelog entry
CHANGELOG_PENDING.md
Changelog documents the addition of -pricingUnitSize flag and deprecation of -pixelsPerUnit.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

🐰 A flag renamed with care so fine,
Old pixelsPerUnit steps aside,
While pricingUnitSize takes the line—
Both aliases work side by side!
Work units now bloom in the help text wide. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new -pricingUnitSize flag and deprecating the old -pixelsPerUnit flag, which is the primary focus of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rs/deprecate-pixelsperunit-flag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rickstaa
rickstaa force-pushed the rs/deprecate-pixelsperunit-flag branch from ca923a0 to cf8e7c8 Compare June 9, 2026 10:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/livepeer/starter/starter_test.go (1)

403-417: ⚡ Quick win

Add a precedence case when both flags are passed.

This test is solid for one-flag inputs; add a case with both -unitScale and -pixelsPerUnit in the same parse to lock expected precedence behavior.

Proposed test extension
 func TestNewLivepeerConfig_UnitScaleFlag(t *testing.T) {
 	require := require.New(t)

 	// -unitScale sets PixelsPerUnit.
 	fs := flag.NewFlagSet("livepeer-test", flag.ContinueOnError)
 	cfg := NewLivepeerConfig(fs)
 	require.NoError(fs.Parse([]string{"-unitScale", "1000000000000"}))
 	require.Equal("1000000000000", *cfg.PixelsPerUnit)

 	// -pixelsPerUnit is a deprecated alias for the same value.
 	fs = flag.NewFlagSet("livepeer-test", flag.ContinueOnError)
 	cfg = NewLivepeerConfig(fs)
 	require.NoError(fs.Parse([]string{"-pixelsPerUnit", "42"}))
 	require.Equal("42", *cfg.PixelsPerUnit)
+
+	// If both are present, last one wins (Go flag parse order).
+	fs = flag.NewFlagSet("livepeer-test", flag.ContinueOnError)
+	cfg = NewLivepeerConfig(fs)
+	require.NoError(fs.Parse([]string{"-unitScale", "10", "-pixelsPerUnit", "20"}))
+	require.Equal("20", *cfg.PixelsPerUnit)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/livepeer/starter/starter_test.go` around lines 403 - 417, Add a
precedence test inside TestNewLivepeerConfig_UnitScaleFlag that parses both
flags together to lock expected behavior: call fs.Parse with both
"-pixelsPerUnit" and "-unitScale" (e.g.
[]string{"-pixelsPerUnit","42","-unitScale","1000000000000"}) on a
NewLivepeerConfig(fs) and assert cfg.PixelsPerUnit equals the value for
-unitScale (the newer flag), and optionally repeat with the flags reversed to
ensure order-independent precedence; reference NewLivepeerConfig and
cfg.PixelsPerUnit when locating where to add the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/livepeer/starter/flags.go`:
- Around line 106-109: Update the runtime validation and log messages in
cmd/livepeer/starter/starter.go to use the new primary flag name "-unitScale"
(and mention "-pixelsPerUnit" only as deprecated) and to say "price per unit"
(or "work unit") instead of "price per pixel"; locate the checks and log/error
strings that reference cfg.PixelsPerUnit, "-pixelsPerUnit", or "price per pixel"
and change their wording to prefer "-unitScale" and "price per unit" so users
setting -unitScale see correct guidance.

---

Nitpick comments:
In `@cmd/livepeer/starter/starter_test.go`:
- Around line 403-417: Add a precedence test inside
TestNewLivepeerConfig_UnitScaleFlag that parses both flags together to lock
expected behavior: call fs.Parse with both "-pixelsPerUnit" and "-unitScale"
(e.g. []string{"-pixelsPerUnit","42","-unitScale","1000000000000"}) on a
NewLivepeerConfig(fs) and assert cfg.PixelsPerUnit equals the value for
-unitScale (the newer flag), and optionally repeat with the flags reversed to
ensure order-independent precedence; reference NewLivepeerConfig and
cfg.PixelsPerUnit when locating where to add the assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e411cba-2c9d-4c68-a712-d278132ad85d

📥 Commits

Reviewing files that changed from the base of the PR and between e628b9c and ca923a0.

📒 Files selected for processing (2)
  • cmd/livepeer/starter/flags.go
  • cmd/livepeer/starter/starter_test.go

Comment thread cmd/livepeer/starter/flags.go Outdated
`pixelsPerUnit` is really just a pricing scale factor: price is quoted per N
work units (`price_per_work_unit = pricePerUnit / pixelsPerUnit`). The "pixels"
name is transcoding-era legacy and is confusing for non-video / BYOC runners,
where there are no pixels.

Add `-unitScale` as the clearer primary flag and keep `-pixelsPerUnit` as a
deprecated alias writing to the same config (following the datadir/dataDir
pattern). Update the pricePerUnit/maxPricePerUnit help text to reference
unitScale.

No wire or config-format changes: the proto field and the config struct are
untouched, so existing clients, discovery JSON, and configs keep working. Only
the user-facing flag is renamed, with the old name still accepted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rickstaa
rickstaa force-pushed the rs/deprecate-pixelsperunit-flag branch from cf8e7c8 to daa6847 Compare June 9, 2026 10:26
@rickstaa
rickstaa requested a review from j0sh June 9, 2026 10:39
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 33.29223%. Comparing base (e628b9c) to head (95a1d2e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #3942         +/-   ##
===================================================
- Coverage   33.30014%   33.29223%   -0.00791%     
===================================================
  Files            171         171                 
  Lines          42174       42175          +1     
===================================================
- Hits           14044       14041          -3     
- Misses         27077       27080          +3     
- Partials        1053        1054          +1     
Files with missing lines Coverage Δ
cmd/livepeer/starter/flags.go 87.40741% <100.00000%> (+0.09398%) ⬆️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e628b9c...95a1d2e. Read the comment docs.

Files with missing lines Coverage Δ
cmd/livepeer/starter/flags.go 87.40741% <100.00000%> (+0.09398%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pricingUnitSize reads as the size of one pricing unit (in work units),
which parallels pricePerUnit and makes the direction unambiguous (larger
= coarser granularity). The "pricing" qualifier keeps the flag
self-documenting in isolation (config files, run commands) where the
neighboring price flags aren't visible, and avoids the "unit of price"
misread of priceUnitSize.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rickstaa
rickstaa force-pushed the rs/deprecate-pixelsperunit-flag branch from cee0907 to 91b0432 Compare June 15, 2026 11:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/livepeer/starter/starter_test.go (1)

403-423: ⚡ Quick win

Add a combined-flags precedence test to lock expected behavior.

Please add one case parsing both -unitSize and -pixelsPerUnit in the same argv and assert which one should win (typically last occurrence). This prevents ambiguity regressions while both names coexist.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/livepeer/starter/starter_test.go` around lines 403 - 423, Add a new test
case to the TestNewLivepeerConfig_UnitSizeFlag function that parses both the
-unitSize and -pixelsPerUnit flags together in the same argv to test flag
precedence behavior. Create a new FlagSet, initialize NewLivepeerConfig with it,
parse a slice containing both flags (in the order that determines which should
take precedence, typically with one appearing last), and then assert that
PixelsPerUnit equals the value of the flag that should win according to the
expected precedence rules. This locks in the intended behavior when both flags
are provided simultaneously.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/livepeer/starter/starter_test.go`:
- Around line 403-423: Add a new test case to the
TestNewLivepeerConfig_UnitSizeFlag function that parses both the -unitSize and
-pixelsPerUnit flags together in the same argv to test flag precedence behavior.
Create a new FlagSet, initialize NewLivepeerConfig with it, parse a slice
containing both flags (in the order that determines which should take
precedence, typically with one appearing last), and then assert that
PixelsPerUnit equals the value of the flag that should win according to the
expected precedence rules. This locks in the intended behavior when both flags
are provided simultaneously.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6188c9a5-42d0-46d2-b7e2-fc7f518bd63b

📥 Commits

Reviewing files that changed from the base of the PR and between daa6847 and cee0907.

📒 Files selected for processing (2)
  • cmd/livepeer/starter/flags.go
  • cmd/livepeer/starter/starter_test.go

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

ENG-113

ENG-111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant