-
Notifications
You must be signed in to change notification settings - Fork 673
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
MG-2354 - Fix Update Bootstrap Config State #2356
Conversation
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
@nyagamunene why is method |
Changing state does not make much sense anymore from the Bootstrap perspective. I.e. we have a manual option to change Things' state now, and the state has nothing to do with BS configuration. @arvindh123 Please review. |
The reason was that the |
bootstrap/service.go
Outdated
|
||
// Check for existing connection between channel and thing | ||
// If it exists set state to acive | ||
state := Inactive | ||
pm := mgsdk.PageMetadata{} | ||
for _, channel := range cfg.Channels { | ||
tp, err := bs.sdk.ThingsByChannel(channel.ID, pm, token) | ||
if err != nil { | ||
return Config{}, errors.Wrap(svcerr.ErrMalformedEntity, err) | ||
} | ||
for _, thing := range tp.Things { | ||
if thing.ID == cfg.ThingID { | ||
state = Active | ||
break | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyagamunene this will be resolve through a separate endpoint here: #2301. @arvindh123 please confirm
Signed-off-by: nyagamunene <[email protected]>
From the below logs we can see on bootstrap state change , bootstrap service sends connect/disconnect from channel to things service.
The problem happen exactly at Disconnect and Connect handlers in repo where there is wrong query UPDATE configs SET state = $1 WHERE EXISTS ( SELECT 1 FROM connections WHERE config_id = $2 AND channel_id = $3) This query always update all the columns in bootstrap service. |
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What type of PR is this?
This is a bug fix because it fixes the following issue: #2354
What does this do?
It changes how the
ConnectThing
andDisconnectThing
in repo makes the query. It ensure that not all rows are updatedWhich issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Yes, I have included tests for my changes.
Did you document any new/modified feature?
N/A
Notes