Skip to content

Commit

Permalink
K8SPSMDB-937: Fix decoding initialSyncStatus to empty interface
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes committed Jul 11, 2023
1 parent d86fc24 commit e97ed94
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions healthcheck/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package healthcheck

import (
"context"
"encoding/json"

v "github.com/hashicorp/go-version"
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo"
Expand Down Expand Up @@ -111,14 +112,31 @@ func HealthCheckMongodLiveness(client *mgo.Client, startupDelaySeconds int64) (*
// standalone mongod nodes in an unmanaged cluster doesn't need
// to die before they added to a replset
if res.Err().Error() == ErrNoReplsetConfigStr {
return nil, nil
state := mongo.MemberStateUnknown
return &state, nil
}
return nil, errors.Wrap(res.Err(), "get replsetGetStatus response")
}

// this is a workaround to fix decoding of empty interfaces
// https://jira.mongodb.org/browse/GODRIVER-988
rsStatus := ReplSetStatus{}
if err := res.Decode(&rsStatus); err != nil {
return nil, errors.Wrap(err, "get replsetGetStatus response")
tempResult := bson.M{}
err = res.Decode(&tempResult)
if err != nil {
return nil, errors.Wrap(err, "decode replsetGetStatus response")
}

if err == nil {
result, err := json.Marshal(tempResult)
if err != nil {
return nil, errors.Wrap(err, "marshal temp result")
}

err = json.Unmarshal(result, &rsStatus)
if err != nil {
return nil, errors.Wrap(err, "unmarshal temp result")
}
}

oplogRs := OplogRs{}
Expand Down

0 comments on commit e97ed94

Please sign in to comment.