Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Removed the GTID field from the GaleraState struct
Browse files Browse the repository at this point in the history
As we're still not sure what to do on the operator side with the GTID we decided to not export it in the `GaleraState`. It would also force us to import the `GaleraState` struct to the operator repository so we chose to just not export it for the moment instead.

https://mariadb-operator.slack.com/archives/C056RAECH0W/p1699990598511999?thread_ts=1699350363.009529&cid=C056RAECH0W
  • Loading branch information
Matthieu` committed Nov 15, 2023
1 parent b1f9ef6 commit 7c9c00d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 5 additions & 9 deletions pkg/galera/galera.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type GaleraState struct {
Version string `json:"version"`
UUID string `json:"uuid"`
Seqno int `json:"seqno"`
GTID *GTID `json:"gtid"`
SafeToBootstrap bool `json:"safeToBootstrap"`
}

Expand Down Expand Up @@ -74,14 +73,13 @@ func (g *GaleraState) MarshalText() ([]byte, error) {
}
tpl := createTpl("grastate.dat", `version: {{ .Version }}
uuid: {{ .UUID }}
seqno: {{ .Seqno }}{{ if .GTID }},{{ .GTID }}{{ end }}
seqno: {{ .Seqno }}
safe_to_bootstrap: {{ .SafeToBootstrap }}`)
buf := new(bytes.Buffer)
err := tpl.Execute(buf, tplOpts{
Version: g.Version,
UUID: g.UUID,
Seqno: g.Seqno,
GTID: g.GTID,
SafeToBootstrap: func() int {
if g.SafeToBootstrap {
return 1
Expand Down Expand Up @@ -125,15 +123,17 @@ func (g *GaleraState) UnmarshalText(text []byte) error {
uuid = &value
case "seqno":
// When the `wsrep_gtid_mode` is set to `ON`, the `seqno` is
// actually a string of the form `seqno,gtid`.
// actually a string of the form `<seqno>,<gtid>`.
//
// For the moment we only care about the `seqno` part as we're
// still not sure about what to do with the `gtid`.
seqnoStr, gtidStr, found := strings.Cut(value, ",")
if found {
gtid = &GTID{}
err := gtid.UnmarshalText([]byte(gtidStr))
if err != nil {
return fmt.Errorf("error parsing gtid: %v", err)
}

}
i, err := strconv.Atoi(seqnoStr)
if err != nil {
Expand All @@ -158,10 +158,6 @@ func (g *GaleraState) UnmarshalText(text []byte) error {
g.Version = *version
g.UUID = *uuid
g.Seqno = *seqno
// Only set the GTID if it was found in the file.
if gtid != nil {
g.GTID = gtid
}
g.SafeToBootstrap = *safeToBootstrap
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/galera/galera_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ safe_to_bootstrap: 0`,
Version: "2.1",
UUID: "05f061bd-02a3-11ee-857c-aa370ff6666b",
Seqno: 1,
GTID: &GTID{DomainID: 0, ServerID: 1, SequenceNumber: 2},
SafeToBootstrap: true,
},
want: `version: 2.1
uuid: 05f061bd-02a3-11ee-857c-aa370ff6666b
seqno: 1,0-1-2
seqno: 1
safe_to_bootstrap: 1`,
wantErr: false,
},
Expand Down Expand Up @@ -242,7 +241,6 @@ safe_to_bootstrap: 1`),
Version: "2.1",
UUID: "05f061bd-02a3-11ee-857c-aa370ff6666b",
Seqno: 1,
GTID: &GTID{DomainID: 0, ServerID: 1, SequenceNumber: 2},
SafeToBootstrap: true,
},
},
Expand Down

0 comments on commit 7c9c00d

Please sign in to comment.