From c70b5d2418c0c47cb24ffbbb702faaff0f32037a Mon Sep 17 00:00:00 2001 From: Johannes Aubart Date: Fri, 1 Aug 2025 13:01:04 +0200 Subject: [PATCH 1/2] add list of exposed service resources to ServiceProvider status --- .../openmcp.cloud_serviceproviders.yaml | 20 +++++++++++++++++++ .../v1alpha1/serviceprovider_types.go | 6 +++--- .../v1alpha1/zz_generated.deepcopy.go | 5 +++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api/crds/manifests/openmcp.cloud_serviceproviders.yaml b/api/crds/manifests/openmcp.cloud_serviceproviders.yaml index f80f2a3..2932f48 100644 --- a/api/crds/manifests/openmcp.cloud_serviceproviders.yaml +++ b/api/crds/manifests/openmcp.cloud_serviceproviders.yaml @@ -160,6 +160,26 @@ spec: type: integer phase: type: string + resources: + description: Resources is a list of Group/Version/Kind that specifies + which service resources this provider exposes. + items: + description: |- + GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion + to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling + properties: + group: + type: string + kind: + type: string + version: + type: string + required: + - group + - kind + - version + type: object + type: array required: - observedGeneration type: object diff --git a/api/provider/v1alpha1/serviceprovider_types.go b/api/provider/v1alpha1/serviceprovider_types.go index ab8723c..7a708d6 100644 --- a/api/provider/v1alpha1/serviceprovider_types.go +++ b/api/provider/v1alpha1/serviceprovider_types.go @@ -21,9 +21,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // ServiceProviderSpec defines the desired state of ServiceProvider. type ServiceProviderSpec struct { DeploymentSpec `json:",inline"` @@ -32,6 +29,9 @@ type ServiceProviderSpec struct { // ServiceProviderStatus defines the observed state of ServiceProvider. type ServiceProviderStatus struct { DeploymentStatus `json:",inline"` + + // Resources is a list of Group/Version/Kind that specifies which service resources this provider exposes. + Resources []metav1.GroupVersionKind `json:"resources,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/provider/v1alpha1/zz_generated.deepcopy.go b/api/provider/v1alpha1/zz_generated.deepcopy.go index cab9f7f..f36a5b3 100644 --- a/api/provider/v1alpha1/zz_generated.deepcopy.go +++ b/api/provider/v1alpha1/zz_generated.deepcopy.go @@ -347,6 +347,11 @@ func (in *ServiceProviderSpec) DeepCopy() *ServiceProviderSpec { func (in *ServiceProviderStatus) DeepCopyInto(out *ServiceProviderStatus) { *out = *in in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]v1.GroupVersionKind, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceProviderStatus. From f42fce240e7678e7aa39a86fe496bc40bbdde5e1 Mon Sep 17 00:00:00 2001 From: Johannes Aubart Date: Fri, 1 Aug 2025 13:01:35 +0200 Subject: [PATCH 2/2] add WaitForClusterDeletion flag to ClusterRequest spec --- api/clusters/v1alpha1/clusterrequest_types.go | 9 +++++++++ api/clusters/v1alpha1/zz_generated.deepcopy.go | 7 ++++++- .../clusters.openmcp.cloud_clusterrequests.yaml | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api/clusters/v1alpha1/clusterrequest_types.go b/api/clusters/v1alpha1/clusterrequest_types.go index ef8d37c..f3f1ebd 100644 --- a/api/clusters/v1alpha1/clusterrequest_types.go +++ b/api/clusters/v1alpha1/clusterrequest_types.go @@ -18,6 +18,15 @@ type ClusterRequestSpec struct { // Purpose is the purpose of the requested cluster. // +kubebuilder:validation:MinLength=1 Purpose string `json:"purpose"` + + // WaitForClusterDeletion specifies whether the ClusterProvider should remove its finalizer from the ClusterRequest only after the corresponding Cluster has been deleted. + // 'true' means that the finalizer stays until the Cluster is gone, 'false' means that the finalizer can be removed before the Cluster has been deleted. + // If not specified, this defaults to 'true' if the cluster's tenancy is 'Exclusive' and to 'false' otherwise. + // Note that the delayed finalizer removal only occurs if the deletion of the ClusterRequest actually triggers the deletion of the Cluster. + // If the cluster is shared with further ClusterRequests using it or if it does not have the 'clusters.openmcp.cloud/delete-without-requests' label set to 'true', + // the finalizer will be removed without waiting for the Cluster deletion, independently of this setting. + // +optional + WaitForClusterDeletion *bool `json:"waitForClusterDeletion,omitempty"` } // +kubebuilder:validation:XValidation:rule="!has(oldSelf.cluster) || has(self.cluster)", message="cluster may not be removed once set" diff --git a/api/clusters/v1alpha1/zz_generated.deepcopy.go b/api/clusters/v1alpha1/zz_generated.deepcopy.go index adb1b6e..f076a30 100644 --- a/api/clusters/v1alpha1/zz_generated.deepcopy.go +++ b/api/clusters/v1alpha1/zz_generated.deepcopy.go @@ -267,7 +267,7 @@ func (in *ClusterRequest) DeepCopyInto(out *ClusterRequest) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -324,6 +324,11 @@ func (in *ClusterRequestList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterRequestSpec) DeepCopyInto(out *ClusterRequestSpec) { *out = *in + if in.WaitForClusterDeletion != nil { + in, out := &in.WaitForClusterDeletion, &out.WaitForClusterDeletion + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRequestSpec. diff --git a/api/crds/manifests/clusters.openmcp.cloud_clusterrequests.yaml b/api/crds/manifests/clusters.openmcp.cloud_clusterrequests.yaml index a89c8d5..7b9f4bf 100644 --- a/api/crds/manifests/clusters.openmcp.cloud_clusterrequests.yaml +++ b/api/crds/manifests/clusters.openmcp.cloud_clusterrequests.yaml @@ -60,6 +60,15 @@ spec: description: Purpose is the purpose of the requested cluster. minLength: 1 type: string + waitForClusterDeletion: + description: |- + WaitForClusterDeletion specifies whether the ClusterProvider should remove its finalizer from the ClusterRequest only after the corresponding Cluster has been deleted. + 'true' means that the finalizer stays until the Cluster is gone, 'false' means that the finalizer can be removed before the Cluster has been deleted. + If not specified, this defaults to 'true' if the cluster's tenancy is 'Exclusive' and to 'false' otherwise. + Note that the delayed finalizer removal only occurs if the deletion of the ClusterRequest actually triggers the deletion of the Cluster. + If the cluster is shared with further ClusterRequests using it or if it does not have the 'clusters.openmcp.cloud/delete-without-requests' label set to 'true', + the finalizer will be removed without waiting for the Cluster deletion, independently of this setting. + type: boolean required: - purpose type: object