1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-28 03:10:32 +00:00
Commit Graph

60 Commits

Author SHA1 Message Date
vardhaman22
dae842ea98 updated wrangler from v2 to v3
also updated k8s dependencies to v0.30.1
2024-06-05 22:53:08 +05:30
Silvio Moioli
7a84620e8b
SQLite backed cache (#223)
This uses SQLite-backed informers provided by Lasso with https://github.com/rancher/lasso/pull/65 to implement Steve API (/v1/) functionality.

This new functionality is available behind a feature flag to be specified at Steve startup

See https://confluence.suse.com/pages/viewpage.action?pageId=1359086083 

Co-authored-by: Ricardo Weir <ricardo.weir@suse.com>
Co-authored-by: Michael Bolot <michael.bolot@suse.com>
Co-authored-by: Silvio Moioli <silvio@moioli.net>
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2024-06-05 16:17:12 +02:00
Ricardo Weir
d42a5bc545
Skip key generation if cache disabled (#170) 2024-04-19 09:43:15 -04:00
Michael Bolot
7913f2782a
Merge pull request #141 from moio/watchnames_propagate_errors
WatchNames: return errors via WebSocket
2024-03-01 09:48:41 -06:00
Kevin Joiner
e35a044d5a Bumps rancher/wrangler to it's tagged v2 version.
The previous wrangler commit included all of the v2 changes.
Except for the import paths changes.
2024-01-24 10:24:01 -05:00
Silvio Moioli
d138622063
adapt tests
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2024-01-23 11:25:29 +01:00
Silvio Moioli
1585ed3f7a
WatchNames: return errors via WebSocket
Align behavior with plain Watch, which also does the same.

Fixes https://github.com/rancher/rancher/issues/41809

Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-12-22 20:10:51 +01:00
Michael Bolot
0b23400f9f Updating ByNames to not return nil, nil
ByNames could previously return a nil value and a nil error. This caused
issues when other parts of the application
(pkg/stores/partition/parallel.go) tried to use the result. Now this
will return an empty list on the error condition, instead of nil
2023-10-16 14:33:35 -05:00
Colleen Murphy
52e7ebfd1b Fix partition unit test
Remove unnecessary items from the `access` slice in one of the unit
tests. Each item in `access` corresponds to one request in `apiOps`, so
they should have the same number of elements.
2023-09-20 13:58:37 -07:00
vardhaman22
ebc8b721a8 updated deps for k8s 1.27 2023-08-23 00:42:52 +05:30
Colleen Murphy
d040cffef3
Merge pull request #112 from cmurphy/unformatter-store
Drop unrecognized fields before update
2023-07-17 09:02:51 -07:00
Colleen Murphy
adaa391ddf Drop unrecognized fields before update
Add a nested store to the proxy store to strip non-Kubernetes fields
from the object being updated.

The steve formatter and proxy store adds fields to objects when it
outputs them to the client, for usability by the UI. It adds the
object's fields[1], relationships to other objects[2], a summary of the
object's state[3], and additional information in the conditions[4].
These fields are not native to Kubernetes, so when a client submits the
object back as an update, Kubernetes reports a warning that they are
unrecognized. This change ensures the extra fields are removed before
submitting the update.

[1] bf2e9655f5/pkg/stores/proxy/proxy_store.go (L189)
[2] bf2e9655f5/pkg/resources/common/formatter.go (L106)
[3] bf2e9655f5/pkg/resources/common/formatter.go (L100)
[4] bf2e9655f5/pkg/resources/common/formatter.go (L108)
2023-07-14 14:54:01 -07:00
Colleen Murphy
8128019458
Merge pull request #80 from moio/fix_lru_concurrent_map_write
LRU cache: fix concurrent map write
2023-06-23 13:22:50 -07:00
Ricardo Weir
c53bd62e9c Add tests 2023-06-09 13:18:32 -07:00
Silvio Moioli
7010a5e6c7
proxy_store: improve error handling
This prevents a goroutine leak when item.Object is a `runtime.Object` but not a
`metav1.Object`, as in that case `WatchNames`’s `for` loop will quit early and
subsequent calls to `returnErr` will remain parked forever.

This helps with https://github.com/rancher/rancher/issues/41225
Fuller explanation in https://github.com/rancher/steve/pull/107
2023-06-09 10:55:26 +02:00
Colleen Murphy
1dfd3c711f
Merge pull request #105 from cmurphy/projects-filtering
Add projectsornamespaces query parameter
2023-05-12 10:58:54 -07:00
Colleen Murphy
84dedac146 Add projectsornamespaces query parameter
Add a new query parameter to filter resources by their namespace or
their namespace's project. This parameter is separate from the existing
`filter` parameter.

Filter by a comma-separated list of projects and/or namespaces with:

?projectsornamespaces=p1,n1,n2

The result can be negated with the ! operator:

?projectsornamespaces!=p1,n1,n2
2023-05-11 14:17:39 -07:00
Ricardo Weir
0cabe8de10 Update tests 2023-05-10 22:58:41 -07:00
Ricardo Weir
3db0918eb8 Change cache default to false 2023-05-10 22:58:35 -07:00
Colleen Murphy
61a39906f9 Add support for NOT filters
This change adds support for excluding results using the != operator.

Example to exclude all results with name "example":

?filter=metadata.name!=example

Include all results from namespace "example" but exclude those with name
"example":

?filter=metadata.namespace=example&metadata.name!=example

Exclude results with name "foo" OR exclude results with name "bar"
(effectively includes results of both types):

?filter=metadata.name!=foo,metadata.name!=bar
2023-03-23 14:12:14 -07:00
Colleen Murphy
2e4ee872d9 Add support for OR filters
Currently, multiple filters can be appended on the query string, and
each subsequent filter is ANDed with the set. Items that pass through
the filter set must match every filter in the set.

This change adds support for OR filters. A single filter key can specify
multiple filters, separated by ','. An item that passes this filter can
match any filter in the set.

For example, this filter matches items that have either "name" or
"namespace" that match "example":

?filter=metadata.name=example,metadata.namespace=example

This filter matches items that have "name" that matches either "foo" or
"bar":

?filter=metadata.name=foo,metadata.name=bar

Specifying more than one filter key in the query still ANDs each inner
filter set together. This set of filters can match either a name of
"foo" or "bar", but must in all cases match namespace "abc":

?filter=metadata.name=foo,metadata.name=bar&filter=metadata.namespace=abc
2023-03-23 14:12:13 -07:00
Silvio Moioli
44a6096815
LRU cache: fix concurrent map write
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-03-15 10:07:43 +01:00
Michael Bolot
59a2c55e14 Fixes a bug with resource.error watch events
Watch events need to have a type defined by
k8s.io/apimachinery/pkg/watch to be properly interpreted. Fixes
a bug where this was not the case
2023-01-11 15:43:42 -06:00
Chad Roberts
65ca114ce0
Expose WarningBuffer type for external use 2023-01-03 11:32:46 -05:00
Michael Bolot
956b7351aa
Initial implmentation of warning headers
Attempts to pass through warning headers which k8s returns.
Requires an update to rancher/apiserver.
2022-12-30 12:11:14 -05:00
Colleen Murphy
7565dba268
Merge pull request #63 from cmurphy/pagination-sorting-filtering
Pagination, sorting, filtering
2022-12-20 15:59:29 -08:00
Colleen Murphy
fa7fb37245 Retrieve exact revision regardless of cache state
Without this change, the cache is checked if a revision is specified,
but the revision is ignored if the value is not found in the cache. This
is a problem if by chance sequential paginated requests land on separate
pods, because a different version number may be fetched on the sequent
request and cause the caches to be inconsistent with one another. This
change ensures that `revision` is passed as `resourceVersion` to the
Kubernetes request, since `revision` has no meaning to Kubernetes.
2022-12-20 15:01:20 -08:00
Colleen Murphy
7c0228e575 Use limit=-1 to disable default list limit
The default chunk size in the partition was set to 100000. It could be
overridden as a larger or smaller number, but not disabled altogether.
This change adds the ability for users to explicitly opt out of the
limit by specifying a negative number or zero. The default behavior is
the same.
2022-12-20 15:01:20 -08:00
Colleen Murphy
b151f25581 Add secondary sort parameter
Extend the sorting functionality in the partition store to support
primary and secondary sorting criteria. Sorting parameters are specified
by a single 'sort' query and comma separated. Example:

Sort by name and creation time:

GET /v1/secrets?sort=metadata.name,metadata.creationTimestamp

Reverse sort by name, normal sort by creation time:

GET /v1/secrets?sort=-metadata.name,metadata.creationTimestamp

Normal sort by name, reverse sort by creation time:

GET /v1/secrets?sort=metadata.name,-metadata.creationTimestamp
2022-12-20 15:01:19 -08:00
Colleen Murphy
52e189b1ff Add pagination tests for partition listing 2022-12-20 15:01:19 -08:00
Colleen Murphy
b0eb50f38d Add caching to pagination
Cache filtered, sorted results for fast subsequent page retrieval.

Requests for cached queries need to include the list revision number
along with other queries. If no specific revision is requested, a new
fetch is done in order to get the latest revision. The revision is
included in the list response.

Example first request:

GET /v1/secrets?pagesize=10

Example subsequent page request:

GET /v1/secrets?pagesize=10&page=1&revision=107740
2022-12-20 15:01:19 -08:00
Colleen Murphy
9f1a27db06 Add pagination to partition store
Extend the partition store to parse page and pagesize parameters and
return a subset of list results. The total number of pages is included
in the list response.

Request an initial page:

GET /v1/secrets?pagesize=10

or

GET /v1/secrets?pagesize=10&page=1

Request subsequent pages, or arbitrary pages:

GET /v1/secrets?pagesize=10&page=37

If a page number is out of bounds, an empty list is returned.
2022-12-20 15:01:15 -08:00
Colleen Murphy
adecbd9122 Add sorting to partition store
Extend the partition store to parse the "sort" query parameter as a
sorting condition. Dot notation is used to denote the object field.
Preceding the key with "-" denotes descending (reverse) order.

Example sorting by name:

GET /v1/secrets?sort=metadata.name

Reverse sorting by name:

GET /v1/secrets?sort=-metadata.name

All values are converted to strings and sorted lexicographically.
2022-12-14 09:13:58 -08:00
Colleen Murphy
f8eaa11d83 Add filtering to partition store
Extend the partition store to parse query params as list filters. Filter
keys use dot notation to denote the subfield of an object to filter on.
Example:

GET /v1/secrets?filter=metadata.name=foo

Filters are ANDed together, so an object must match all filters to be
included in the list. Example:

GET /v1/secrets?filter=metadata.name=foo&filter=metadata.namespace=bar

Arrays are searched for matching items. If any item in the array
matches, the item is included in the list. Example:

GET /v1/pods?filter=spec.containers.image=alpine
2022-12-14 09:13:58 -08:00
Colleen Murphy
60d234d282 Refactor proxy store
Filtering and sorting needs to operate on unstructured data. It also
needs to operate after the parallel partitioner, higher in the store
stack. This means that the proxy Store needs to return raw, unstructured
data up to the partitioner. This change moves all conversions from
unstructured Kubernetes types to apiserver objects up from the proxy
store into the partitioner.
2022-12-14 09:13:58 -08:00
Colleen Murphy
1d4a130974 Add unit tests for partition listing 2022-12-14 09:13:58 -08:00
Colleen Murphy
23fdd030e6 Add tests for RBAC partitioner 2022-12-13 10:09:30 -08:00
Colleen Murphy
b16d502fc7 docs: Add docs for partition and proxy store 2022-10-31 10:34:41 -07:00
Colleen Murphy
ea61c2187a cleanup: Remove unused namespace constraint
The use of AddNamespaceConstraint was removed in e35b8304 of
rancher/rancher, so there is no possibility of there being a namespace
constraint in the request context. Remove the unused function and the
unused codepath from the rbac store.
2022-10-27 14:27:13 -07:00
Colleen Murphy
475f311d0b cleanup: Remove unused switchstore store
Usage of the switchstore store was removed when the clusters resource
was removed in dcea1db.
2022-10-27 14:27:13 -07:00
Michael Bolot
b73cc57b20 Adding validate phase to the CI
Adds a validate phase to the CI which runs a linter. Also fixes
linter issues discovered during the initial run
2022-10-14 15:21:17 -05:00
Colleen Murphy
11fe86ab7e Make watch timeout configurable
By default, a watch times out after 30 minutes. For debugging purposes,
it's convenient if this can be decreased. Add an environment variable
CATTLE_WATCH_TIMEOUT_SECONDS to enable setting the timeout in seconds.
2022-06-13 16:01:55 -07:00
Colleen Murphy
ada5b33d98 Return websocket error and add logging for watches
Add debug logs and send websocket messages when the watch is closed
unexpectedly.

In addition to being helpful for debugging, the dashboard specifically
looks for a `resource.error` event containing the string "too old" in
order to trigger the watch to be resynced with a refreshed revision
number.  Without this error returned, the dashboard will only see
`resource.stop` events and never change its behavior, continuing to try
to restart the watch with an incorrect resource version.
2022-06-13 15:54:40 -07:00
Ricardo Weir
e9472ecc34 Add metrics 2022-02-14 17:39:37 -07:00
michelia
42c575a009 Fixed errors in obtaining object relationships
Issue: https://github.com/harvester/harvester/issues/1857
2022-01-26 19:31:03 +08:00
CMC
fea67065db
feat: support k8s version less than 1.16 2021-11-25 16:16:20 +08:00
Darren Shepherd
0414d4acf5 If the user doesn't specify a resourceVersion default to "" not latest 2021-08-10 10:43:34 -07:00
Darren Shepherd
9f5d802708 Cleanup schema change reporting 2021-08-09 16:47:09 -07:00
Darren Shepherd
eba8358f2a Fix issues when creating clusterrolebindings to namespaces objects 2021-07-23 23:46:03 -07:00
Darren Shepherd
991a2a1776 Don't mask errors when doing by name lookups 2021-07-23 23:45:13 -07:00