Skip to content

Commit ca55408

Browse files
author
Peng Zhou
committed
fix context issue
1 parent 6617be6 commit ca55408

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/k8sutil/statefulset.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (oc *OperatorContext) ReconcileStatefulset() (reconcile.Result, error) {
119119
logger.Info("Operator Status:", "Stage", cr.Status.Stage)
120120
if cr.Status.Stage == "STS_CREATED" {
121121
logger.Info("MarkLogic statefulSet created successfully, waiting for pods to be ready")
122-
pods, err := GetPodsForStatefulSet(cr.Namespace, cr.Spec.Name)
122+
pods, err := GetPodsForStatefulSet(oc.Ctx, cr.Namespace, cr.Spec.Name)
123123
if err != nil {
124124
logger.Error(err, "Error getting pods for statefulset")
125125
}
@@ -178,7 +178,7 @@ func (oc *OperatorContext) setCondition(condition *metav1.Condition) bool {
178178
func (oc *OperatorContext) GetStatefulSet(namespace string, stateful string) (*appsv1.StatefulSet, error) {
179179
logger := oc.ReqLogger
180180
statefulInfo := &appsv1.StatefulSet{}
181-
err := oc.Client.Get(context.TODO(), client.ObjectKey{Namespace: namespace, Name: stateful}, statefulInfo)
181+
err := oc.Client.Get(oc.Ctx, client.ObjectKey{Namespace: namespace, Name: stateful}, statefulInfo)
182182
if err != nil {
183183
logger.Info("MarkLogic statefulSet get action failed")
184184
return nil, err
@@ -189,7 +189,7 @@ func (oc *OperatorContext) GetStatefulSet(namespace string, stateful string) (*a
189189

190190
func (oc *OperatorContext) createStatefulSet(statefulset *appsv1.StatefulSet, cr *marklogicv1.MarklogicGroup) error {
191191
logger := oc.ReqLogger
192-
err := oc.Client.Create(context.TODO(), statefulset)
192+
err := oc.Client.Create(oc.Ctx, statefulset)
193193
if err != nil {
194194
logger.Error(err, "MarkLogic stateful creation failed")
195195
return err
@@ -304,11 +304,11 @@ func generateStatefulSetsDef(stsMeta metav1.ObjectMeta, params statefulSetParame
304304
return statefulSet
305305
}
306306

307-
func GetPodsForStatefulSet(namespace, name string) ([]corev1.Pod, error) {
307+
func GetPodsForStatefulSet(ctx context.Context, namespace, name string) ([]corev1.Pod, error) {
308308
selector := fmt.Sprintf("app.kubernetes.io/name=marklogic,app.kubernetes.io/instance=%s", name)
309309
// List Pods with the label selector
310310
listOptions := metav1.ListOptions{LabelSelector: selector}
311-
pods, err := GenerateK8sClient().CoreV1().Pods(namespace).List(context.TODO(), listOptions)
311+
pods, err := GenerateK8sClient().CoreV1().Pods(namespace).List(ctx, listOptions)
312312
if err != nil {
313313
return nil, err
314314
}

0 commit comments

Comments
 (0)