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

fixes #1258 controller updates deployment when headless boolean is up… #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions controllers/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"strconv"

registryv1alpha1 "github.com/devfile/registry-operator/api/v1alpha1"
"github.com/devfile/registry-operator/pkg/registry"
Expand Down Expand Up @@ -84,6 +85,19 @@ func (r *DevfileRegistryReconciler) updateDeployment(ctx context.Context, cr *re
needsUpdating = true
}
}
headlessStatus := dep.Spec.Template.Spec.Containers[0].Env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to rename this var to be more clear that it is the array of all env vars for the container?


for _, env := range headlessStatus {
if env.Name == "REGISTRY_HEADLESS" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some time to check this part of the code, so I'm not sure I understand the purpose of the env var usage here. Could you elaborate?

From my point of view, I would expect us here to:

  • Compare the existing headless status with the new one.
  • We could fetch the existing from dep.Spec.Template.Spec.Headless
  • We could create (IIRC we don't have one) a function to get the headless status from the registryv1alpha1.DevfileRegistry resource.
  • In case the two of them are different assign the current value to the existing one and update the needsUpdating variable to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create (IIRC we don't have one) a function to get the headless status from the registryv1alpha1.DevfileRegistry resource.
im comparing on the basis of deployment , i also taught about that but saw this
https://github.com/Horiodino/registry-operator/blob/headless-boolean/pkg/registry/deployment.go#L286
so i didn't added anything.

is that same thing or different ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like it is setting the headless value but I believe @thepetk is wanting a checker function to easily grab the headless value from a CR

value, err := strconv.ParseBool(env.Value)
if err != nil {
return err
}
if *cr.Spec.Headless != value {
needsUpdating = true
}
}
}

if len(dep.Spec.Template.Spec.Containers) > 2 {
viewerImage := registry.GetRegistryViewerImage(cr)
Expand Down
Loading