Skip to content

Commit fa1929b

Browse files
authored
Merge pull request #3389 from jwtty/support-cluster-scoped
feat: support cluster-scoped objs in wait_for_generic_k8s_object
2 parents fef7446 + 8b4ef8a commit fa1929b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clusterloader2/pkg/measurement/common/wait_for_generic_k8s_object.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ func getGroupVersionResource(params map[string]interface{}) (schema.GroupVersion
133133
func getNamespaces(namespacesPrefix string, params map[string]interface{}) (measurementutil.NamespacesRange, error) {
134134
namespaceRange, err := util.GetMap(params, "namespaceRange")
135135
if err != nil {
136+
if util.IsErrKeyNotFound(err) {
137+
// If not provided, assume waiting for cluster-scoped objects.
138+
return measurementutil.NamespacesRange{
139+
Prefix: "",
140+
}, nil
141+
}
136142
return measurementutil.NamespacesRange{}, err
137143
}
138144
minParam, err := util.GetInt(namespaceRange, "min")

clusterloader2/pkg/measurement/util/wait_for_conditions.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ func (o *WaitForGenericK8sObjectsOptions) Summary() string {
6565

6666
// String returns printable representation of the namespaces range.
6767
func (nr *NamespacesRange) String() string {
68+
if nr.Prefix == "" {
69+
return ""
70+
}
6871
return fmt.Sprintf("%s-(%d-%d)", nr.Prefix, nr.Min, nr.Max)
6972
}
7073

7174
// getMap returns a map with namespaces which should be queried.
7275
func (nr *NamespacesRange) getMap() map[string]bool {
7376
result := map[string]bool{}
77+
if nr.Prefix == "" {
78+
result[""] = true // Cluster-scoped objects.
79+
return result
80+
}
7481
for i := nr.Min; i <= nr.Max; i++ {
7582
result[fmt.Sprintf("%s-%d", nr.Prefix, i)] = true
7683
}

0 commit comments

Comments
 (0)