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

Fix Mentix data cloning bug #1457

Merged
merged 26 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3f08891
Add a site property to explicitly enable health checks
Daniel-WWU-IT Nov 30, 2020
ed873af
Add changelog
Daniel-WWU-IT Nov 30, 2020
1ffc377
Add some more labels to Prometheus targets
Daniel-WWU-IT Dec 1, 2020
83ba2ca
Skip endpoints for BBE if no gRPC port is set
Daniel-WWU-IT Dec 1, 2020
5acfedd
Merge branch 'master-upstream'
Daniel-WWU-IT Dec 2, 2020
e895b9d
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 4, 2021
d67790f
Minor TUS adjustments
Daniel-WWU-IT Jan 4, 2021
b9a5e49
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 14, 2021
bf0b038
Set scheme for Prometheus targets
Daniel-WWU-IT Jan 14, 2021
5fe8350
Add site authorization status support
Daniel-WWU-IT Jan 15, 2021
7ec1186
Persist authorization status
Daniel-WWU-IT Jan 15, 2021
46b2d53
Admin API for site authorization
Daniel-WWU-IT Jan 15, 2021
c3e082e
Update changelog
Daniel-WWU-IT Jan 15, 2021
63836d1
Hound fix
Daniel-WWU-IT Jan 15, 2021
c39ee4f
Hound fix
Daniel-WWU-IT Jan 15, 2021
0fe77e7
Missing error check
Daniel-WWU-IT Jan 15, 2021
990af82
Expose site ID
Daniel-WWU-IT Jan 18, 2021
177b3bf
Update documentation and example
Daniel-WWU-IT Jan 18, 2021
1ed1822
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 18, 2021
5839218
Make GenerateId private
Daniel-WWU-IT Jan 18, 2021
d6a74a2
Fix crash when (un)registering a site
Daniel-WWU-IT Jan 18, 2021
ce8356a
Merge branch 'master-upstream'
Daniel-WWU-IT Jan 19, 2021
dcc9a94
Use site ID field for authorization
Daniel-WWU-IT Jan 19, 2021
10e6c66
Merge branch 'master-upstream'
Daniel-WWU-IT Feb 5, 2021
ea1269d
Fix Mentix data cloning bug
Daniel-WWU-IT Feb 5, 2021
7ab6db2
Fix changelog
Daniel-WWU-IT Feb 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/mentix-clone-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Cloning of internal mesh data lost some values

This update fixes a bug in Mentix that caused some (non-critical) values to be lost during data cloning that happens internally.

https://github.com/cs3org/reva/pull/1457
4 changes: 2 additions & 2 deletions pkg/mentix/connectors/localfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (connector *LocalFileConnector) RetrieveMeshData() (*meshdata.MeshData, err
connector.setSiteTypes(meshData)

meshData.InferMissingData()

return meshData, nil
}

Expand Down Expand Up @@ -145,8 +146,7 @@ func (connector *LocalFileConnector) unmergeData(meshData *meshdata.MeshData, up

func (connector *LocalFileConnector) authorizeData(meshData *meshdata.MeshData, updatedData *meshdata.MeshData, authorize bool) error {
for _, placeholderSite := range updatedData.Sites {
// The site ID is stored in the updated site's name
if site := meshData.FindSite(placeholderSite.Name); site != nil {
if site := meshData.FindSite(placeholderSite.ID); site != nil {
if authorize {
meshdata.SetPropertyValue(&site.Properties, meshdata.PropertyAuthorized, "true")
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mentix/exchangers/importers/adminapi/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func decodeAdminQueryData(data []byte) (*meshdata.MeshData, error) {
if value, ok := jsonData["id"]; ok {
if id, ok := value.(string); ok {
site := &meshdata.Site{}
site.Name = id // Store the provided site ID in the site's name
site.ID = id // We only need to store the ID of the site

meshData := &meshdata.MeshData{Sites: []*meshdata.Site{site}}
return meshData, nil
Expand Down
23 changes: 11 additions & 12 deletions pkg/mentix/meshdata/meshdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
package meshdata

import (
"bytes"
"encoding/gob"
"encoding/json"
"fmt"
"reflect"
"strings"
)

Expand Down Expand Up @@ -196,10 +199,13 @@ func (meshData *MeshData) FromJSON(data string) error {
func (meshData *MeshData) Clone() *MeshData {
clone := &MeshData{}

// To avoid any "deep copy" packages, use JSON en- and decoding instead
data, err := meshData.ToJSON()
if err == nil {
if err := clone.FromJSON(data); err != nil {
// To avoid any "deep copy" packages, use gob en- and decoding instead
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
dec := gob.NewDecoder(&buf)

if err := enc.Encode(meshData); err == nil {
if err := dec.Decode(clone); err != nil {
// In case of an error, clear the data
clone.Clear()
}
Expand All @@ -210,14 +216,7 @@ func (meshData *MeshData) Clone() *MeshData {

// Compare checks whether the stored data equals the data of another MeshData object.
func (meshData *MeshData) Compare(other *MeshData) bool {
if other == nil {
return false
}

// To avoid cumbersome comparisons, just compare the JSON-encoded data
json1, _ := meshData.ToJSON()
json2, _ := other.ToJSON()
return json1 == json2
return reflect.DeepEqual(meshData, other)
}

// New returns a new (empty) MeshData object.
Expand Down