-
Notifications
You must be signed in to change notification settings - Fork 65
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
Consumed capacity info in SpaceProvisionerConfig #1109
Merged
metlos
merged 29 commits into
codeready-toolchain:master
from
metlos:member-info-in-spc-status_controller-part
Jan 7, 2025
+563
−186
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
067308a
Make the SPC ready status reflect the ability to place spaces to
metlos 8470d2b
fix small typos and improve the wording in comments
metlos f30cec6
Address linter complaints.
metlos a6b7053
Merge branch 'master' into member-info-in-spc-status-2
mfrancisc 2130e70
return error when no ToolchainStatus is found
metlos 466f212
Rename the tests to better reflect what they're doing
metlos 8450dd9
Don't log the error that will be logged again by the callers
metlos a0b15c8
better naming and explanation why we're doing only a partial re-check…
metlos 1b9a606
Merge remote-tracking branch 'origin/member-info-in-spc-status-2' int…
metlos 691752e
Add tests for the GetSpaceCountsFromCountsCache.
metlos d6db400
Clean up comments
metlos 3b1b557
add a testcase for multiple memory usage threshold breaches
metlos 9e27aa8
Merge remote-tracking branch 'origin/member-info-in-spc-status-2' int…
metlos 136c8ed
Fix typos
metlos 7c935b5
remove GetUsageFunc from the SPC, always read the ToolchainStatus
metlos 0bebee7
Make sure the mappers are used with the correct object type
metlos f97d687
reset the env var to its original value after the test
metlos 087b3bd
Move the update of the space count from the predicate up a level for it
metlos 5972be2
Move the GetSpaceCountFromSpaceProvisionerConfigs helper function into
metlos 226ca14
Simplify the capacity ready state computation.
metlos 845ea69
Merge remote-tracking branch 'origin/member-info-in-spc-status-2' int…
metlos db8505f
Mirror the consumed capacity recorded in the ToolchainStatus to
metlos 499ef81
Merge branch 'master' into member-info-in-spc-status_controller-part
MatousJobanek 68d6be5
Simplify the logic in refreshStatus of the SPC.
metlos 9a0e4f6
Break up long assertions in the test
metlos b058ec5
Merge remote-tracking branch 'upstream/master' into member-info-in-sp…
metlos 6ffd1e5
Merge branch 'master' into member-info-in-spc-status_controller-part
metlos 90cf19a
Merge branch 'master' into member-info-in-spc-status_controller-part
fbm3307 a514b81
Merge branch 'master' into member-info-in-spc-status_controller-part
metlos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,19 +2,40 @@ | |||||
|
||||||
import ( | ||||||
"context" | ||||||
|
||||||
toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1" | ||||||
"k8s.io/apimachinery/pkg/types" | ||||||
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" | ||||||
"sigs.k8s.io/controller-runtime/pkg/log" | ||||||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||||||
) | ||||||
|
||||||
func MapToolchainClusterToSpaceProvisionerConfigs(ctx context.Context, cl runtimeclient.Client) func(context.Context, runtimeclient.Object) []reconcile.Request { | ||||||
return func(context context.Context, obj runtimeclient.Object) []reconcile.Request { | ||||||
func MapToolchainClusterToSpaceProvisionerConfigs(cl runtimeclient.Client) func(context.Context, runtimeclient.Object) []reconcile.Request { | ||||||
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request { | ||||||
if _, ok := obj.(*toolchainv1alpha1.ToolchainCluster); !ok { | ||||||
return nil | ||||||
} | ||||||
|
||||||
ret, err := findReferencingProvisionerConfigs(ctx, cl, runtimeclient.ObjectKeyFromObject(obj)) | ||||||
if err != nil { | ||||||
log.FromContext(ctx).Error(err, "failed to list SpaceProvisionerConfig objects while determining what objects to reconcile", | ||||||
"toolchainClusterCause", runtimeclient.ObjectKeyFromObject(obj)) | ||||||
"causeObj", runtimeclient.ObjectKeyFromObject(obj), "causeKind", "ToolchainCluster") | ||||||
return []reconcile.Request{} | ||||||
} | ||||||
return ret | ||||||
} | ||||||
} | ||||||
|
||||||
func MapToolchainStatusToSpaceProvisionerConfigs(cl runtimeclient.Client) func(context.Context, runtimeclient.Object) []reconcile.Request { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Similarly for this function may be we don't require it to be global |
||||||
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request { | ||||||
if _, ok := obj.(*toolchainv1alpha1.ToolchainStatus); !ok { | ||||||
return nil | ||||||
} | ||||||
|
||||||
ret, err := findAllSpaceProvisionerConfigsInNamespace(ctx, cl, obj.GetNamespace()) | ||||||
if err != nil { | ||||||
log.FromContext(ctx).Error(err, "failed to list SpaceProvisionerConfig objects while determining what objects to reconcile", | ||||||
"causeObj", runtimeclient.ObjectKeyFromObject(obj), "causeKind", "ToolchainStatus") | ||||||
return []reconcile.Request{} | ||||||
} | ||||||
return ret | ||||||
|
@@ -39,3 +60,20 @@ | |||||
} | ||||||
return ret, nil | ||||||
} | ||||||
|
||||||
func findAllSpaceProvisionerConfigsInNamespace(ctx context.Context, cl runtimeclient.Client, ns string) ([]reconcile.Request, error) { | ||||||
configs := &toolchainv1alpha1.SpaceProvisionerConfigList{} | ||||||
if err := cl.List(ctx, configs, runtimeclient.InNamespace(ns)); err != nil { | ||||||
return nil, err | ||||||
} | ||||||
ret := make([]reconcile.Request, 0, len(configs.Items)) | ||||||
for _, cfg := range configs.Items { | ||||||
ret = append(ret, reconcile.Request{ | ||||||
NamespacedName: types.NamespacedName{ | ||||||
Namespace: cfg.Namespace, | ||||||
Name: cfg.Name, | ||||||
}, | ||||||
}) | ||||||
} | ||||||
return ret, nil | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
minor doubt- i don't see this function being used out of the package or in e2e, why is it declared global?