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

K8SPXC-1301: Run operator locally #1522

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cecd676
Implement queries_exec.
inelpandzic Nov 4, 2023
3752d48
Add OPERATOR_IMAGE env var.
inelpandzic Nov 7, 2023
b340168
Merge branch 'main' into k8spxc-1301-run-operator-locally
inelpandzic Nov 8, 2023
2d4e454
Fix controller-runtime issues.
inelpandzic Nov 8, 2023
3f91473
Use queries.DatabaseExec
inelpandzic Nov 8, 2023
d31e269
Implement user exec manger.
inelpandzic Nov 9, 2023
58f9af3
Fix sql result parsing and set proper container.
inelpandzic Nov 11, 2023
33316f4
Temp improve getting primary pod.
inelpandzic Nov 14, 2023
3985c01
Implement ReplicationStatusExec.
inelpandzic Nov 14, 2023
fe1b906
Merge branch 'main' into k8spxc-1301-run-operator-locally
inelpandzic Nov 14, 2023
0aae3e3
Comments cleanup
inelpandzic Nov 14, 2023
fb40c51
Cleanup contexts.
inelpandzic Nov 14, 2023
e227a37
Remove file.
inelpandzic Nov 14, 2023
2c59190
Bump go version to 1.21.
inelpandzic Nov 16, 2023
b4a671e
Set go version to 1.20.
inelpandzic Nov 16, 2023
3732a1d
Updte controller-runtime.
inelpandzic Nov 16, 2023
fedfe55
Set controller-runtime to v0.16.2.
inelpandzic Nov 16, 2023
6d1abf3
Fix checking if old password is discarded.
inelpandzic Nov 20, 2023
a3b4546
Merge branch 'main' into k8spxc-1301-run-operator-locally
inelpandzic Nov 20, 2023
f348557
Properly update monitor and proxyadmin user within ProxySQL.
inelpandzic Nov 21, 2023
30d7c20
Fix Update160MonitorUserGrantExec with correct SQL query.
inelpandzic Nov 22, 2023
090b5bd
Fix syntax sql error.
inelpandzic Nov 22, 2023
9273b2a
Improve getting primary pod.
inelpandzic Nov 22, 2023
65e676c
Cleanup
inelpandzic Nov 23, 2023
df3dccb
Fix import.
inelpandzic Nov 23, 2023
eace940
Get Dabatabase connected through proxy.
inelpandzic Nov 24, 2023
1c2c1f5
Refactor
inelpandzic Nov 24, 2023
79740c7
Set propper database for user manager.
inelpandzic Nov 24, 2023
23961c9
Refactor user.Manager.
inelpandzic Nov 24, 2023
0c90841
Lint fix.
inelpandzic Nov 24, 2023
88c7aff
Fix getting replication status query.
inelpandzic Nov 29, 2023
6170d68
Fix pass leak.
inelpandzic Nov 29, 2023
7e998ca
Fix checking replication status.
inelpandzic Nov 29, 2023
b153930
Merge branch 'main' into k8spxc-1301-run-operator-locally
inelpandzic Dec 3, 2023
87a8712
Merge branch 'main' into k8spxc-1301-run-operator-locally
inelpandzic Dec 29, 2023
fb40ef7
Implement database.ShowReplicaStatus.
inelpandzic Dec 29, 2023
1ed4605
Revert cr.yaml file.
inelpandzic Dec 29, 2023
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
Prev Previous commit
Next Next commit
Implement ReplicationStatusExec.
inelpandzic committed Nov 14, 2023
commit 3985c0162a9edc1c982d3452cf695a43b04a6f8a
30 changes: 28 additions & 2 deletions pkg/pxc/queries/queries_exec.go
Original file line number Diff line number Diff line change
@@ -108,9 +108,35 @@ func (p *DatabaseExec) ChangeChannelPasswordExec(ctx context.Context, channel, p
return nil
}

// channel name moze biti: group_replication_applier ili SHOW REPLICA STATUS FOR CHANNEL group_replication_recovery
func (p *DatabaseExec) ReplicationStatusExec(ctx context.Context, channel string) (ReplicationStatus, error) {
panic("not implemented")
rows := []*struct {
IORunning string `csv:"Replica_IO_Running"`
SQLRunning string `csv:"Replica_SQL_Running"`
LastErrNo int `csv:"Last_Errno"`
}{}

q := fmt.Sprintf("SHOW REPLICA STATUS FOR CHANNEL %s", channel)
err := p.query(ctx, q, &rows)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return ReplicationStatusNotInitiated, nil
}
return ReplicationStatusError, errors.Wrap(err, "select replication status")
}

ioRunning := rows[0].IORunning == "Yes"
sqlRunning := rows[0].SQLRunning == "Yes"
lastErrNo := rows[0].LastErrNo

if ioRunning && sqlRunning {
return ReplicationStatusActive, nil
}

if !ioRunning && !sqlRunning && lastErrNo == 0 {
return ReplicationStatusNotInitiated, nil
}

return ReplicationStatusError, nil
}

func (p *DatabaseExec) StopAllReplicationExec(ctx context.Context) error {
2 changes: 1 addition & 1 deletion pkg/pxc/users/users_exec.go
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ func (m *ManagerExec) IsOldPassDiscardedExec(ctx context.Context, user *SysUser)
return false, errors.Wrap(err, "select User_attributes field")
}

if len(rows[0].Attr) > 0 {
if len(rows[0].Attr) > 0 && rows[0].Attr != "NULL" {
return false, nil
}