Skip to content

fix: startup all resource indexing #2881

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

Merged
merged 24 commits into from
Aug 5, 2025
Merged

fix: startup all resource indexing #2881

merged 24 commits into from
Aug 5, 2025

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Jul 31, 2025

Indexes all the resources in the cache on startup, making sure that all resources are on the index for first reconiliation.

csviri added 19 commits July 24, 2025 13:50
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
This reverts commit faf9bdf.
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@openshift-ci openshift-ci bot requested review from metacosm and xstefank July 31, 2025 11:43
@csviri csviri changed the title sec to primary as index v3 fix: startup resource cache access - alternate version 2 Jul 31, 2025
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
csviri added 2 commits July 31, 2025 16:44
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@csviri csviri changed the title fix: startup resource cache access - alternate version 2 fix: startup resource cache access Aug 1, 2025
@csviri csviri changed the title fix: startup resource cache access fix: startup resource indexing Aug 1, 2025
@csviri csviri changed the title fix: startup resource indexing fix: startup all resource indexing Aug 1, 2025
* Used to initialize resources when the namespace is generated but the operator is not started
* yet.
*/
public Builder withBeforeStartHook(Consumer<LocallyRunOperatorExtension> beforeStartHook) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might need a "before-shutdown" hook as well to perform clean-up if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is usually not needed strictly , since one can clean the resources at the end of the test, so functionally that is doable. But agree that might be a nicer api.

SECONDARY_NUMBER);

if (secondary.size() != cached.size()) {
secondaryAndCacheSameAmount = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not simply:

secondaryAndCacheSameAmount = secondary.size() == cache.size();

Copy link
Collaborator Author

@csviri csviri Aug 5, 2025

Choose a reason for hiding this comment

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

That would not work if later is the same value would overwrite the false, so here the aim is that if once false therefore always false

@@ -44,6 +44,22 @@ void dependentResourceCanReferenceEachOther() {
assertThat(operator.get(Secret.class, TEST_RESOURCE_NAME + i)).isNotNull();
}
});

for (int i = 0; i < EXECUTION_NUMBER; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems unrelated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this test was failing with a different version of the fix, and improved it while investigating, I can make it as a separate PR.

Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

LGTM with minor nitpicks.

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@csviri csviri merged commit 457c23f into main Aug 5, 2025
24 of 25 checks passed
@csviri csviri deleted the sec-to-primary-as-index-v3 branch August 5, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

context.getSecondaryResources() returns incomplete list on initial reconcile after operator startup
3 participants