Skip to content

MLE-20186 bug for update label and annotation #79

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

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions pkg/k8sutil/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ func SetCommonAnnotations(annotations map[string]string) {
CustomAnnotations = annotations
}

func getCommonLabels(name string) map[string]string {
defaultLabels := map[string]string{
func getSelectorLabels(name string) map[string]string {
selectorLabels := map[string]string{
"app.kubernetes.io/name": "marklogic",
"app.kubernetes.io/instance": name,
"app.kubernetes.io/managed-by": "marklogic-operator",
"app.kubernetes.io/component": "database",
}
return selectorLabels
}

func getCommonLabels(name string) map[string]string {
defaultLabels := getSelectorLabels(name)
mergedLabels := map[string]string{}
if len(CustomLabels) > 0 {
for k, v := range defaultLabels {
Expand Down
2 changes: 2 additions & 0 deletions pkg/k8sutil/marklogicServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ func (cc *ClusterContext) ReconsileMarklogicCluster() (reconcile.Result, error)
logger.Info("MarkLogic statefulSet spec is different from the MarkLogicGroup spec, updating the statefulSet")
logger.Info(patchDiff.String())
currentMlg.Spec = markLogicGroupDef.Spec
currentMlg.ObjectMeta.Labels = markLogicGroupDef.ObjectMeta.Labels
currentMlg.ObjectMeta.Annotations = markLogicGroupDef.ObjectMeta.Annotations
err := cc.Client.Update(cc.Ctx, currentMlg)
if err != nil {
logger.Error(err, "Error updating MakrLogicGroup")
Expand Down
3 changes: 1 addition & 2 deletions pkg/k8sutil/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func (oc *OperatorContext) ReconcileStatefulset() (reconcile.Result, error) {
} else {
logger.Info("MarkLogic statefulSet spec is the same as the MarkLogicGroup spec")
}
logger.Info("MarkLogic statefulSet is updated to " + strconv.Itoa(int(*cr.Spec.Replicas)))
logger.Info("Operator Status:", "Stage", cr.Status.Stage)
if cr.Status.Stage == "STS_CREATED" {
logger.Info("MarkLogic statefulSet created successfully, waiting for pods to be ready")
Expand Down Expand Up @@ -191,7 +190,7 @@ func generateStatefulSetsDef(stsMeta metav1.ObjectMeta, params statefulSetParame
TypeMeta: generateTypeMeta("StatefulSet", "apps/v1"),
ObjectMeta: stsMeta,
Spec: appsv1.StatefulSetSpec{
Selector: LabelSelectors(stsMeta.GetLabels()),
Selector: LabelSelectors(getSelectorLabels(params.Name)),
ServiceName: stsMeta.Name,
Replicas: params.Replicas,
PodManagementPolicy: appsv1.ParallelPodManagement,
Expand Down