You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
klog.Warning("ServiceExport exists in the member cluster, request is denied", "operation", req.Operation, "memberCluster", mcObjectName)
55
+
returnadmission.Denied(fmt.Sprintf("Please delete serviceExport %s in the member cluster before leaving, request is denied", internalServiceExport.Spec.ServiceReference.NamespacedName))
56
+
}
57
+
}
58
+
returnadmission.Allowed("Member cluster is ready to leave")
59
+
}
60
+
37
61
varmc clusterv1beta1.MemberCluster
38
-
klog.V(2).InfoS("Validating webhook handling member cluster", "operation", req.Operation, "namespacedName", types.NamespacedName{Name: req.Name})
39
62
iferr:=v.decoder.Decode(req, &mc); err!=nil {
40
63
klog.ErrorS(err, "Failed to decode member cluster object for validating fields", "userName", req.UserInfo.Username, "groups", req.UserInfo.Groups)
Expect(hubClient.Create(ctx, internalServiceExport)).To(Succeed(), "Failed to create internalServiceExport")
134
+
}
135
+
})
136
+
137
+
It("Should fail the unjoin requests", func() {
138
+
foridx:=rangeallMemberClusters {
139
+
memberCluster:=allMemberClusters[idx]
140
+
mcObj:=&clusterv1beta1.MemberCluster{
141
+
ObjectMeta: metav1.ObjectMeta{
142
+
Name: memberCluster.ClusterName,
143
+
},
144
+
}
145
+
err:=hubClient.Delete(ctx, mcObj)
146
+
Expect(err).ShouldNot(Succeed(), "Want the deletion to be denied")
147
+
varstatusErr*apierrors.StatusError
148
+
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Delete memberCluster call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&apierrors.StatusError{})))
149
+
Expect(statusErr.ErrStatus.Message).Should(MatchRegexp("Please delete serviceExport test-namespace/test-svc in the member cluster before leaving, request is denied"))
150
+
}
151
+
})
152
+
153
+
It("Deleting the internalServiceExports", func() {
0 commit comments