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

feat(discovery): options to configure discovery port names and numbers #715

Merged
merged 10 commits into from
Feb 12, 2024

Conversation

tthvo
Copy link
Member

@tthvo tthvo commented Jan 23, 2024

Welcome to Cryostat! 👋

Before contributing, make sure you have:

  • Read the contributing guidelines
  • Linked a relevant issue which this PR resolves
  • Linked any other relevant issues, PR's, or documentation, if any
  • Resolved all conflicts, if any
  • Rebased your branch PR on top of the latest upstream main branch
  • Attached at least one of the following labels to the PR: [chore, ci, docs, feat, fix, test]
  • Signed all commits: git commit -S -m "YOUR_COMMIT_MESSAGE"

Fixes: #714
Depends on https://github.com/cryostatio/cryostat/pull/1862

Description of the change:

  • Added CRD fields for customizing discovery port names and numbers.
  • Tests are a little messy though but please lmk what you think! :D

Spec

Define non-empty lists:

spec:
  targetDiscoveryOptions:
    discoveryPortNames:
      - for-jmx
      - jmx-port
    discoveryPortNumbers:
      - 9092
      - 9093

Use empty value (i.e. -):

spec:
  targetDiscoveryOptions:
    disableBuiltInPortNames: true
    disableBuiltInPortNumbers: true

Use default values:

spec:
  targetDiscoveryOptions:

OR

spec:
  targetDiscoveryOptions:
    discoveryPortNames: []
    discoveryPortNumbers: []

Motivation for the change:

See #714

How to test

This relies on Andrew's image for #714. Build or use a pre-built one here quay.io/thvo/cryostat-operator:2.5.0-k8s-discovery-3.

$ export BUNDLE_IMG=quay.io/thvo/cryostat-operator-bundle:2.5.0-k8s-discovery-3
$ make deploy_bundle

