Skip to content

Commit

Permalink
fix and update
Browse files Browse the repository at this point in the history
  • Loading branch information
rainzm committed May 12, 2020
1 parent 2430e12 commit 7f60c79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion api/v1/virtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ type VirtualMachineConfig struct {

type VMProjectSpec struct {
Project string `json:"project"`
PoejectDomain string `json:"projectDomain"`
// +optional
PoejectDomain string `json:"projectDomain,omitempty"`
}

type VMDiskSpec struct {
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/onecloud.yunion.io_virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ spec:
type: string
required:
- project
- projectDomain
type: object
recreatePolicy:
description: RecreatePolicy describe that when the virtual machine is
Expand Down
12 changes: 8 additions & 4 deletions controllers/ansibleplaybook_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ import (
"yunion.io/x/onecloud-service-operator/provider"
)

const (
PendingAfter = 15 * time.Second
WaitingAfter = 15 * time.Second
)

// AnsiblePlaybookReconciler reconciles a AnsiblePlaybook object
type AnsiblePlaybookReconciler struct {
client.Client
Expand All @@ -57,7 +62,6 @@ func (r *AnsiblePlaybookReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er

var ansiblePlaybook onecloudv1.AnsiblePlaybook
if err := r.Get(ctx, req.NamespacedName, &ansiblePlaybook); err != nil {
log.Error(err, "unable to fetch AnsiblePlaybook")
return ctrl.Result{}, client.IgnoreNotFound(err)
}

Expand Down Expand Up @@ -265,7 +269,7 @@ func (r *AnsiblePlaybookReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er

// Pending
if ansiblePlaybook.Status.Phase == onecloudv1.ResourcePending {
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
return ctrl.Result{Requeue: true, RequeueAfter: PendingAfter}, nil
}

// Unkown
Expand Down Expand Up @@ -334,7 +338,7 @@ func (r *AnsiblePlaybookReconciler) apCreate(ctx context.Context, ap *onecloudv1

func (r *AnsiblePlaybookReconciler) apDelete(ctx context.Context, ap *onecloudv1.AnsiblePlaybook) error {
isDelete, extInfo, err := provider.Provider.APDelete(ctx, ap)
if err == nil {
if err != nil {
return err
}
if isDelete {
Expand Down Expand Up @@ -369,7 +373,7 @@ func (r *AnsiblePlaybookReconciler) markWaiting(ctx context.Context, log logr.Lo
newStatus.Phase = onecloudv1.ResourceWaiting
newStatus.Reason = msg
if !r.requireUpdate(ap, newStatus) {
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
return ctrl.Result{Requeue: true, RequeueAfter: WaitingAfter}, nil
}
ap.Status = *newStatus
if err := r.Status().Update(ctx, ap); err != nil {
Expand Down

0 comments on commit 7f60c79

Please sign in to comment.