generate work name based on different resource (#232)

Signed-off-by: lihanbo <lihanbo2@huawei.com>
This commit is contained in:
Hanbo Li 2021-03-25 11:59:06 +08:00 committed by GitHub
parent 51d56624c6
commit 65a4f32e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -194,7 +194,13 @@ func (c *WorkStatusController) handleDeleteEvent(key string) error {
return err
}
workName := names.GenerateBindingName(clusterWorkload.Namespace, clusterWorkload.GVK.Kind, clusterWorkload.Name)
var workName string
if clusterWorkload.Namespace == "" {
workName = names.GenerateClusterResourceBindingName(clusterWorkload.GVK.Kind, clusterWorkload.Name)
} else {
workName = names.GenerateBindingName(clusterWorkload.Namespace, clusterWorkload.GVK.Kind, clusterWorkload.Name)
}
work := &workv1alpha1.Work{}
if err := c.Client.Get(context.TODO(), client.ObjectKey{Namespace: executionSpace, Name: workName}, work); err != nil {
// Stop processing if resource no longer exist.