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

Config: Add versioning #1671

Merged
merged 11 commits into from
Dec 9, 2024
Merged

Conversation

gbjk
Copy link
Collaborator

@gbjk gbjk commented Oct 10, 2024

Config

  • Add config versioning manager. Motivation:
    • Huobi would like to move futures to coinmargined futures, but we don't want to lose the user's existing config
    • We have a number of places we have deprecated config clutter, and pointers to native types, purely so we can upgrade it.
  • Version1 handles the pairs manager format migration
  • Version2 handles GDAX to Coinbase rename
  • Version3 will handle AssetEnabled, but keeping this initial PR minimal
  • Upgrade configtest to Version2
  • Not upgrading config_example because it would jump over some null changes - I'll handle those in Version4 quickly
  • Add -decrypt and -upgrade to cmd/config, no longer explicitly decrypts, or automatically reverses what was there
  • Add -edit to edit a file in place
  • -in instead of -infile and -out instead of outfile
  • Do not echo input to user when entering encryption key
  • 🐛 Fix encryption keys not allowing spaces
  • This has some light touch improvements to encryption handling. I think I'm going to have to circle back to that separately later.

Note Well: The test failure in TestConfigAllJsonResponse is fixed by the dependency below

Dependencies

Type of change

  • New feature (non-breaking change which adds functionality)

@gbjk gbjk force-pushed the feature/config_version branch from 70797f0 to 3d955f8 Compare October 10, 2024 01:06
@gbjk gbjk self-assigned this Oct 10, 2024
@gbjk gbjk added the review me This pull request is ready for review label Oct 10, 2024
@gbjk gbjk mentioned this pull request Oct 10, 2024
4 tasks
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Good stuff. Will give it a thorough testing next round. Thanks.

cmd/config/config.go Show resolved Hide resolved
cmd/config/config.go Outdated Show resolved Hide resolved
cmd/config/config.go Outdated Show resolved Hide resolved
config/config_test.go Show resolved Hide resolved
config/config_test.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
@gbjk gbjk force-pushed the feature/config_version branch 2 times, most recently from 522cb73 to e8546a6 Compare October 13, 2024 05:34
@gbjk
Copy link
Collaborator Author

gbjk commented Oct 13, 2024

@shazbert I'm done restructuring this.
All versions live in the same package, in separate files.
Stateful representations of types used for state-in-time upgrades live in vN/types.go
Not expecting types for each version. A type that changes a thing can introduce the new representation, and if necessary add the old representation to a previous version as well.

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Nice changes! Thanks for changing the requested. Also just mentioning config_example.json can we now shift that up in line with this versioning system, I see you have commited the configtest.json file.

cmd/config/config.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
cmd/config/config.go Show resolved Hide resolved
config/config.go Show resolved Hide resolved
config/config_test.go Show resolved Hide resolved
@gbjk
Copy link
Collaborator Author

gbjk commented Oct 17, 2024

Nice changes! Thanks for changing the requested. Also just mentioning config_example.json can we now shift that up in line with this versioning system, I see you have commited the configtest.json file.

See PR description 🙂

Not upgrading config_example because it would jump over some null changes - I'll handle those in Version4 quickly

The test config I could upgrade without introducing any new nulls. I know I could fix those, or run a whole instance on it to get them fixed, but I want to use it as a test case for making sure our fully versioned upgrade path handles all the *bool examples

@gbjk gbjk requested a review from shazbert October 19, 2024 10:00
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Thanks sir, just a diff with changes that needs to be added then looks good to go after merge with master. Nice work!

config/config_encryption.go Show resolved Hide resolved
config/config_test.go Show resolved Hide resolved
@gbjk gbjk requested a review from shazbert October 28, 2024 02:39
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Thanks. Nothing else from me.

@gbjk
Copy link
Collaborator Author

gbjk commented Nov 10, 2024

Rebased.

I've dropped out the "upgrade test config" change. I've realised that I should work through moving all of the things that trigger warnings to proper versions first, then it won't even matter. That's pretty trivial but I'll let this land as-is first.
Otherwise we'll get endless conflicts until this is done.

The method to upgrade it is to run config tool with upgrade, then remove anything that would be nulled out.
Which is precisely why I'm not doing it now.

Copy link

codecov bot commented Nov 10, 2024

Codecov Report

Attention: Patch coverage is 68.71166% with 153 lines in your changes missing coverage. Please review.

Project coverage is 37.12%. Comparing base (d4c4bf1) to head (d4eb810).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
cmd/config/config.go 0.00% 93 Missing ⚠️
config/config.go 82.91% 22 Missing and 12 partials ⚠️
config/versions/versions.go 88.18% 10 Missing and 3 partials ⚠️
config/versions/v1.go 72.72% 6 Missing and 3 partials ⚠️
config/config_encryption.go 91.17% 2 Missing and 1 partial ⚠️
config/versions/v2.go 92.30% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1671      +/-   ##
==========================================
+ Coverage   37.04%   37.12%   +0.07%     
==========================================
  Files         414      418       +4     
  Lines      180305   180303       -2     
