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

Add dscinitializations resource to cluster-role.yaml and handle missing dsci status in ServingRuntimeList.cy.ts #2758

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ describe('Serving Runtime List', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: true,
servingRuntimes: [],
});

Expand All @@ -619,6 +620,44 @@ describe('Serving Runtime List', () => {
kserveModal.findAuthenticationCheckbox().should('not.exist');
});

it('Kserve auth should be hidden when no required capabilities', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: false,
servingRuntimes: [],
requiredCapabilities: [],
});

projectDetails.visitSection('test-project', 'model-server');

modelServingSection.getServingPlatformCard('single-serving').findDeployModelButton().click();

kserveModal.shouldBeOpen();

// check external route, token should be checked and no alert
kserveModal.findAuthenticationCheckbox().should('not.exist');
});

it('Kserve auth should be enabled if capabilities are prsent', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableKServeAuthConfig: false,
servingRuntimes: [],
requiredCapabilities: [StackCapability.SERVICE_MESH, StackCapability.SERVICE_MESH_AUTHZ],
});

projectDetails.visitSection('test-project', 'model-server');

modelServingSection.getServingPlatformCard('single-serving').findDeployModelButton().click();

kserveModal.shouldBeOpen();

// check external route, token should be checked and no alert
kserveModal.findAuthenticationCheckbox().should('exist');
});

it('Do not deploy KServe model when user cannot edit namespace', () => {
initIntercepts({
disableModelMeshConfig: false,
Expand Down
69 changes: 68 additions & 1 deletion frontend/src/concepts/areas/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isAreaAvailable, SupportedArea } from '~/concepts/areas';
import { mockDscStatus } from '~/__mocks__/mockDscStatus';
import { mockDashboardConfig } from '~/__mocks__/mockDashboardConfig';
import { StackComponent } from '~/concepts/areas/types';
import { StackCapability, StackComponent } from '~/concepts/areas/types';
import { SupportedAreasStateMap } from '~/concepts/areas/const';
import { mockDsciStatus } from '~/__mocks__/mockDsciStatus';

Expand Down Expand Up @@ -188,5 +188,72 @@ describe('isAreaAvailable', () => {
expect(isAvailable.requiredComponents).toBe(null);
});
});

describe('requiredCapabilities', () => {
it('should enable area if both capabilities are enabled', () => {
// Make sure this test is valid
expect(SupportedAreasStateMap[SupportedArea.K_SERVE_AUTH].requiredCapabilities).toEqual([
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
]);

// Test both reliant areas
const isAvailableKserveAuth = isAreaAvailable(
SupportedArea.K_SERVE_AUTH,
mockDashboardConfig({ disableKServeAuth: false }).spec,
mockDscStatus({
installedComponents: {
[StackComponent.K_SERVE]: true,
},
}),
mockDsciStatus({
requiredCapabilities: [
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
],
}),
);

expect(isAvailableKserveAuth.status).toBe(true);
expect(isAvailableKserveAuth.featureFlags).toEqual({
disableKServeAuth: 'on',
});
expect(isAvailableKserveAuth.requiredCapabilities).toEqual({
[StackCapability.SERVICE_MESH]: true,
[StackCapability.SERVICE_MESH_AUTHZ]: true,
});
});

it('should enable area if one capability is missing', () => {
// Make sure this test is valid
expect(SupportedAreasStateMap[SupportedArea.K_SERVE_AUTH].requiredCapabilities).toEqual([
StackCapability.SERVICE_MESH,
StackCapability.SERVICE_MESH_AUTHZ,
]);

// Test both reliant areas
const isAvailableKserveAuth = isAreaAvailable(
SupportedArea.K_SERVE_AUTH,
mockDashboardConfig({ disableKServeAuth: false }).spec,
mockDscStatus({
installedComponents: {
[StackComponent.K_SERVE]: true,
},
}),
mockDsciStatus({
requiredCapabilities: [StackCapability.SERVICE_MESH],
}),
);

expect(isAvailableKserveAuth.status).toBe(false);
expect(isAvailableKserveAuth.featureFlags).toEqual({
disableKServeAuth: 'on',
});
expect(isAvailableKserveAuth.requiredCapabilities).toEqual({
[StackCapability.SERVICE_MESH]: true,
[StackCapability.SERVICE_MESH_AUTHZ]: false,
});
});
});
});
});
8 changes: 8 additions & 0 deletions manifests/base/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,11 @@ rules:
- get
resources:
- datascienceclusters
- apiGroups:
- dscinitialization.opendatahub.io
verbs:
- list
- watch
- get
resources:
- dscinitializations
Loading