Limit list to current namespace for backup and restore (#1106)
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>pull/1117/head
parent
597d9cdedf
commit
f8c3c2e138
|
|
@ -153,7 +153,10 @@ func cleanPreviousInstallation(rctx *RestoreContext, dataDir string) (bool, erro
|
|||
skipBackupObjectsRequirement, _ := labels.NewRequirement(deploy.KubernetesPartOfLabelKey, selection.NotEquals, []string{checlusterbackup.BackupCheEclipseOrg})
|
||||
|
||||
cheResourcesLabelSelector := labels.NewSelector().Add(*cheInstanceRequirement).Add(*cheNameRequirement).Add(*skipBackupObjectsRequirement)
|
||||
cheResourcesListOptions := &client.ListOptions{LabelSelector: cheResourcesLabelSelector}
|
||||
cheResourcesListOptions := &client.ListOptions{
|
||||
LabelSelector: cheResourcesLabelSelector,
|
||||
Namespace: rctx.namespace,
|
||||
}
|
||||
cheResourcesMatchingLabelsSelector := client.MatchingLabelsSelector{Selector: cheResourcesLabelSelector}
|
||||
|
||||
// Delete all Che related deployments, but keep operator (excluded by name) and internal backup server (excluded by label)
|
||||
|
|
|
|||
|
|
@ -148,7 +148,8 @@ func (r *ReconcileCheClusterRestore) doReconcile(restoreCR *chev1.CheClusterRest
|
|||
if backupServerConfigName == "" {
|
||||
// Try to find backup server configuration in the same namespace
|
||||
cheBackupServersConfigurationList := &chev1.CheBackupServerConfigurationList{}
|
||||
if err := r.client.List(context.TODO(), cheBackupServersConfigurationList); err != nil {
|
||||
listOptions := &client.ListOptions{Namespace: restoreCR.GetNamespace()}
|
||||
if err := r.client.List(context.TODO(), cheBackupServersConfigurationList, listOptions); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if len(cheBackupServersConfigurationList.Items) != 1 {
|
||||
|
|
|
|||
|
|
@ -568,9 +568,10 @@ func ReloadCheCluster(client client.Client, cheCluster *orgv1.CheCluster) error
|
|||
cheCluster)
|
||||
}
|
||||
|
||||
func FindCheCRinNamespace(client client.Client, namespace string) (*orgv1.CheCluster, int, error) {
|
||||
func FindCheCRinNamespace(cl client.Client, namespace string) (*orgv1.CheCluster, int, error) {
|
||||
cheClusters := &orgv1.CheClusterList{}
|
||||
if err := client.List(context.TODO(), cheClusters); err != nil {
|
||||
listOptions := &client.ListOptions{Namespace: namespace}
|
||||
if err := cl.List(context.TODO(), cheClusters, listOptions); err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
||||
|
|
@ -580,7 +581,7 @@ func FindCheCRinNamespace(client client.Client, namespace string) (*orgv1.CheClu
|
|||
|
||||
cheCR := &orgv1.CheCluster{}
|
||||
namespacedName := types.NamespacedName{Namespace: namespace, Name: cheClusters.Items[0].GetName()}
|
||||
err := client.Get(context.TODO(), namespacedName, cheCR)
|
||||
err := cl.Get(context.TODO(), namespacedName, cheCR)
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue