Skip to content

Commit

Permalink
replace Update with Patch for setting Pod labels
Browse files Browse the repository at this point in the history
Closes #24
  • Loading branch information
nrvnrvn committed Nov 16, 2020
1 parent 6baac7e commit 549d566
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ true >go.mod.bzl
true >go.sum

# verify and vendor all dependencies
go mod verify
go mod tidy -v
go mod verify
go mod vendor

# remove all files that were fetched with previous commands in order to avoid conflicts with proto rules
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/redis/redis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ podIter:
for i := range podList.Items {
go func(pod corev1.Pod, masterAddress string, wg *sync.WaitGroup) {
defer wg.Done()
podPatch := client.MergeFrom(pod.DeepCopy())
if pod.Status.PodIP == masterAddress {
select {
case masterChan <- pod.Name:
Expand All @@ -285,7 +286,7 @@ podIter:
}
pod.Labels[roleLabelKey] = replicaLabel
}
if err := reconciler.client.Update(ctx, &pod); err != nil {
if err := reconciler.client.Patch(ctx, &pod, podPatch); err != nil {
errChan <- err
}
}(podList.Items[i], master.Host, &wg)
Expand Down
14 changes: 14 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ github.com/PuerkitoBio/urlesc
# github.com/beorn7/perks v1.0.1
github.com/beorn7/perks/quantile
# github.com/cenkalti/backoff/v3 v3.0.0
## explicit
github.com/cenkalti/backoff/v3
# github.com/cespare/xxhash/v2 v2.1.1
github.com/cespare/xxhash/v2
Expand All @@ -44,10 +45,12 @@ github.com/go-openapi/jsonpointer
# github.com/go-openapi/jsonreference v0.19.3
github.com/go-openapi/jsonreference
# github.com/go-openapi/spec v0.19.4
## explicit
github.com/go-openapi/spec
# github.com/go-openapi/swag v0.19.5
github.com/go-openapi/swag
# github.com/go-redis/redis v6.15.5+incompatible
## explicit
github.com/go-redis/redis
github.com/go-redis/redis/internal
github.com/go-redis/redis/internal/consistenthash
Expand Down Expand Up @@ -106,6 +109,7 @@ github.com/modern-go/concurrent
# github.com/modern-go/reflect2 v1.0.1
github.com/modern-go/reflect2
# github.com/operator-framework/operator-sdk v0.17.1
## explicit
github.com/operator-framework/operator-sdk/pkg/k8sutil
github.com/operator-framework/operator-sdk/pkg/kube-metrics
github.com/operator-framework/operator-sdk/pkg/leader
Expand All @@ -129,8 +133,10 @@ github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
# github.com/spf13/cast v1.3.0
## explicit
github.com/spf13/cast
# github.com/spf13/pflag v1.0.5
## explicit
github.com/spf13/pflag
# go.uber.org/atomic v1.6.0
go.uber.org/atomic
Expand All @@ -144,6 +150,7 @@ go.uber.org/zap/internal/color
go.uber.org/zap/internal/exit
go.uber.org/zap/zapcore
# golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
## explicit
golang.org/x/crypto/argon2
golang.org/x/crypto/blake2b
golang.org/x/crypto/ssh/terminal
Expand Down Expand Up @@ -192,6 +199,7 @@ gopkg.in/inf.v0
# gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v2
# k8s.io/api v0.17.4
## explicit
k8s.io/api/admission/v1beta1
k8s.io/api/admissionregistration/v1
k8s.io/api/admissionregistration/v1beta1
Expand Down Expand Up @@ -234,6 +242,7 @@ k8s.io/api/storage/v1
k8s.io/api/storage/v1alpha1
k8s.io/api/storage/v1beta1
# k8s.io/apimachinery v0.17.4
## explicit
k8s.io/apimachinery/pkg/api/equality
k8s.io/apimachinery/pkg/api/errors
k8s.io/apimachinery/pkg/api/meta
Expand Down Expand Up @@ -279,6 +288,7 @@ k8s.io/apimachinery/pkg/watch
k8s.io/apimachinery/third_party/forked/golang/json
k8s.io/apimachinery/third_party/forked/golang/reflect
# k8s.io/client-go v12.0.0+incompatible => k8s.io/client-go v0.17.4
## explicit
k8s.io/client-go/discovery
k8s.io/client-go/dynamic
k8s.io/client-go/kubernetes
Expand Down Expand Up @@ -362,6 +372,7 @@ k8s.io/client-go/util/workqueue
# k8s.io/klog v1.0.0
k8s.io/klog
# k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
## explicit
k8s.io/kube-openapi/pkg/common
k8s.io/kube-openapi/pkg/util/proto
# k8s.io/kube-state-metrics v1.7.2
Expand All @@ -373,6 +384,7 @@ k8s.io/utils/integer
k8s.io/utils/pointer
k8s.io/utils/trace
# sigs.k8s.io/controller-runtime v0.5.2
## explicit
sigs.k8s.io/controller-runtime/pkg/cache
sigs.k8s.io/controller-runtime/pkg/cache/internal
sigs.k8s.io/controller-runtime/pkg/client
Expand Down Expand Up @@ -407,3 +419,5 @@ sigs.k8s.io/controller-runtime/pkg/webhook/internal/certwatcher
sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics
# sigs.k8s.io/yaml v1.1.0
sigs.k8s.io/yaml
# github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible
# k8s.io/client-go => k8s.io/client-go v0.17.4

0 comments on commit 549d566

Please sign in to comment.