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

Conversation

Horiodino
Copy link
Contributor

Description of Changes

checks if the environment variable "REGISTRY_HEADLESS" exists in headlessStatus, parses its value to a boolean, and sets needsUpdating to true if the parsed value differs from the Headless spec in the cr.Spec

Related Issue(s)

devfile/api#1258

Acceptance Criteria

Tests

  • Test Coverage
    • Are your changes sufficiently tested, and are any applicable test cases added or updated to cover your changes?
  • Gosec scans

Documentation

  • [ ✔️ ] Does the registry operator documentation need to be updated with your changes?

Tests Performed

Explain what tests you personally ran to ensure the changes are functioning as expected.

How To Test

Instructions for the reviewer on how to test your changes.

Running Unit Tests

Running Integration Tests

Notes To Reviewer

Any notes you would like to include for the reviewer.

Copy link

openshift-ci bot commented Nov 11, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Horiodino
Once this PR has been reviewed and has the lgtm label, please assign elsony for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

openshift-ci bot commented Nov 11, 2024

Hi @Horiodino. Thanks for your PR.

I'm waiting for a devfile member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

@Jdubrick Jdubrick left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@@ -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?

Copy link
Contributor

@Jdubrick Jdubrick left a comment

Choose a reason for hiding this comment

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

Not able to get it to update when the headless is altered. Currently deploying with

apiVersion: registry.devfile.io/v1alpha1
kind: DevfileRegistry
metadata:
  name: devfile-registry
spec:
  telemetry:
    registryName: test
  k8s:
    ingressDomain: testing-registry
  tls:
    enabled: false
  headless: true

and when running kubectl apply -n devfile registry -f <path to yaml> with this file:

apiVersion: registry.devfile.io/v1alpha1
kind: DevfileRegistry
metadata:
  name: devfile-registry
spec:
  telemetry:
    registryName: test
  k8s:
    ingressDomain: testing-registry
  tls:
    enabled: false
  headless: false

It does not update. I also noticed that if you remove headless altogether then it segfaults as a memory issue, could be a one off but worth looking into.

Was this working for you/was it tested? @michael-valdron @thepetk have either of you been able to reproduce?

Copy link
Contributor

@thepetk thepetk left a comment

Choose a reason for hiding this comment

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

Left a comment to get more info. I think the current feature needs to have some test cases too.

headlessStatus := dep.Spec.Template.Spec.Containers[0].Env

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but the here headlessStatus := dep.Spec.Template.Spec.Containers[0].Env dep is CR isit ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Horiodino yes dep is a CR but the built-in Kubernetes Deployment CR to be more specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah its not the user defined one right , theirs not any wrapper for getting that CR correct ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I can think of off the top of my head, I think just abstracting your piece of code into a function that takes in a deployment cr and fetches the headless env and returns what it is would be good to add pieces that can easily be tested with unit tests. So I would recommend doing that and adding unit tests for it. Side note, you can deploy the operator and registry on Kubernetes (Minikube/Kind) locally and can verify what happens when you change the headless value, I know during my run throughs it wasn't adding/removing the registry-viewer container as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants