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

[BC] CreateMode: refactor and fix FlagX Create flags. #136

Merged
merged 5 commits into from
Jul 4, 2024
Merged

Conversation

jeffbean
Copy link

BREAKING Client behavior: since this proposes a new parsing of the Create flag integer this will break clients if they rely on CreateContainer as it was creating znodes that may not have been containers.

Changes:

  • Fix FlagTTL value from 4 -> 5
  • Adding all known CreateMode values to Flag constants.
  • Adding a createMode private struct behind the flag integer, replicate CreateMode from ZK java lib.
  • Create, CreateContainer, CreateTTL methods now parse the flag integer passed in based on the constants defined (new error condition).
  • Rewrite tests to better catch CreateContainer and CreateTTL (no assertions on zk behavior since zk does not expose znode mode)
  • Added Change-Detector unit tests for create mode values.

Copy link

codecov bot commented May 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.50%. Comparing base (6131812) to head (b61590a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
+ Coverage   77.98%   78.50%   +0.51%     
==========================================
  Files           7        8       +1     
  Lines        1322     1349      +27     
==========================================
+ Hits         1031     1059      +28     
  Misses        199      199              
+ Partials       92       91       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jeffbean jeffbean self-assigned this May 12, 2024
@jeffbean jeffbean requested review from echohead and alxn May 12, 2024 18:45
@jeffbean
Copy link
Author

Based on the PR #125 that shows the issue at hand. The bug was in the CreateContainer and CreateTTL methods.

@jeffbean jeffbean linked an issue May 12, 2024 that may be closed by this pull request
jeffbean added 3 commits June 2, 2024 11:21
…eate flags

BREAKING Client behavior: since this proposes a new parsing of the Create flag integer this will break clients if they rely on CreateContainer as it was creating znodes that may not have been containers.

Changes:
- Fix FlagTTL value from 4 -> 5
- Adding all known CreateMode values to Flag constants.
- Adding a createMode private struct behind the flag integer, replicate CreateMode from ZK java lib.
- Create, CreateContainer, CreateTTL methods now parse the flag integer passed in based on the constants defined.
- Rewrite tests to better catch CreateContainer and CreateTTL (no assertions on zk behavior since zk does not expose znode mode)
- Added Change-Detector unit tests for create mode values.
note this commit shows the fact we don't need CreateContainer as a method, its an argument to Create. TTL is still needed from having a different payload, but later could be logic in Create based on the CreateMode we are given.
conn.go Outdated Show resolved Hide resolved
create_mode.go Outdated Show resolved Hide resolved
create_mode.go Show resolved Hide resolved
create_mode.go Show resolved Hide resolved
create_mode.go Outdated Show resolved Hide resolved
zk_test.go Show resolved Hide resolved
zk_test.go Show resolved Hide resolved
zk_test.go Show resolved Hide resolved
conn.go Outdated Show resolved Hide resolved
@jeffbean
Copy link
Author

jeffbean commented Jul 4, 2024

For others that may face new errors:

	path, err := c.CreateContainer("/container-node", []byte("foo"), zk.FlagTTL, zk.WorldACL(zk.PermAll))
	if err != nil {
		log.Fatal(err)
	}
// old: would not error, and create a Container znode
// new: will return an error that this is not a TTL operation and not create a znode

@jeffbean jeffbean merged commit 6585b41 into master Jul 4, 2024
10 checks passed
@jeffbean jeffbean deleted the create_mode branch July 4, 2024 16:29
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.

Create TTL Node shows invalid arguments
2 participants