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 : Valid (SingleNamespaced) Operator Installation in tenant namespace #2589

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 20 additions & 4 deletions CATALOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Depending on the workload type, not all tests are required to pass to satisfy be

## Test cases summary

### Total test cases: 117
### Total test cases: 118

### Total suites: 10

Expand All @@ -19,7 +19,7 @@ Depending on the workload type, not all tests are required to pass to satisfy be
|manageability|2|
|networking|12|
|observability|5|
|operator|11|
|operator|12|
|performance|6|
|platform-alteration|13|
|preflight|18|
Expand All @@ -36,11 +36,11 @@ Depending on the workload type, not all tests are required to pass to satisfy be
|---|---|
|8|1|

### Non-Telco specific tests only: 69
### Non-Telco specific tests only: 70

|Mandatory|Optional|
|---|---|
|43|26|
|44|26|

### Telco specific tests only: 27

Expand Down Expand Up @@ -1298,6 +1298,22 @@ Tags|common,operator
|Non-Telco|Optional|
|Telco|Optional|

#### operator-only-single-namespace-mode-allowed-in-tenant-namespaces

Property|Description
---|---
Unique ID|operator-only-single-namespace-mode-allowed-in-tenant-namespaces
Description|Verifies that only single-namespace operators are installed in a tenant-dedicated namespace. The test fails if this namespace contains all-namespaced operators, cluster-wide operators, or pods unrelated to any operator.
Suggested Remediation|Ensure that operator with install mode SingleNamespace only is installed in the tenant namespace. Any other operator with install mode AllNamespace, cluster-wide operator or pods not belonging to any operator must not be present in this namespace.
Best Practice Reference|https://redhat-best-practices-for-k8s.github.io/guide/#redhat-best-practices-for-k8s-cnf-operator-requirements
Exception Process|No exceptions
Tags|common,operator
|**Scenario**|**Optional/Mandatory**|
|Extended|Mandatory|
|Far-Edge|Mandatory|
|Non-Telco|Mandatory|
|Telco|Mandatory|

#### operator-pods-no-hugepages

Property|Description
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ lint:
typos
markdownlint '**/*.md'
yamllint --no-warnings .
shellcheck --format=gcc ${BASH_SCRIPTS}
shellcheck --nocomments --format=gcc ${BASH_SCRIPTS}
bnshr marked this conversation as resolved.
Show resolved Hide resolved

# Builds and runs unit tests
test: coverage-qe
Expand Down
8 changes: 8 additions & 0 deletions expected_results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ testCases:
- observability-termination-policy
- operator-crd-versioning
- operator-crd-openapi-schema
- operator-install-source
- operator-install-status-no-privileges
- operator-install-status-succeeded
- operator-semantic-versioning
- operator-single-crd-owner
- operator-pods-no-hugepages
- operator-multiple-same-operators
- performance-exclusive-cpu-pool
- performance-max-resources-exec-probes
- platform-alteration-isredhat-release
Expand All @@ -81,6 +88,7 @@ testCases:
- operator-install-status-no-privileges
- operator-install-status-succeeded
- operator-olm-skip-range
- operator-only-single-namespace-mode-allowed-in-tenant-namespaces
- operator-semantic-versioning
- operator-single-crd-owner
- operator-pods-no-hugepages
Expand Down
1 change: 1 addition & 0 deletions pkg/autodiscover/autodiscover_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func getAllNamespaces(oc corev1client.CoreV1Interface) (allNs []string, err erro
}
return allNs, nil
}

func getAllOperators(olmClient v1alpha1.OperatorsV1alpha1Interface) ([]*olmv1Alpha.ClusterServiceVersion, error) {
csvs := []*olmv1Alpha.ClusterServiceVersion{}

Expand Down
4 changes: 2 additions & 2 deletions pkg/stringhelper/stringhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
)

// StringInSlice checks a slice for a given string.
func StringInSlice[T ~string](s []T, str T, contains bool) bool {
func StringInSlice[T ~string](s []T, str T, containsCheck bool) bool {
for _, v := range s {
if !contains {
if !containsCheck {
if strings.TrimSpace(string(v)) == string(str) {
return true
}
Expand Down
24 changes: 24 additions & 0 deletions pkg/stringhelper/stringhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ func TestStringInSlice(t *testing.T) {
containsFeature: false, // Note: Turn 'off' the contains check
expected: false,
},
{
testSlice: []string{
"oneapple",
},
testString: "apple",
containsFeature: false, // Note: Turn 'off' the contains check
expected: false,
},
{
testSlice: []string{
"apples",
},
testString: "twoapples",
containsFeature: false, // Note: Turn 'off' the contains check
expected: false,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -126,6 +142,14 @@ func TestStringInSlice_other(t *testing.T) {
containsFeature: false, // Note: Turn 'off' the contains check
expected: false,
},
{
testSlice: []otherString{
"intreeintreeintree",
},
testString: "intree",
containsFeature: false, // Note: Turn 'off' the contains check
expected: false,
},
}

for _, tc := range testCases {
Expand Down
34 changes: 18 additions & 16 deletions tests/identifiers/doclinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,24 @@ const (
TestRtAppNoExecProbesDocLink = NoDocLinkFarEdge

// Operator Test Suite
DocOperatorRequirement = "https://redhat-best-practices-for-k8s.github.io/guide/#redhat-best-practices-for-k8s-cnf-operator-requirements"
TestOperatorInstallStatusSucceededIdentifierDocLink = DocOperatorRequirement
TestOperatorNoPrivilegesDocLink = DocOperatorRequirement
TestOperatorIsCertifiedIdentifierDocLink = DocOperatorRequirement
TestOperatorIsInstalledViaOLMIdentifierDocLink = DocOperatorRequirement
TestOperatorHasSemanticVersioningIdentifierDocLink = DocOperatorRequirement
TestOperatorCrdSchemaIdentifierDocLink = DocOperatorRequirement
TestOperatorCrdVersioningIdentifierDocLink = DocOperatorRequirement
TestOperatorSingleCrdOwnerIdentifierDocLink = DocOperatorRequirement
TestOperatorRunAsNonRootDocLink = DocOperatorRequirement
TestOperatorAutomountTokensDocLink = DocOperatorRequirement
TestOperatorReadOnlyFilesystemDocLink = DocOperatorRequirement
TestOperatorPodsNoHugepagesDocLink = DocOperatorRequirement
TestOperatorCatalogSourceBundleCountIdentifierDocLink = DocOperatorRequirement
TestOperatorOlmSkipRangeDocLink = DocOperatorRequirement
TestMultipleSameOperatorsIdentifierDocLink = DocOperatorRequirement
DocOperatorRequirement = "https://redhat-best-practices-for-k8s.github.io/guide/#redhat-best-practices-for-k8s-cnf-operator-requirements"
TestOperatorInstallStatusSucceededIdentifierDocLink = DocOperatorRequirement
TestOperatorNoPrivilegesDocLink = DocOperatorRequirement
TestOperatorIsCertifiedIdentifierDocLink = DocOperatorRequirement
TestOperatorIsInstalledViaOLMIdentifierDocLink = DocOperatorRequirement
TestSingleNamespacedOperatorInstallationInTenantNamespaceDocLink = DocOperatorRequirement
TestOperatorHasSemanticVersioningIdentifierDocLink = DocOperatorRequirement
TestOperatorCrdSchemaIdentifierDocLink = DocOperatorRequirement
TestOperatorCrdVersioningIdentifierDocLink = DocOperatorRequirement
TestOperatorSingleCrdOwnerIdentifierDocLink = DocOperatorRequirement
TestOperatorRunAsUserIDDocLink = DocOperatorRequirement
TestOperatorRunAsNonRootDocLink = DocOperatorRequirement
TestOperatorAutomountTokensDocLink = DocOperatorRequirement
TestOperatorReadOnlyFilesystemDocLink = DocOperatorRequirement
TestOperatorPodsNoHugepagesDocLink = DocOperatorRequirement
TestOperatorCatalogSourceBundleCountIdentifierDocLink = DocOperatorRequirement
TestOperatorOlmSkipRangeDocLink = DocOperatorRequirement
TestMultipleSameOperatorsIdentifierDocLink = DocOperatorRequirement

// Observability Test Suite
TestLoggingIdentifierDocLink = "https://redhat-best-practices-for-k8s.github.io/guide/#redhat-best-practices-for-k8s-logging"
Expand Down
Loading
Loading