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

fix(discovery): BUILTIN_DISCOVERY_DISABLED can be specified even when PLATFORM is set #1865

Merged

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Jan 24, 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 using a GPG signature

To recreate commits with GPG signature git fetch upstream && git rebase --force --gpg-sign upstream/main


Fixes: #1864

Description of the change:

Removes BUILTIN_DISCOVERY_DISABLED environment variable from the platform detection selection logic. This is an unfortunate and very old design decision I made that the platform integration is coupled to both the default auth manager as well as platform-specific target discovery mechanism. This made sense when originally implemented because it never made sense for platform-specific discovery mechanisms to overlap, but with the advent of custom targets and later the pluggable discovery API, and then with support for both Podman and Docker API, this is clearly no longer a good assumption and no longer a good abstraction.

This results in a bug where the variable used to control turning off all of these built-in discovery mechanisms is evaluated in the same place as where we determine which platform detection strategies to enable, which therefore also implicates the AuthManagers. We want to be able to do automatic platform auth (OpenShift is the only one that exists now) integration while also allowing users to turn off built-in discovery in case it causes problems or they intend not to use it.

The fix applied in this patch is to allow platform detection as a whole to either work by the usual automatic detection mechanisms, or to allow the user to use the CRYOSTAT_PLATFORM environment variable to specify the list of platforms to enable explicitly. The BUILTIN_DISCOVERY_DISABLED variable is not checked until later, after the platform strategies are selected. Once all the strategies are selected the DiscoveryStorage, which integrates all of the mechanisms into one data repository, turns each one on only if its new isEnabled() method returns true. For Custom Targets and Discovery Storage itself (the pluggable API) this is always true, but for the other built-in discovery mechanisms (Kubernetes API, Podman, Docker) the check depends on BUILTIN_DISCOVERY_DISABLED not being set to true.

How to manually test:

  1. ./mvnw clean package ; podman image prune -f ; podman tag quay.io/cryostat/cryostat:latest quay.io/$MY_QUAY_USERNAME/cryostat:pr-1865-1
  2. podman push quay.io/$MY_QUAY_USERNAME/cryostat:pr-1865-1
  3. cd cryostat-operator
  4. oc new-project pr1865
  5. DEPLOY_NAMESPACE=$(oc project -q) CORE_IMG=quay.io/$MY_QUAY_USERNAME/cryostat:pr-1865-1 make deploy
  6. make create_cryostat_cr ; make sample_app
  7. Open web-client, log in with OpenShift, accept permissions, etc. Verify that Cryostat itself and the sample app appear under the KubernetesApi heading in the target dropdown and in the KubernetesApi Realm in Topology.
  8. oc patch -n $(oc project -q) cryostat/cryostat-sample -p '{"spec":{"targetDiscoveryOptions":{"builtInDiscoveryDisabled":true}}}' to flip the switch and turn off builtin discovery
  9. Wait for rollout replacement to complete, then repeat Step 7. There should be no more KubernetesApi target dropdown header or Realm.

Copy link
Contributor

Hi @andrewazores! Add at least one of the required labels to this PR

Required labels are : chore,ci,cleanup,docs,feat,fix,perf,refactor,style,test

@andrewazores andrewazores force-pushed the builtin-discovery-disable branch 2 times, most recently from 74bf2ed to 698d100 Compare January 24, 2024 17:23
@andrewazores
Copy link
Member Author

/build_test

Copy link
Contributor

Workflow started at 1/24/2024, 12:27:28 PM. View Actions Run.

@andrewazores
Copy link
Member Author

/build_test

Copy link
Contributor

Workflow started at 1/24/2024, 12:36:11 PM. View Actions Run.

Copy link
Contributor

ARCH IMAGE
amd64 ghcr.io/cryostatio/cryostat:pr-1865-3605c98086fcc70caa00ea72569fc2c319075ae0-linux-amd64
arm64 ghcr.io/cryostatio/cryostat:pr-1865-3605c98086fcc70caa00ea72569fc2c319075ae0-linux-arm64

To run smoketest:

# amd64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-3605c98086fcc70caa00ea72569fc2c319075ae0-linux-amd64 sh smoketest.sh

# or arm64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-3605c98086fcc70caa00ea72569fc2c319075ae0-linux-arm64 sh smoketest.sh

Copy link
Contributor

/build_test completed successfully ✅.
View Actions Run.

@andrewazores
Copy link
Member Author

/build_test

Copy link
Contributor

Workflow started at 1/24/2024, 1:27:31 PM. View Actions Run.

@andrewazores andrewazores requested a review from a team January 24, 2024 18:32
Copy link
Contributor

ARCH IMAGE
amd64 ghcr.io/cryostatio/cryostat:pr-1865-b6d5af8d79d5d2ef55354eb790052afaaed935c7-linux-amd64
arm64 ghcr.io/cryostatio/cryostat:pr-1865-b6d5af8d79d5d2ef55354eb790052afaaed935c7-linux-arm64

To run smoketest:

# amd64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-b6d5af8d79d5d2ef55354eb790052afaaed935c7-linux-amd64 sh smoketest.sh

# or arm64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-b6d5af8d79d5d2ef55354eb790052afaaed935c7-linux-arm64 sh smoketest.sh

Copy link
Contributor

/build_test completed successfully ✅.
View Actions Run.

@andrewazores andrewazores changed the title fix(discovery): BUILTIN_DISCOVERY can be specified even when PLATFORM is set fix(discovery): BUILTIN_DISCOVERY_DISABLED can be specified even when PLATFORM is set Jan 24, 2024
Copy link
Member

@mwangggg mwangggg left a comment

Choose a reason for hiding this comment

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

looks good to me

@andrewazores
Copy link
Member Author

/build_test

Copy link
Contributor

github-actions bot commented Feb 6, 2024

Workflow started at 2/6/2024, 11:51:23 AM. View Actions Run.

Copy link
Contributor

github-actions bot commented Feb 6, 2024

ARCH IMAGE
amd64 ghcr.io/cryostatio/cryostat:pr-1865-f22bfb725c6370895216f89713dc2856e6f22df0-linux-amd64
arm64 ghcr.io/cryostatio/cryostat:pr-1865-f22bfb725c6370895216f89713dc2856e6f22df0-linux-arm64

To run smoketest:

# amd64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-f22bfb725c6370895216f89713dc2856e6f22df0-linux-amd64 sh smoketest.sh

# or arm64
CRYOSTAT_IMAGE=ghcr.io/cryostatio/cryostat:pr-1865-f22bfb725c6370895216f89713dc2856e6f22df0-linux-arm64 sh smoketest.sh

Copy link
Contributor

github-actions bot commented Feb 6, 2024

/build_test completed successfully ✅.
View Actions Run.

@andrewazores andrewazores merged commit d627360 into cryostatio:main Feb 6, 2024
8 checks passed
@andrewazores andrewazores deleted the builtin-discovery-disable branch February 6, 2024 17:12
mergify bot pushed a commit that referenced this pull request Feb 6, 2024
andrewazores added a commit that referenced this pull request Feb 6, 2024
… PLATFORM is set (#1865) (#1870)

(cherry picked from commit d627360)

Co-authored-by: Andrew Azores <aazores@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug] BUILTIN_DISCOVERY_DISABLED is ignored if PLATFORM is set
2 participants