@@ -69,6 +69,7 @@ type pathAnnotationPlugin struct {
6969
7070var pathAnnotationResources = sets .New [string ](
7171 apisv1alpha2 .Resource ("apiexports" ).String (),
72+ apisv1alpha2 .Resource ("apibindings" ).String (),
7273 tenancyv1alpha1 .Resource ("workspacetypes" ).String (),
7374)
7475
@@ -105,6 +106,10 @@ func (p *pathAnnotationPlugin) Admit(ctx context.Context, a admission.Attributes
105106
106107 logicalCluster , err := p .getLogicalCluster (clusterName , corev1alpha1 .LogicalClusterName )
107108 if err != nil {
109+ // We skip adding for system bindings if the logical cluster is not found during creation. This is racy during workspace bootstrap.
110+ if apierrors .IsNotFound (err ) && a .GetResource ().GroupResource () == apisv1alpha2 .Resource ("apibindings" ) {
111+ return nil
112+ }
108113 return admission .NewForbidden (a , fmt .Errorf ("cannot get this workspace: %w" , err ))
109114 }
110115 thisPath := logicalCluster .Annotations [core .LogicalClusterPathAnnotationKey ]
@@ -146,6 +151,10 @@ func (p *pathAnnotationPlugin) Validate(ctx context.Context, a admission.Attribu
146151 if pathAnnotationResources .Has (a .GetResource ().GroupResource ().String ()) || found {
147152 logicalCluster , err := p .getLogicalCluster (clusterName , corev1alpha1 .LogicalClusterName )
148153 if err != nil {
154+ // We skip adding for system bindings if the logical cluster is not found during creation. This is racy during workspace bootstrap.
155+ if apierrors .IsNotFound (err ) && a .GetResource ().GroupResource () == apisv1alpha2 .Resource ("apibindings" ) {
156+ return nil
157+ }
149158 return admission .NewForbidden (a , fmt .Errorf ("cannot get this workspace: %w" , err ))
150159 }
151160 thisPath := logicalCluster .Annotations [core .LogicalClusterPathAnnotationKey ]
@@ -154,7 +163,7 @@ func (p *pathAnnotationPlugin) Validate(ctx context.Context, a admission.Attribu
154163 }
155164
156165 if value != thisPath {
157- return admission .NewForbidden (a , fmt .Errorf ("annotation %q must match canonical path %q" , core .LogicalClusterPathAnnotationKey , thisPath ))
166+ return admission .NewForbidden (a , fmt .Errorf ("annotation %q must match canonical path %q, but got %q " , core .LogicalClusterPathAnnotationKey , thisPath , value ))
158167 }
159168 }
160169
0 commit comments