Skip to content

Commit 1acc016

Browse files
Rebased
1 parent eb21e6c commit 1acc016

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

config/openshift/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ bases:
1919

2020
patches:
2121
- path: manager_webhook_patch.yaml
22-
- path: webhookcainjection_patch.yaml
22+
- path: webhookcainjection_mpatch.yaml
23+
- path: webhookcainjection_vpatch.yaml
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This patch add annotation to admission webhook config
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: ValidatingWebhookConfiguration
4+
metadata:
5+
name: validating-webhook-configuration
6+
annotations:
7+
service.beta.openshift.io/inject-cabundle: "true"

pkg/controllers/raycluster_webhook.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323

2424
corev1 "k8s.io/api/core/v1"
2525
"k8s.io/apimachinery/pkg/runtime"
26+
"k8s.io/apimachinery/pkg/util/validation/field"
2627
"k8s.io/utils/pointer"
2728
ctrl "sigs.k8s.io/controller-runtime"
2829
logf "sigs.k8s.io/controller-runtime/pkg/log"
2930
"sigs.k8s.io/controller-runtime/pkg/webhook"
31+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3032

3133
"github.com/project-codeflare/codeflare-operator/pkg/config"
32-
"k8s.io/apimachinery/pkg/util/validation/field"
33-
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3434
)
3535

3636
// log is for logging in this package.
@@ -42,22 +42,25 @@ func SetupRayClusterWebhookWithManager(mgr ctrl.Manager, cfg *config.KubeRayConf
4242
WithDefaulter(&rayClusterDefaulter{
4343
Config: cfg,
4444
}).
45-
WithValidator(&rayClusterValidator{}).
45+
WithValidator(&rayClusterValidator{
46+
Config: cfg,
47+
}).
4648
Complete()
4749
}
4850

4951
// +kubebuilder:webhook:path=/mutate-ray-io-v1-raycluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayclusters,verbs=create;update,versions=v1,name=mraycluster.kb.io,admissionReviewVersions=v1
50-
//+kubebuilder:webhook:path=/validate-ray-io-v1-raycluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayclusters,verbs=create;update,versions=v1,name=vraycluster.kb.io,admissionReviewVersions=v1
52+
// +kubebuilder:webhook:path=/validate-ray-io-v1-raycluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=ray.io,resources=rayclusters,verbs=create;update,versions=v1,name=vraycluster.kb.io,admissionReviewVersions=v1
5153

5254
type rayClusterDefaulter struct {
5355
Config *config.KubeRayConfiguration
5456
}
55-
type rayClusterValidator struct{}
57+
type rayClusterValidator struct {
58+
Config *config.KubeRayConfiguration
59+
}
5660

5761
var _ webhook.CustomDefaulter = &rayClusterDefaulter{}
5862
var _ webhook.CustomValidator = &rayClusterValidator{}
5963

60-
6164
// Default implements webhook.Defaulter so a webhook will be registered for the type
6265
func (r *rayClusterDefaulter) Default(ctx context.Context, obj runtime.Object) error {
6366
raycluster := obj.(*rayv1.RayCluster)
@@ -157,7 +160,7 @@ func (v *rayClusterValidator) ValidateCreate(ctx context.Context, obj runtime.Ob
157160
func (v *rayClusterValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
158161
newRayCluster := newObj.(*rayv1.RayCluster)
159162
if !newRayCluster.DeletionTimestamp.IsZero() {
160-
// Object is being deleted, skip validations
163+
// Object is being deleted, skip validations
161164
return nil, nil
162165
}
163166
warnings, err := v.ValidateCreate(ctx, newRayCluster)

0 commit comments

Comments
 (0)