Then, either create Cryostat from console (OpenShift) or YAML with above spec (discoveryPortNames is a list of strings, and discoveryPortNumbers is a list of integers.

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
@tthvo tthvo added feat New feature or request safe-to-test labels Jan 23, 2024
Copy link

This PR/issue depends on:

@tthvo tthvo marked this pull request as ready for review January 24, 2024 04:27
@tthvo tthvo requested a review from a team January 24, 2024 04:28
@tthvo
Copy link
Member Author

tthvo commented Jan 24, 2024

For OpenShift, I am not sure how the empty list case can be achieved via the form view, but I suppose YAML view is available.

@andrewazores
Copy link
Member

I haven't tested it, but for the names list since it is just a list of string, wouldn't the form view allow entering simply -?

For the port list it is a little annoying I guess because it makes sense to enforce that this is a list of integer on the form, which means they can't enter - - even though in the end this is going to get made into a string so it can be set as an environment variable.

@andrewazores
Copy link
Member

Maybe we go back to using 0 for the "no ports" case?

@tthvo
Copy link
Member Author

tthvo commented Jan 24, 2024

I haven't tested it, but for the names list since it is just a list of string, wouldn't the form view allow entering simply -?
For the port list it is a little annoying I guess because it makes sense to enforce that this is a list of integer on the form, which means they can't enter - - even though in the end this is going to get made into a string so it can be set as an environment variable.

(Field descriptor in this image is outdated. Missing default mentions are added in latest commit)

image

Right, actually both form's input allows entering -. However, for port number input, invalid items are silently removed after submission.

@andrewazores
Copy link
Member

Maybe with that form view UI in mind it would be best to treat the variable as undefined differently from the variable as blank.

undefined -> "Use defaults (names: ["jfr-jmx"], ports: [9091])
'' -> "Use empty (names: [], ports: [])
jfr-jmx or 9091 -> "Use list (names: ["jfr-jmx"], ports: [9091])
foo,bar or 9999,4444 -> "Use list (names: ["foo", "bar"], ports: [9999, 4444])

I think it would be OK to break this default in 3.0, but not for 2.4.1, so the undefined case really must map to the default singletons when the Cryostat container is deployed - I wouldn't even want to move the assignment of those default values into the Operator or Helm chart logic either.

@tthvo
Copy link
Member Author

tthvo commented Jan 24, 2024

Maybe we go back to using 0 for the "no ports" case?

Make sense to me for accommodating the restrictions on integer-only.

I guess I was too concerned about diff between [] and nil when represented on form view. Then, a [-] or [0] to represent empty would be the option.

@andrewazores
Copy link
Member

Maybe not what I just said actually... I don't know how the user (via form or yaml view) would indicate to the operator that they want empty lists vs they want default behaviour. Bah.

Let's go with - and 0 as the "empty" signifiers for the 2.4.1 bugfix release.

For 3.0 I would like it so that Cryostat itself does not assume any default values for the names or ports, ie its own defaults are the empty lists, whether the env vars are undefined or blank. That should clean up this confusing UI and remove the need for the -/0 signifiers.

@tthvo
Copy link
Member Author

tthvo commented Jan 24, 2024

That sounds good to me! That should also eliminate another tiny problem is that empty input field (i.e. added but not filled) are actually wiped out too after submission. So, the below case would not be really possible via form.

'' -> "Use empty (names: [], ports: [])

Copy link
Member

@ebaron ebaron left a comment

Choose a reason for hiding this comment

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

This looks good to me. Does this approach with separate toggles to disable default behaviour seem good to you too @andrewazores?

@andrewazores
Copy link
Member

Yup, that makes sense.

@andrewazores
Copy link
Member

/build_test

@andrewazores
Copy link
Member

@andrewazores andrewazores merged commit a552021 into cryostatio:main Feb 12, 2024
6 of 7 checks passed
mergify bot pushed a commit that referenced this pull request Feb 12, 2024
#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

# Conflicts:
#	bundle/manifests/cryostat-operator.clusterserviceversion.yaml
@tthvo tthvo deleted the jmx-port-config branch February 12, 2024 19:46
andrewazores added a commit that referenced this pull request Feb 12, 2024
…s (backport #715) (#724)

* feat(discovery): options to configure discovery port names and numbers (#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

# Conflicts:
#	bundle/manifests/cryostat-operator.clusterserviceversion.yaml

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
@ebaron
Copy link
Member

ebaron commented Feb 12, 2024

@Mergifyio backport cryostat3

Copy link
Contributor

mergify bot commented Feb 12, 2024

backport cryostat3

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Feb 12, 2024
#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

# Conflicts:
#	bundle/manifests/cryostat-operator.clusterserviceversion.yaml
ebaron pushed a commit that referenced this pull request Feb 12, 2024
…s (backport #715) (#725)

* feat(discovery): options to configure discovery port names and numbers (#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

# Conflicts:
#	bundle/manifests/cryostat-operator.clusterserviceversion.yaml

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
andrewazores pushed a commit to Josh-Matsuoka/cryostat-operator that referenced this pull request Feb 22, 2024
andrewazores added a commit that referenced this pull request Feb 22, 2024
…s (backport #715) (#725)

* feat(discovery): options to configure discovery port names and numbers (#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
andrewazores added a commit to Josh-Matsuoka/cryostat-operator that referenced this pull request Feb 22, 2024
…s (backport cryostatio#715) (cryostatio#725)

* feat(discovery): options to configure discovery port names and numbers (cryostatio#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
andrewazores pushed a commit to Josh-Matsuoka/cryostat-operator that referenced this pull request Feb 22, 2024
mwangggg pushed a commit to mwangggg/cryostat-operator that referenced this pull request Feb 29, 2024
…s (backport cryostatio#715) (cryostatio#725)

* feat(discovery): options to configure discovery port names and numbers (cryostatio#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
andrewazores added a commit that referenced this pull request Apr 23, 2024
* feat(discovery): options to configure discovery port names and numbers (backport #715) (#725)

* feat(discovery): options to configure discovery port names and numbers (#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
(cherry picked from commit a552021)

* resolve conflict

---------

Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>

* Deploy cryostat 3.0

* Remove extraneous file

* test adjustments

* feat(discovery): options to configure discovery port names and numbers (#715)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>

* Fix typo in environment variable breaking reconciler test, fix missing SecurityContext

* Fix conflict with cluster cryostat removal

* ci(gh): add comment when /build_test is finished (#745)

* add scorecard test/suite selection (#746)

* test(scorecard): scorecard tests for recording management (#698)

* test(scorecard): scorecard tests for recording management

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>

* fixup(scorecard): fix cr cleanup func

* test(scorecard): registry recording test to suite

* chore(scorecard): reorganize client def

* chore(scorecard): clean up common setup func

* chore(bundle): regenerate bundle with scorecard tag

* chore(bundle): correct image tag in bundle

* fix(bundle): add missing scorecard test config patch

* feat(scorecard): scaffold cryostat API client

* chore(scorecard): clean up API client

* test(scorecard): implement recording scorecard test

* fixup(scorecard): correctly add scorecard test via hack templates

* fix(client): ignore unverified tls certs and base64 oauth token

* chore(bundle): split cryostat tests to separate stage

* fix(scorecard): extend default transport instead of overwriting

* chore(scorecard): refactor client to support multi-part

* fixup(client): fix request verb

* fix(client): fix recording create form format

* fix(scorecard): create stored credentials for target JVM

* fix(scorecard): fix 502 status error

* chore(scorecard): simplify client def

* chore(scorecard): fetch recordings to ensure action is correctly performed

* test(scorecard): test generating report for a recording

* chore(scorecard): clean up

* test(scorecard): list archives in tests

* ci(scorecard): reconfigure ingress for kind

* ci(k8s): correct cluster name

* test(scorecard): use role instead of clusterrole for oauth rules

* test(scorecard): parse health response for additional checks

* chore(scorecard): add missing newline in logs

* chore(scorecard): check status code before parsing body in health check

* test(scorecard): add custom target discovery to recording scorecard test

* add EOF wait and resp headers

* add resp headers

* chore(client): configure all clients to send safe requests

* fix(clients): add missing content-type header

* fix(scorecard): add missing test name in help message

* chore(client): create new http requests when retrying

* chore(bundle): update scorecard image tags

---------

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Ming Yu Wang <90855268+mwangggg@users.noreply.github.com>
Co-authored-by: Ming Wang <miwan@redhat.com>

* test(scorecard): scorecard test for Cryostat CR configuration changes (#739)

* CR config scorecard

* reformat

* reviews

* add kubectl license

* test(scorecard): scorecard test for report generator  (#753)

* deploy reports sidecar

* report scorecard test

* update

* rebase fix

* query health

* fix(build-ci): fix scorecard image tag returned as null (#760)

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Elliott Baron <ebaron@redhat.com>

* test(scorecard): add container logs to scorecard results (#758)

* test(scorecard): add container logs to scorecard results

* build(bundle): regenerate bundle with new scorecard tags

* chore(scorecard): refactor to remove duplicate codes

* add permission to publish comment when ci fails (#769)

Co-authored-by: Elliott Baron <ebaron@redhat.com>

* Update NewCoreContainer and associated tests

* build(go): update Golang to 1.21 (#777)

* test(scorecard): logWorkloadEvent for cryostat-recording errors (#759)

* logWorkLoadEvent for cryostat-recording errors

* reviews

* tr.LogChannel

---------

Co-authored-by: Elliott Baron <ebaron@redhat.com>

* test(scorecard): fix rebasing skipped commit (#780)

* Merge pull request #8 from ebaron/scorecard-methods

test(scorecard): use methods for more easily passing data

* update bundle image

* Review fixes

* generate storage key, create expected Secret

* fixup! generate storage key, create expected Secret

* database secret handling corrections

* combine database connection password and encryption key into one secret

* correct storage secret key/access key

* update datasource port number to not conflict with storage

* precreate eventtemplates bucket

* remove storage volume parameter overrides

* use HTTP for Cryostat probe even when TLS is enabled - TLS will be done via auth proxy later

* correct environment variable names for proxy awareness

* Fix remaining merge conflict

* Fix makefile

* config cleanup and test fixup

---------

Signed-off-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Thuan Vo <thuan.votann@gmail.com>
Co-authored-by: Andrew Azores <aazores@redhat.com>
Co-authored-by: Ming Yu Wang <90855268+mwangggg@users.noreply.github.com>
Co-authored-by: Ming Wang <miwan@redhat.com>
Co-authored-by: Elliott Baron <ebaron@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport feat New feature or request safe-to-test
Projects
No open projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

[Request] CRD field(s) for configuring Kubernetes API discovery
3 participants