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

feat(kv): label names to be unique #15647

Merged
merged 8 commits into from
Oct 31, 2019
Merged

Conversation

dearyhud
Copy link
Contributor

@dearyhud dearyhud commented Oct 29, 2019

Closes #15591

Describe your proposed changes here.

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • [] Rebased/mergeable
  • [] Tests pass
  • [] http/swagger.yml updated (if modified Go structs or API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

@dearyhud dearyhud changed the title Feat/http unique label names feat(kv): label names to be unique Oct 29, 2019
@dearyhud dearyhud force-pushed the feat/http-unique-label-names branch from a3ae35f to e9c8929 Compare October 29, 2019 22:47
@dearyhud dearyhud force-pushed the feat/http-unique-label-names branch from e9c8929 to 018b841 Compare October 29, 2019 22:48
@dearyhud dearyhud marked this pull request as ready for review October 29, 2019 23:08
@dearyhud dearyhud requested a review from a team October 29, 2019 23:08
Copy link
Contributor

@kelwang kelwang left a comment

Choose a reason for hiding this comment

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

looks great

Copy link
Contributor

@jsteenb2 jsteenb2 left a comment

Choose a reason for hiding this comment

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

nice work, have some questions regarding all the string manipulation

@@ -85,7 +92,7 @@ func (s *Service) findLabelByID(ctx context.Context, tx Tx, id influxdb.ID) (*in

func filterLabelsFn(filter influxdb.LabelFilter) func(l *influxdb.Label) bool {
return func(label *influxdb.Label) bool {
return (filter.Name == "" || (filter.Name == label.Name)) &&
return (filter.Name == "" || (strings.EqualFold(filter.Name, label.Name))) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

is this change to maintain this with utf8 chars? what's the motivation behind this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah. our CI linter also seemed to agree with the change.

I had changed things originally to deal w/ finding labels case insensitively like so
strings.ToLower(filter.Name) == strings.ToLower(label.Name) and CI called foul on that use.


l.Name = strings.TrimSpace(l.Name)

if err := s.uniqueLabelName(ctx, tx, l); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

one thing we may want to do here is move the read for unqiueness outside the update. In cloud this would force a TX imagine, which seems like a bad idea for this. Moving this to a separate read before the update seems like a better idea 🤔. Also, why are we trimming white space on line 265? is that a behavior that we share across the kv implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

re: transactions - I'm just leaving a note here since we chatted about this. This is an even larger issue that may not get addressed in this PR. TX is pretty heavily depended on unfortunately for reading/writing to kv buckets.


k := make([]byte, influxdb.IDLength+len(l.Name))
copy(k, orgID)
copy(k[influxdb.IDLength:], []byte(strings.ToLower((l.Name))))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we making names unique case insensitive now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. label names should be unique & case agnostic. the UI currently handles all this stuff. feels like it's eagerly loading the labels and doing the label name validation in the browser...

for this change I added, the casing of the label names in the label bucket shouldn't matter & can be a mix of upper and lower case no problem. this system bucket is going to store the down-cased version of the label name, and we'll be using that to decide if a matching label name string already exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

excellent! still feels like a service concern, not necessarily a store concern 🤷‍♂, not even sure where that fits in here tbh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed

@dearyhud dearyhud force-pushed the feat/http-unique-label-names branch from 6c7dccb to 8bd8e08 Compare October 30, 2019 18:58
Copy link
Contributor

@jsteenb2 jsteenb2 left a comment

Choose a reason for hiding this comment

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

lets roll

@dearyhud dearyhud merged commit 741b64d into master Oct 31, 2019
@mark-rushakoff mark-rushakoff deleted the feat/http-unique-label-names branch April 16, 2020 20: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.

labels should be unique by name
3 participants