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

ModifyInternalDataGroupRecords won't update Big-IP records when records list is empty #90

Open
svetlinas opened this issue Feb 13, 2019 · 2 comments

Comments

@svetlinas
Copy link

While using bigip.ModifyInternalDataGroupRecords() we encountered a possible issue.
The steps to reproduce it are as follows:

  • There is only 1 record in a data group left;
  • Executing ModifyInternalDataGroupRecords() with an empty slice results with success;
  • Going to BIG-IP instance to check, the record is still there. For the BIG-IP system nothing is changed.

Reading the code and looking more specifically over the DataGroupRecord to dataGroupDTO structs, the Records field tag in dataGroupDTO is json:"records,omitempty". This leads to the behaviour described above. When passing empty/nil slice, the omitempty tag will remove the object from the json send to the BIG-IP system.

We are thinking of 2 possible solutions.

  • Removing the omitempty tag
    This will quickly solve the issue. As seen in the code, the ModifyInternalDataGroupRecords() function is the only one modifying the DataGroupRecord resource. However, if another modifying function is introduced in the future, this removed tag, can lead to overwritten data group records in BIG-IP.
  • Distinguishing between nil slice records and empty slice records
    This leads to modifying the marshal() function and adding case for nil/empty slices. The downside of this approach is that distinguishing between empty and nil slice is a bad practise by a lot of clean code guides.

Please feel free to share your opinion and guidance how we can handle this behaviour. Whatever is decided, we can contribute it.

@stoyanr
Copy link

stoyanr commented Feb 15, 2019

Hi @scottdware, do you have any comments here? We will contribute the fix, we would just like to have some thoughts from you what would you consider a good fix. Thanks!

@scottdware
Copy link
Owner

@svetlinas @stoyanr I'm good with either option you want to submit. The first choice seems to be the simplest way to accomplish this. Go ahead and submit a PR and I'll merge it when it comes in.

Thanks!

marsu-p pushed a commit to marsu-p/go-bigip that referenced this issue Jul 12, 2024
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

No branches or pull requests

3 participants