==========================================
+ Hits        66800    66941     +141     
+ Misses     105657   105497     -160     
- Partials     7848     7865      +17     
Files with missing lines Coverage Δ
common/common.go 93.35% <ø> (ø)
config/versions/v0.go 100.00% <100.00%> (ø)
engine/engine.go 48.89% <100.00%> (ø)
config/versions/v2.go 92.30% <92.30%> (ø)
config/config_encryption.go 85.93% <91.17%> (+3.58%) ⬆️
config/versions/v1.go 72.72% <72.72%> (ø)
config/versions/versions.go 88.18% <88.18%> (ø)
config/config.go 87.09% <82.91%> (+0.05%) ⬆️
cmd/config/config.go 0.00% <0.00%> (-8.63%) ⬇️

... and 26 files with indirect coverage changes

@gbjk gbjk force-pushed the feature/config_version branch from 02b027d to fff95a1 Compare November 11, 2024 01:14
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

I'm excited for config versioning. Just did some light prodding

cmd/config/config.go Outdated Show resolved Hide resolved
cmd/config/config.go Outdated Show resolved Hide resolved
engine/engine.go Outdated Show resolved Hide resolved
config/versions/v0.go Show resolved Hide resolved
@gbjk gbjk requested a review from gloriousCode November 13, 2024 05:12
@gbjk gbjk force-pushed the feature/config_version branch 2 times, most recently from 23abfa0 to 1b498f3 Compare November 18, 2024 07:40
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

Thank you for the latest updates. One main thing I encountered before continuing

config/versions/versions.go Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
config/versions/versions.go Outdated Show resolved Hide resolved
config/versions/versions.go Show resolved Hide resolved
cmd/config/config.go Show resolved Hide resolved
@gbjk gbjk requested a review from shazbert November 26, 2024 03:49
@gbjk gbjk mentioned this pull request Nov 29, 2024
3 tasks
@gloriousCode gloriousCode added the gcrc GloriousCode Review Complete label Dec 1, 2024
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

One nit others are commentary. Nice work!

config/config_encryption.go Outdated Show resolved Hide resolved
cmd/config/config.go Show resolved Hide resolved
config/config.go Show resolved Hide resolved
config/config_encryption.go Show resolved Hide resolved
@gbjk gbjk force-pushed the feature/config_version branch from dbb9635 to 8181ec3 Compare December 2, 2024 03:51
@gbjk gbjk requested a review from shazbert December 2, 2024 03:51
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Ch ACK! Thank you 🖖

@gbjk gbjk mentioned this pull request Dec 4, 2024
3 tasks
@shazbert shazbert added the szrc shazbert review complete label Dec 5, 2024
Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Tested everything and looks to all be good aside from a basic issue. Great work on this feature!

cmd/config/config.go Show resolved Hide resolved
cmd/config/config.go Outdated Show resolved Hide resolved
@gbjk gbjk requested a review from thrasher- December 7, 2024 04:01
@gbjk gbjk force-pushed the feature/config_version branch from c568878 to 82e885c Compare December 7, 2024 08:16
Copy link
Collaborator

@thrasher- thrasher- 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 making those changes! Just some remaining minor consistency issues and then this looks good to go!

config/versions/versions_test.go Outdated Show resolved Hide resolved
config/versions/versions_test.go Outdated Show resolved Hide resolved
config/versions/versions_test.go Outdated Show resolved Hide resolved
config/versions/versions_test.go Outdated Show resolved Hide resolved
config/versions/versions_test.go Outdated Show resolved Hide resolved
gbjk added 11 commits December 9, 2024 10:31
This restructure allows us to share types between versions, avoids
needing to import the versions, and puts the test fixtures in same
package.
It's a win on all fronts
Called from engine before logger is inited, and also just wrong to use
log to communicate with user
Checking the versions at Deploy is much saner.
This simplifies the handling for encryption prompts by moving it to a
field on config, allowing us to simplify all the places were were
passing around config

Also moves password entry to being secure (echo-off)
@gbjk gbjk force-pushed the feature/config_version branch from 6709cf7 to 262c5d3 Compare December 9, 2024 03:31
@gbjk
Copy link
Collaborator Author

gbjk commented Dec 9, 2024

Rebased and squashed following last fixes, which were cosmetic.

Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

tACK, nice work 🚀

@thrasher- thrasher- merged commit 219ed90 into thrasher-corp:master Dec 9, 2024
5 of 11 checks passed
@gbjk gbjk deleted the feature/config_version branch December 9, 2024 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gcrc GloriousCode Review Complete review me This pull request is ready for review szrc shazbert review complete
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants