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 : Proper operator installation inside tenant namespace #2589

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bnshr
Copy link
Contributor

@bnshr bnshr commented Nov 25, 2024

Refers the issue

@bnshr bnshr marked this pull request as draft November 25, 2024 14:08
@bnshr bnshr force-pushed the CNFCERT-1088 branch 3 times, most recently from 98cb58b to 56d4773 Compare November 25, 2024 14:39
@dcibot
Copy link
Collaborator

dcibot commented Nov 25, 2024

@bnshr bnshr force-pushed the CNFCERT-1088 branch 2 times, most recently from 1f928d0 to e3fd824 Compare November 25, 2024 15:09
@dcibot
Copy link
Collaborator

dcibot commented Nov 25, 2024

@bnshr bnshr force-pushed the CNFCERT-1088 branch 2 times, most recently from 33278d6 to 26570f7 Compare November 25, 2024 16:20
@dcibot
Copy link
Collaborator

dcibot commented Nov 25, 2024

@bnshr bnshr marked this pull request as ready for review November 25, 2024 19:17
Copy link
Member

@sebrandon1 sebrandon1 left a comment

Choose a reason for hiding this comment

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

Initial set of comments

tests/operator/suite.go Outdated Show resolved Hide resolved
tests/operator/helper.go Outdated Show resolved Hide resolved
tests/operator/helper.go Outdated Show resolved Hide resolved
tests/operator/helper.go Show resolved Hide resolved
tests/operator/suite.go Outdated Show resolved Hide resolved
@dcibot
Copy link
Collaborator

dcibot commented Jan 14, 2025

@dcibot
Copy link
Collaborator

dcibot commented Jan 14, 2025

@dcibot
Copy link
Collaborator

dcibot commented Jan 14, 2025

tests/operator/suite.go Outdated Show resolved Hide resolved
tests/operator/suite.go Outdated Show resolved Hide resolved
@dcibot
Copy link
Collaborator

dcibot commented Jan 16, 2025

@dcibot
Copy link
Collaborator

dcibot commented Jan 16, 2025

Copy link
Member

@sebrandon1 sebrandon1 left a comment

Choose a reason for hiding this comment

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

Some more comments to look at.

config/certsuite_config.yml Outdated Show resolved Hide resolved
@@ -83,7 +83,7 @@ lint:
typos
markdownlint '**/*.md'
yamllint --no-warnings .
shellcheck --format=gcc ${BASH_SCRIPTS}
shellcheck --nocomments --format=gcc ${BASH_SCRIPTS}
Copy link
Member

Choose a reason for hiding this comment

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

Could this be put into another PR?

Copy link
Contributor Author

@bnshr bnshr Jan 17, 2025

Choose a reason for hiding this comment

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

I cannot remember now why this was added. There was some issue, which was solved by adding this.

@@ -45,3 +52,83 @@ func SplitCsv(csv string) CsvResult {
}
return result
}

func hasOperatorInstallModeType(installModes []v1alpha1.InstallMode, installModeType v1alpha1.InstallModeType) bool {
Copy link
Member

Choose a reason for hiding this comment

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

This could be unit tested in another PR.

tests/operator/helper.go Outdated Show resolved Hide resolved
return singleNamespacedOperators
}

func getAllPodsBy(namespace string) (podsInNamespace []*provider.Pod) {
Copy link
Member

Choose a reason for hiding this comment

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

This could be unit tested in another PR.

tests/operator/helper.go Outdated Show resolved Hide resolved
config/certsuite_config.yml Outdated Show resolved Hide resolved
@dcibot
Copy link
Collaborator

dcibot commented Jan 16, 2025

@bnshr bnshr changed the title feat : Operator Installation outside of targetNamespace feat : Proper operator installation inside tenant namespace Jan 17, 2025
@bnshr bnshr force-pushed the CNFCERT-1088 branch 5 times, most recently from 4edc01f to 1817116 Compare January 17, 2025 16:13
@dcibot
Copy link
Collaborator

dcibot commented Jan 17, 2025

@dcibot
Copy link
Collaborator

dcibot commented Jan 17, 2025

Copy link
Member

@edcdavid edcdavid left a comment

Choose a reason for hiding this comment

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

I am surprised to see so much changes, your previous implementation needed only a simple change, e.g. to go through all operator namespaces instead of all Single operator namespaces. I feel this implementation is more convoluted and seems to miss a test case since now we are testing also application namespaces.

func checkIfNamespaceContainsOnlyOperatorPods(namespace string) (isOperatorOnlyNamespace bool, singleNamespacedCsvs, allNamespacedCsvs []string, failedPods string, err error) {
allPods := getAllPodsBy(namespace)

foundCsvs, failedPodList, err := checkValidOperatorPodsIn(namespace, allPods)
Copy link
Member

Choose a reason for hiding this comment

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

failedPodList -> podsBelongingToNoOperators

nonCompliantObjects = append(nonCompliantObjects, testhelper.NewOperatorReportObject(operatorNamespace, allNamespacedOperators,
"AllNamespaced Operator has invalid installation in tenant namespace ", false).AddField("failed pods", failedPods))
} else {
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNamespacedNamedReportObject(
Copy link
Member

Choose a reason for hiding this comment

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

If doesNamespaceContainsOnlyOperatorPods is false and if len(allNamespacedCsvs) == 0, it could be that pods are all app pods so it is compliant.

var compliantObjects []*testhelper.ReportObject
var nonCompliantObjects []*testhelper.ReportObject

for _, operatorNamespace := range env.Namespaces {
Copy link
Member

Choose a reason for hiding this comment

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

if you go through all namespaces instead of all operator namespaces, you need to consider the compliant case where all pods do not belong to any operator in the namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants