Skip to content

Commit

Permalink
Add some logging to sandbox-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Jan 26, 2021
1 parent f33edfa commit 1b23f53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apis/devops/v1/sandbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type SandboxSpec struct {

// SandboxStatus defines the observed state of Sandbox
type SandboxStatus struct {
NamespaceStatus *v1.NamespaceStatus `json:",omitempty"`
LastNotification *metav1.Time `json:"last_notification,omitempty"`
NamespaceStatus v1.NamespaceStatus `json:",omitempty"`
LastNotification *metav1.Time `json:"last_notification,omitempty"`

// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Expand Down
7 changes: 1 addition & 6 deletions apis/devops/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions controllers/devops/sandbox_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,20 @@ func (r *SandboxReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, err
}

sandbox.Status.NamespaceStatus = &newNs.Status
log.WithValues("status.phase", newNs.Status.Phase).Info("Created namespace is now...")

sandbox.Status.NamespaceStatus = newNs.Status
if err := r.Status().Update(ctx, sandbox); err != nil {
log.Error(err, "Unable to update sandbox status")
return ctrl.Result{}, err
}
} else {
if sandbox.Status.NamespaceStatus != nil && sandbox.Status.NamespaceStatus.Phase == v1.NamespaceActive {
if sandbox.Status.NamespaceStatus.Phase == v1.NamespaceActive {
return ctrl.Result{}, nil
}

log.WithValues("status.phase", sandbox.Status.NamespaceStatus.Phase).Info("Namespace exists, but sandbox status is not Active")

return ctrl.Result{}, fmt.Errorf("Namespace for sandbox already exists")
}

Expand Down

0 comments on commit 1b23f53

Please sign in to comment.