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
Feature flag MultiClusterHub and disable Web Terminal #9340
Feature flag MultiClusterHub and disable Web Terminal #9340
Conversation
2fcb400
to
aafbffd
Compare
const flags = useSelector((state: RootState) => getFlagsObject(state)); | ||
const isMCHAvailable = flags[MCH_AVAILABILITY_FLAG]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useFlag
instead?
const { t } = useTranslation(); | ||
|
||
if (!terminalAvailable) { | ||
if (!terminalAvailable || (!flagLoading && isMCHAvailable)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!terminalAvailable || (!flagLoading && isMCHAvailable)) { | |
if (!terminalAvailable || flagLoading || isMCHAvailable) { |
|
||
if (devWorkspaceFlag === false) return <Redirect to="/" />; | ||
if (devWorkspaceFlag === false || mchFLag === true) return <Redirect to="/" />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mch flag could take some time to be available but we shouldn't be showing the console while console in the meantime. We need to wait for the flag to be ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted
{ | ||
type: 'FeatureFlag/Custom', | ||
properties: { | ||
detect: detectMCHAvailability, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use dynamic plugin SDK because static plugins are being migrated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted
|
||
export const detectMCHAvailability: FeatureDetector = async (dispatch) => { | ||
try { | ||
const multiclusterHubs = await k8sList(MultiClusterHubModel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to key on the feature gate we plan to add in https://issues.redhat.com/browse/CONSOLE-2845. We'd only want to disable web terminal if the multicluster is enabled for console, which won't always be the case when ACM is installed.
} catch (err) { | ||
err?.response?.status === 404 | ||
? dispatch(setFlag(MCH_AVAILABILITY_FLAG, false)) | ||
: handleError(err, MCH_AVAILABILITY_FLAG, dispatch, detectMCHAvailability); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the access control for this resource? What happens for users who don't have authority to list MultiClusterHubs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we would run into an undesired state for users who cannot list MCH
cc @TheRealJon @jhadvig |
The console operator will pass the backend a list of clusters, so the backend will know. Easiest might be to add something to |
@spadgett Good point about the RBAC issues of using MultiClusterHub as an indication of multicluster capability. That was by my suggestion. I also suggested we look for the TechPreviewNoUpgrade config on the cluster, which will also have the same RBAC problems. I agree that window.SERVER_FLAGS might be the best way to go, in which case this story is probably blocked by https://issues.redhat.com/browse/CONSOLE-2845 |
@spadgett @christianvogt @TheRealJon Keeping on hold and will update the implementation post https://issues.redhat.com/browse/CONSOLE-2845 |
/hold |
284ae5b
to
76c3a5f
Compare
Updated to mock implementation using |
/retest |
76c3a5f
to
786eee8
Compare
@abhinandan13jan please ensure your description is up to date with the latest implementation. Including the PR testing section. |
Srry for the delay. Updated |
const isMultiClusterEnabled = (): boolean => { | ||
let isAvailable = false; | ||
// Mock implementation. needs update | ||
const mchFlagData = window.SERVER_FLAGS.clusters; | ||
if (mchFlagData) { | ||
isAvailable = mchFlagData.length > 1; // to-do: update logic/flag when finalised | ||
} | ||
return isAvailable; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, this could be simplified with optional chaining:
const isMultiClusterEnabled = (): boolean => { | |
let isAvailable = false; | |
// Mock implementation. needs update | |
const mchFlagData = window.SERVER_FLAGS.clusters; | |
if (mchFlagData) { | |
isAvailable = mchFlagData.length > 1; // to-do: update logic/flag when finalised | |
} | |
return isAvailable; | |
}; | |
const isMultiClusterEnabled = (): boolean => window.SERVER_FLAGS.clusters?.length > 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
786eee8
to
94d19e1
Compare
/retest |
/lgtm |
@@ -0,0 +1,4 @@ | |||
const isMultiClusterEnabled = (): boolean => window.SERVER_FLAGS.clusters?.length > 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid?
What if the hub cluster only has a one managed cluster? Won't this array contain a single item?
Should we be checking for undefined or null instead?
cc @spadgett
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cluster list will always include the hub cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.
Ok so if there's one cluster it would mean that we are always targeting the hub cluster in which case the check is correct.
While maybe not correct for the web terminal which can work to access the cluster the console runs on. But that's another discussion.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinandan13jan, christianvogt, TheRealJon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@abhinandan13jan @spadgett why the hold? Can this be merged now, it seems like it'll have no impact whether the server flag is present or not. |
I think this can merge now. I added the hold because of the note Abhi made but since https://issues.redhat.com/browse/CONSOLE-2845 is done separately and we are not dependent on it... I think we can unhold. /unhold |
Addresses
Commit 1 -> https://issues.redhat.com/browse/ODC-5924 // Create feature flag for MultiClusterHub CR with Running status
Commit 2 -> https://issues.redhat.com/browse/ODC-5927 // Disable Web terminal based on MCH feature flag
Description
Assumes structure of
SERVER_FLAGS
to beSERVER_FLAGS.clusters: string [ ]
where presence of more than one entry definesmultiCluster
to be enabledCreates a function
isMultiClusterEnabled
which reads data fromSERVER_FLAGS
for the presence of multiple clusters and returns accordingly.Updates Web terminal to read the presence of multiple clusters and render accordindly.
PR Testing
Web-terminal
operator and check for theCloudshell masthead
icon./terminal
route should be available.Sometimes it doesn't work in localhost. You may need to manually set
useCloudShellAvailable
totrue
for testing purpose.window.SERVER_FLAGS.clusters = [ 'clustera', 'clusterb']
. This data must exist before render.CloudShell masthead
icon should disappear./terminal
route should be unavailable/redirected.Screenshot
Test
Added test-suite for utility
useMCHDetection
in console-appUpdated test-suite for
CloudShellTab
Browser Conformance
Chrome