@@ -3,6 +3,7 @@ package cluster
33// Postgres CustomResourceDefinition object i.e. Spilo
44
55import (
6+ "context"
67 "database/sql"
78 "encoding/json"
89 "fmt"
@@ -88,7 +89,7 @@ type Cluster struct {
8889 pgDb * sql.DB
8990 mu sync.Mutex
9091 userSyncStrategy spec.UserSyncer
91- deleteOptions * metav1.DeleteOptions
92+ deleteOptions metav1.DeleteOptions
9293 podEventsQueue * cache.FIFO
9394
9495 teamsAPIClient teams.Interface
@@ -131,7 +132,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgres
131132 Services : make (map [PostgresRole ]* v1.Service ),
132133 Endpoints : make (map [PostgresRole ]* v1.Endpoints )},
133134 userSyncStrategy : users.DefaultUserSyncStrategy {},
134- deleteOptions : & metav1.DeleteOptions {PropagationPolicy : & deletePropagationPolicy },
135+ deleteOptions : metav1.DeleteOptions {PropagationPolicy : & deletePropagationPolicy },
135136 podEventsQueue : podEventsQueue ,
136137 KubeClient : kubeClient ,
137138 }
@@ -182,7 +183,8 @@ func (c *Cluster) setStatus(status string) {
182183 // we cannot do a full scale update here without fetching the previous manifest (as the resourceVersion may differ),
183184 // however, we could do patch without it. In the future, once /status subresource is there (starting Kubernetes 1.11)
184185 // we should take advantage of it.
185- newspec , err := c .KubeClient .AcidV1ClientSet .AcidV1 ().Postgresqls (c .clusterNamespace ()).Patch (c .Name , types .MergePatchType , patch , "status" )
186+ newspec , err := c .KubeClient .AcidV1ClientSet .AcidV1 ().Postgresqls (c .clusterNamespace ()).Patch (
187+ context .TODO (), c .Name , types .MergePatchType , patch , metav1.PatchOptions {}, "status" )
186188 if err != nil {
187189 c .logger .Errorf ("could not update status: %v" , err )
188190 // return as newspec is empty, see PR654
@@ -1185,38 +1187,38 @@ func (c *Cluster) deleteClusterObject(
11851187
11861188func (c * Cluster ) deletePatroniClusterServices () error {
11871189 get := func (name string ) (spec.NamespacedName , error ) {
1188- svc , err := c .KubeClient .Services (c .Namespace ).Get (name , metav1.GetOptions {})
1190+ svc , err := c .KubeClient .Services (c .Namespace ).Get (context . TODO (), name , metav1.GetOptions {})
11891191 return util .NameFromMeta (svc .ObjectMeta ), err
11901192 }
11911193
11921194 deleteServiceFn := func (name string ) error {
1193- return c .KubeClient .Services (c .Namespace ).Delete (name , c .deleteOptions )
1195+ return c .KubeClient .Services (c .Namespace ).Delete (context . TODO (), name , c .deleteOptions )
11941196 }
11951197
11961198 return c .deleteClusterObject (get , deleteServiceFn , "service" )
11971199}
11981200
11991201func (c * Cluster ) deletePatroniClusterEndpoints () error {
12001202 get := func (name string ) (spec.NamespacedName , error ) {
1201- ep , err := c .KubeClient .Endpoints (c .Namespace ).Get (name , metav1.GetOptions {})
1203+ ep , err := c .KubeClient .Endpoints (c .Namespace ).Get (context . TODO (), name , metav1.GetOptions {})
12021204 return util .NameFromMeta (ep .ObjectMeta ), err
12031205 }
12041206
12051207 deleteEndpointFn := func (name string ) error {
1206- return c .KubeClient .Endpoints (c .Namespace ).Delete (name , c .deleteOptions )
1208+ return c .KubeClient .Endpoints (c .Namespace ).Delete (context . TODO (), name , c .deleteOptions )
12071209 }
12081210
12091211 return c .deleteClusterObject (get , deleteEndpointFn , "endpoint" )
12101212}
12111213
12121214func (c * Cluster ) deletePatroniClusterConfigMaps () error {
12131215 get := func (name string ) (spec.NamespacedName , error ) {
1214- cm , err := c .KubeClient .ConfigMaps (c .Namespace ).Get (name , metav1.GetOptions {})
1216+ cm , err := c .KubeClient .ConfigMaps (c .Namespace ).Get (context . TODO (), name , metav1.GetOptions {})
12151217 return util .NameFromMeta (cm .ObjectMeta ), err
12161218 }
12171219
12181220 deleteConfigMapFn := func (name string ) error {
1219- return c .KubeClient .ConfigMaps (c .Namespace ).Delete (name , c .deleteOptions )
1221+ return c .KubeClient .ConfigMaps (c .Namespace ).Delete (context . TODO (), name , c .deleteOptions )
12201222 }
12211223
12221224 return c .deleteClusterObject (get , deleteConfigMapFn , "configmap" )
0 commit comments