Skip to content

Commit

Permalink
Improve debugger subcommand (#744)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Jan 4, 2024
1 parent 7a069de commit 8b87df8
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 61 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ require (
k8s.io/klog/v2 v2.110.1
k8s.io/kubectl v0.29.0
kmodules.xyz/cert-manager-util v0.29.0
kmodules.xyz/client-go v0.29.4
kmodules.xyz/client-go v0.29.5
kmodules.xyz/custom-resources v0.29.0
kmodules.xyz/monitoring-agent-api v0.29.0
kubedb.dev/apimachinery v0.40.1-0.20240101000103-032b27211164
kubedb.dev/apimachinery v0.40.1-0.20240104031132-a1d475ceb73e
kubedb.dev/db-client-go v0.0.8
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/yaml v1.4.0
Expand Down Expand Up @@ -135,8 +135,8 @@ require (
kmodules.xyz/objectstore-api v0.29.0 // indirect
kmodules.xyz/offshoot-api v0.29.0 // indirect
kmodules.xyz/prober v0.29.0 // indirect
kmodules.xyz/resource-metadata v0.18.1 // indirect
kubeops.dev/sidekick v0.0.5-0.20231225131722-1b7b3d4fc5bc // indirect
kmodules.xyz/resource-metadata v0.18.2-0.20240101021508-7630737cb0e6 // indirect
kubeops.dev/sidekick v0.0.5-0.20231225214445-a15c70833046 // indirect
kubestash.dev/apimachinery v0.3.1-0.20231231034418-cc46ddfd674a // indirect
sigs.k8s.io/gateway-api v0.8.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/cert-manager-util v0.29.0 h1:HjEaEsv66xeMKiI8LwfTRls0z9V9L0qEvPBdOcX/CsI=
kmodules.xyz/cert-manager-util v0.29.0/go.mod h1:0YuaPwp+P3Pw7Spxf6eDhOCMDDNXfNV2xIuxIexT1QU=
kmodules.xyz/client-go v0.29.4 h1:WW4vlYtzLc9JXrJjcFuJO4DX/kIZ5ia7QtDyhNDUwfI=
kmodules.xyz/client-go v0.29.4/go.mod h1:xWlS/1zWkx1sIKCAkzULy9570mHZYi2exDECEoP1ek4=
kmodules.xyz/client-go v0.29.5 h1:iRl4MoV+96TM1csInOCWjn5xSOXzuYlil6CO40vXLHU=
kmodules.xyz/client-go v0.29.5/go.mod h1:pHuzpwzEcDUIGjVVvwz9N8lY+6A7HXwvs2d7NtK7Hho=
kmodules.xyz/custom-resources v0.29.0 h1:RaDM2+wSVXiwIvLqmkTVYpwoH83AC8wruXe2p2rOZNY=
kmodules.xyz/custom-resources v0.29.0/go.mod h1:MzZyXtxdg1PDxGk3RTTO1Xv3KiVqZnIonSwmxVbagOY=
kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9H1UFRwB4=
Expand All @@ -816,14 +816,14 @@ kmodules.xyz/offshoot-api v0.29.0 h1:GHLhxxT9jU1N8+FvOCCeJNyU5g0duYS46UGrs6AHNLY
kmodules.xyz/offshoot-api v0.29.0/go.mod h1:5NxhBblXoDHWStx9HCDJR2KFTwYjEZ7i1Id3jelIunw=
kmodules.xyz/prober v0.29.0 h1:Ex7m4F9rH7uWNNJlLgP63ROOM+nUATJkC2L5OQ7nwMg=
kmodules.xyz/prober v0.29.0/go.mod h1:UtK+HKyI1lFLEKX+HFLyOCVju6TO93zv3kwGpzqmKOo=
kmodules.xyz/resource-metadata v0.18.1 h1:xRR3yvz8sOPAEdgyl2Uyac+9BrSkRqxCM4eNZPpomw4=
kmodules.xyz/resource-metadata v0.18.1/go.mod h1:t9zy5/xAD042zBn9Zf7igQKh9TSPa72B3kVMXdTQTUI=
kubedb.dev/apimachinery v0.40.1-0.20240101000103-032b27211164 h1:EQSWdD4JNJx/nqp0sP0eUJ4JXgEDiy1Y4W9bQqvCERM=
kubedb.dev/apimachinery v0.40.1-0.20240101000103-032b27211164/go.mod h1:xg6q1DCjO24xgMuZ9h2zPgdfo+vGxrE6fJfeTsAbZVc=
kmodules.xyz/resource-metadata v0.18.2-0.20240101021508-7630737cb0e6 h1:a1ZAbqyIL41vgnsbkKP64r9fQBOVxpmaM+5GpwPJhcc=
kmodules.xyz/resource-metadata v0.18.2-0.20240101021508-7630737cb0e6/go.mod h1:XsCdEKjfoulX29tMGviDhjT/jLl158uvMvXlKOhK1as=
kubedb.dev/apimachinery v0.40.1-0.20240104031132-a1d475ceb73e h1:W4P/V/i6PkCL6ODaG7M2669AhhnRv8PYhvOFHTrVeWg=
kubedb.dev/apimachinery v0.40.1-0.20240104031132-a1d475ceb73e/go.mod h1:pa3rY23DEC7j4c0H2uIe6uG7YUbNnT1qA3p7UBr3pwQ=
kubedb.dev/db-client-go v0.0.8 h1:u95a8//A2ItHpM73YFqYiFRZcYQhDODrnoDDgYjqKuQ=
kubedb.dev/db-client-go v0.0.8/go.mod h1:d3/Eztn7mzjEYwHI5+aALMOaLwAWRh0eRlCoKKD5cU4=
kubeops.dev/sidekick v0.0.5-0.20231225131722-1b7b3d4fc5bc h1:4iPXO/8xpo3H+BQyoPKfX+MmNfqw3U+wWalbAjUi7Uc=
kubeops.dev/sidekick v0.0.5-0.20231225131722-1b7b3d4fc5bc/go.mod h1:9j1ho/lTWtI4NBj5Cy+xdc55MViBLumIfO9ZTRWQmHI=
kubeops.dev/sidekick v0.0.5-0.20231225214445-a15c70833046 h1:X1ieV+IXqNesmFwSH6NEVF1J2wO0vplC4k6v3Vmq0d0=
kubeops.dev/sidekick v0.0.5-0.20231225214445-a15c70833046/go.mod h1:XX6Vhw9EMmX9R8Y13AgaYDAsfeLZdTL8MzymTOAT0nY=
kubestash.dev/apimachinery v0.3.1-0.20231231034418-cc46ddfd674a h1:zkRd7mpfFk2QtGKefGxZqpczy909KJCk4iPu9WOwCKU=
kubestash.dev/apimachinery v0.3.1-0.20231231034418-cc46ddfd674a/go.mod h1:ImhcNxJIdObtmm1jPeOnvK9TrwS7bXqNa8I4Um/Vf1A=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *elasticsearchOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *mariadbOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *mongodbOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *mysqlOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *postgresOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
14 changes: 11 additions & 3 deletions pkg/debug/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ func (opts *redisOpts) collectOperatorLogs() error {
return err
}
for _, pod := range pods.Items {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
isOperatorPod := false
for _, container := range pod.Spec.Containers {
if container.Name == operatorContainerName {
isOperatorPod = true
}
}
if isOperatorPod {
err = opts.writeLogs(pod.Name, pod.Namespace, operatorContainerName)
if err != nil {
return err
}
}
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions vendor/kmodules.xyz/client-go/meta/preconditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

type PreConditionSet struct {
sets.String
sets.Set[string]
}

func (s PreConditionSet) PreconditionFunc() []mergepatch.PreconditionFunc {
Expand All @@ -36,7 +36,7 @@ func (s PreConditionSet) PreconditionFunc() []mergepatch.PreconditionFunc {
mergepatch.RequireMetadataKeyUnchanged("namespace"),
}

for _, field := range s.List() {
for _, field := range sets.List[string](s.Set) {
preconditions = append(preconditions,
RequireChainKeyUnchanged(field),
)
Expand All @@ -45,7 +45,7 @@ func (s PreConditionSet) PreconditionFunc() []mergepatch.PreconditionFunc {
}

func (s PreConditionSet) Error() error {
strList := strings.Join(s.List(), "\n\t")
strList := strings.Join(sets.List[string](s.Set), "\n\t")
return fmt.Errorf(strings.Join([]string{`At least one of the following was changed:
apiVersion
kind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchElasticsearchObject(ctx context.Context, c cs.KubedbV1alpha2Interface,

func TryUpdateElasticsearch(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.Elasticsearch) *api.Elasticsearch, opts metav1.UpdateOptions) (result *api.Elasticsearch, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.Elasticsearches(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateElasticsearchStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.Elasticsearches(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchEtcdObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur, mod

func TryUpdateEtcd(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.Etcd) *api.Etcd, opts metav1.UpdateOptions) (result *api.Etcd, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.Etcds(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateEtcdStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.Etcds(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchMariaDBObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur,

func TryUpdateMariaDB(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.MariaDB) *api.MariaDB, opts metav1.UpdateOptions) (result *api.MariaDB, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.MariaDBs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateMariaDBStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.MariaDBs(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchMemcachedObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur

func TryUpdateMemcached(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.Memcached) *api.Memcached, opts metav1.UpdateOptions) (result *api.Memcached, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.Memcacheds(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateMemcachedStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.Memcacheds(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchMongoDBObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur,

func TryUpdateMongoDB(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.MongoDB) *api.MongoDB, opts metav1.UpdateOptions) (result *api.MongoDB, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.MongoDBs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateMongoDBStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.MongoDBs(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchMySQLObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur, mo

func TryUpdateMySQL(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.MySQL) *api.MySQL, opts metav1.UpdateOptions) (result *api.MySQL, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.MySQLs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateMySQLStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.MySQLs(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchPerconaXtraDBObject(ctx context.Context, c cs.KubedbV1alpha2Interface,

func TryUpdatePerconaXtraDB(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.PerconaXtraDB) *api.PerconaXtraDB, opts metav1.UpdateOptions) (result *api.PerconaXtraDB, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.PerconaXtraDBs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdatePerconaXtraDBStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.PerconaXtraDBs(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchPgBouncerObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur

func TryUpdatePgBouncer(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.PgBouncer) *api.PgBouncer, opts metav1.UpdateOptions) (result *api.PgBouncer, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.PgBouncers(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdatePgBouncerStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.PgBouncers(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchPostgresObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur,

func TryUpdatePostgres(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.Postgres) *api.Postgres, opts metav1.UpdateOptions) (result *api.Postgres, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.Postgreses(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdatePostgresStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.Postgreses(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchProxySQLObject(ctx context.Context, c cs.KubedbV1alpha2Interface, cur,

func TryUpdateProxySQL(ctx context.Context, c cs.KubedbV1alpha2Interface, meta metav1.ObjectMeta, transform func(*api.ProxySQL) *api.ProxySQL, opts metav1.UpdateOptions) (result *api.ProxySQL, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.ProxySQLs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func UpdateProxySQLStatus(
if err != nil {
return nil, err
}
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
var e2 error
result, e2 = c.ProxySQLs(meta.Namespace).UpdateStatus(ctx, apply(cur), opts)
Expand Down
Loading

0 comments on commit 8b87df8

Please sign in to comment.