Skip to content
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

fixed listener image reconciliation. #2135 #2136

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,56 @@ func ConfigListener(i *ispnv1.Infinispan, ctx pipeline.Context) {
listenerExists := r.Load(name, deployment) == nil
if listenerExists {
container := kube.GetContainer(InfinispanListenerContainer, &deployment.Spec.Template.Spec)
if container != nil && container.Image == configListenerImage {
if deployment.Spec.Replicas != nil && *deployment.Spec.Replicas == 0 {
if err := ScaleConfigListener(1, i, ctx); err != nil {
ctx.Requeue(err)
return
if container != nil {
if container.Image == configListenerImage {
if deployment.Spec.Replicas != nil && *deployment.Spec.Replicas == 0 {
if err := ScaleConfigListener(1, i, ctx); err != nil {
ctx.Requeue(err)
return
}
}
}

// Update the deployment args if the ConfigListener log level has been updated
logLevel := string(i.Spec.ConfigListener.Logging.Level)
if container.Args[len(container.Args)-1] != logLevel {
err := UpdateConfigListenerDeployment(i, ctx, func(deployment *appsv1.Deployment) {
container = kube.GetContainer(InfinispanListenerContainer, &deployment.Spec.Template.Spec)
container.Args[len(container.Args)-1] = logLevel
})
// Update the deployment args if the ConfigListener log level has been updated
logLevel := string(i.Spec.ConfigListener.Logging.Level)
if container.Args[len(container.Args)-1] != logLevel {
err := UpdateConfigListenerDeployment(i, ctx, func(deployment *appsv1.Deployment) {
container = kube.GetContainer(InfinispanListenerContainer, &deployment.Spec.Template.Spec)
container.Args[len(container.Args)-1] = logLevel
})

if err != nil {
ctx.Requeue(fmt.Errorf("unable to update ConfigListener log level: %w", err))
return
}
}

if err != nil {
ctx.Requeue(fmt.Errorf("unable to update ConfigListener log level: %w", err))
if podResources, err := podResources(i); err != nil {
ctx.Requeue(fmt.Errorf("unable to calculate ConfigListener pod resources on update: %w", err))
return
} else if podResources != nil && !reflect.DeepEqual(*podResources, container.Resources) {
err := UpdateConfigListenerDeployment(i, ctx, func(deployment *appsv1.Deployment) {
container = kube.GetContainer(InfinispanListenerContainer, &deployment.Spec.Template.Spec)
container.Resources = *podResources
})

if err != nil {
ctx.Requeue(fmt.Errorf("unable to update ConfigListener resources: %w", err))
return
}
}
}

if podResources, err := podResources(i); err != nil {
ctx.Requeue(fmt.Errorf("unable to calculate ConfigListener pod resources on update: %w", err))
return
} else if podResources != nil && !reflect.DeepEqual(*podResources, container.Resources) {
// The Deployment already exists with the expected spec, do nothing
} else {
// Deployed configListener has different image, redeploying...
ctx.Log().Info("ConfigListener deployment, new image detected", "image", configListenerImage)
err := UpdateConfigListenerDeployment(i, ctx, func(deployment *appsv1.Deployment) {
container = kube.GetContainer(InfinispanListenerContainer, &deployment.Spec.Template.Spec)
container.Resources = *podResources
deployment.Spec.Template.Spec.Containers[0].Image = configListenerImage
})

if err != nil {
ctx.Requeue(fmt.Errorf("unable to update ConfigListener resources: %w", err))
ctx.Requeue(fmt.Errorf("unable to update ConfigListener image: %w", err))
return
}
return
}

// The Deployment already exists with the expected spec, do nothing
return
}
}

Expand Down
Loading