Skip to content

Commit

Permalink
Some notFound Conditions are now managed, and some tests are provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreagit97 committed May 26, 2021
1 parent 9faf5c4 commit 9253a6b
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 236 deletions.
2 changes: 1 addition & 1 deletion apis/virtualKubelet/v1alpha1/namespacemap_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type RemoteNamespaceStatus struct {
// RemoteNamespace is the name chosen by the user at creation time according to NamespaceMappingStrategy
RemoteNamespace string `json:"remoteNamespace,omitempty"`
// Phase is the remote Namespace's actual status (Accepted,Refused).
// +kubebuilder:validation:Enum="Accepted";"CreationLoopBackOff"
// +kubebuilder:validation:Enum="Accepted";"CreationLoopBackOff";"Terminating"
Phase MappingPhase `json:"phase,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ spec:
enum:
- Accepted
- CreationLoopBackOff
- Terminating
type: string
remoteNamespace:
description: RemoteNamespace is the name chosen by the user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ func (r *NamespaceMapReconciler) ensureRemoteNamespacesExistence(nm *mapsv1alpha
// if an entry in DesiredMapping is removed, the user has required the deletion of NamespaceOffloading
// resource, so is necessary to put "Terminating" phase on NamespaceOffloading. At the moment is impossible
// to delete a single entry in a NamespaceMap without deleting the whole NamespaceOffloading resource.
if remoteStatus.Phase == mapsv1alpha1.MappingAccepted {
if remoteStatus.Phase == mapsv1alpha1.MappingAccepted || remoteStatus.Phase == mapsv1alpha1.MappingTerminating {
if err := r.deleteRemoteNamespace(nm.Labels[liqoconst.RemoteClusterID], remoteStatus.RemoteNamespace); err != nil {
requeue = true
_ = r.setNotReadyNamespaceCondition(localName, nm.Labels[liqoconst.RemoteClusterID])
nm.Status.CurrentMapping[localName] = mapsv1alpha1.RemoteNamespaceStatus{
RemoteNamespace: remoteStatus.RemoteNamespace,
Phase: mapsv1alpha1.MappingTerminating,
}
klog.Info(err)
break
}
}
Expand All @@ -124,7 +125,7 @@ func (r *NamespaceMapReconciler) ensureRemoteNamespacesExistence(nm *mapsv1alpha

// Several conflicts are possible here
if err := r.Update(context.TODO(), nm); err != nil {
klog.Errorf("unable to update NamespaceMap '%s' Status", nm.Name)
klog.Errorf("%s -> unable to update NamespaceMap '%s' Status", err, nm.Name)
return true
}
klog.Infof("Status of the NamespaceMap '%s' is correctly updated", nm.Name)
Expand Down
Loading

0 comments on commit 9253a6b

Please sign in to comment.