Skip to content

Commit

Permalink
feat: update k8s to 1.29
Browse files Browse the repository at this point in the history
Signed-off-by: nwaiyatharee <[email protected]>
  • Loading branch information
agoda-devops-container committed Sep 23, 2024
1 parent eaacca6 commit 3161895
Show file tree
Hide file tree
Showing 18 changed files with 346 additions and 557 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ jobs:
- name: install Kubebuilder
uses: RyanSiu1995/[email protected]
with:
version: 3.1.0
version: 3.15.1
kubebuilderOnly: false
kubernetesVersion: v1.22.0
kubernetesVersion: v1.29.0


- name: Run unit-test
Expand Down
1 change: 0 additions & 1 deletion apis/cue/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apis/oam/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions controller/client/controller_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func DefaultNewControllerClient(cache cache.Cache, config *rest.Config, options
dClient := &delegatingClient{
scheme: mClient.Scheme(),
mapper: mClient.RESTMapper(),
client: mClient,
Reader: &delegatingReader{
CacheReader: mCache,
ClientReader: mClient,
Expand Down
11 changes: 11 additions & 0 deletions controller/client/delegating_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type delegatingClient struct {

scheme *runtime.Scheme
mapper meta.RESTMapper
client client.Client
}

// Scheme returns the scheme this client is using.
Expand All @@ -52,6 +53,16 @@ func (d *delegatingClient) RESTMapper() meta.RESTMapper {
return d.mapper
}

// RESTMapper returns the rest mapper this client is using.
func (d *delegatingClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error) {
return d.client.GroupVersionKindFor(obj)
}

// RESTMapper returns the rest mapper this client is using.
func (d *delegatingClient) IsObjectNamespaced(obj runtime.Object) (bool, error) {
return d.client.IsObjectNamespaced(obj)
}

// delegatingReader extend the delegatingReader from controller-runtime/pkg/client
// 1. for requests not in local cluster, disable cache
// 2. for structured types, inherit the cache blacklist
Expand Down
2 changes: 1 addition & 1 deletion controller/reconciler/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("Test clients", func() {

const path = "/trigger"
ch := reconciler.RegisterTriggerHandler(mgr, path, 1024)
svr := httptest.NewServer(mgr.GetWebhookServer().WebhookMux)
svr := httptest.NewServer(mgr.GetWebhookServer().WebhookMux())
defer svr.Close()

resp, err := http.Get(svr.URL + path)
Expand Down
26 changes: 14 additions & 12 deletions controller/sharding/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@ package sharding

import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// BuildCache add shard-id label selector for given typed object
func BuildCache(scheme *runtime.Scheme, shardingObjects ...client.Object) cache.NewCacheFunc {
return BuildCacheWithOptions(cache.Options{Scheme: scheme}, shardingObjects...)
func BuildCache(shardingObjects ...client.Object) cache.NewCacheFunc {
return BuildCacheWithOptions(shardingObjects...)
}

// BuildCacheWithOptions add shard-id label selector to sharding objects with options
func BuildCacheWithOptions(opts cache.Options, shardingObjects ...client.Object) cache.NewCacheFunc {
if EnableSharding {
ls := labels.SelectorFromSet(map[string]string{LabelKubeVelaScheduledShardID: ShardID})
if opts.SelectorsByObject == nil {
opts.SelectorsByObject = map[client.Object]cache.ObjectSelector{}
}
for _, obj := range shardingObjects {
opts.SelectorsByObject[obj] = cache.ObjectSelector{Label: ls}
func BuildCacheWithOptions(shardingObjects ...client.Object) cache.NewCacheFunc {
return func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
if EnableSharding {
ls := labels.SelectorFromSet(map[string]string{LabelKubeVelaScheduledShardID: ShardID})
if opts.ByObject == nil {
opts.ByObject = map[client.Object]cache.ByObject{}
}
for _, obj := range shardingObjects {
opts.ByObject[obj] = cache.ByObject{Label: ls}
}
}
return cache.New(config, opts)
}
return cache.BuilderWithOptions(opts)
}
2 changes: 1 addition & 1 deletion controller/sharding/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = Describe("Test sharding", func() {
Ω(cli.Create(ctx, cm2)).To(Succeed())

By("Test cache")
store, err := sharding.BuildCache(scheme.Scheme, &corev1.ConfigMap{})(cfg, cache.Options{})
store, err := sharding.BuildCache(&corev1.ConfigMap{})(cfg, cache.Options{Scheme: scheme.Scheme})
Ω(err).To(Succeed())
go func() { _ = store.Start(ctx) }()
Eventually(func(g Gomega) {
Expand Down
27 changes: 15 additions & 12 deletions crds/core.oam.dev_definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: definitions.core.oam.dev
spec:
group: core.oam.dev
Expand All @@ -24,20 +23,24 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: Definition is a internal storage for KubeVela definitions, it
will never be exposed directly to end users. It will just like a configmap
as internal usage, using a standalone CRD can help us optimize the efficiency
for informer.
description: |-
Definition is a internal storage for KubeVela definitions, it will never be exposed directly to end users.
It will just like a configmap as internal usage, using a standalone CRD can help us optimize the efficiency for informer.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
20 changes: 12 additions & 8 deletions crds/cue.oam.dev_packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: packages.cue.oam.dev
spec:
group: cue.oam.dev
Expand Down Expand Up @@ -36,14 +35,19 @@ spec:
description: Package is an extension for cuex engine
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
Loading

0 comments on commit 3161895

Please sign in to comment.