Skip to content

Commit 2774b08

Browse files
authored
Merge pull request #160 from arangodb/feature/plan-action-timeout
Reconciliation plan-item timeout
2 parents d3e1feb + b3c6918 commit 2774b08

14 files changed

+118
-3
lines changed

pkg/deployment/reconcile/action.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728
)
2829

2930
// Action executes a single Plan item.
@@ -35,4 +36,6 @@ type Action interface {
3536
// CheckProgress checks the progress of the action.
3637
// Returns true if the action is completely finished, false otherwise.
3738
CheckProgress(ctx context.Context) (bool, error)
39+
// Timeout returns the amount of time after which this action will timeout.
40+
Timeout() time.Duration
3841
}

pkg/deployment/reconcile/action_add_member.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
2930
"github.com/rs/zerolog"
@@ -64,3 +65,8 @@ func (a *actionAddMember) CheckProgress(ctx context.Context) (bool, error) {
6465
// Nothing todo
6566
return true, nil
6667
}
68+
69+
// Timeout returns the amount of time after which this action will timeout.
70+
func (a *actionAddMember) Timeout() time.Duration {
71+
return addMemberTimeout
72+
}

pkg/deployment/reconcile/action_cleanout_member.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
2930
"github.com/rs/zerolog"
@@ -114,3 +115,8 @@ func (a *actionCleanoutMember) CheckProgress(ctx context.Context) (bool, error)
114115
// Cleanout completed
115116
return true, nil
116117
}
118+
119+
// Timeout returns the amount of time after which this action will timeout.
120+
func (a *actionCleanoutMember) Timeout() time.Duration {
121+
return cleanoutMemberTimeout
122+
}

pkg/deployment/reconcile/action_remove_member.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
"github.com/pkg/errors"
2930
"github.com/rs/zerolog"
@@ -94,3 +95,8 @@ func (a *actionRemoveMember) CheckProgress(ctx context.Context) (bool, error) {
9495
// Nothing todo
9596
return true, nil
9697
}
98+
99+
// Timeout returns the amount of time after which this action will timeout.
100+
func (a *actionRemoveMember) Timeout() time.Duration {
101+
return removeMemberTimeout
102+
}

pkg/deployment/reconcile/action_renew_tls_certificate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
2930
"github.com/rs/zerolog"
@@ -69,3 +70,8 @@ func (a *renewTLSCertificateAction) Start(ctx context.Context) (bool, error) {
6970
func (a *renewTLSCertificateAction) CheckProgress(ctx context.Context) (bool, error) {
7071
return true, nil
7172
}
73+
74+
// Timeout returns the amount of time after which this action will timeout.
75+
func (a *renewTLSCertificateAction) Timeout() time.Duration {
76+
return renewTLSCertificateTimeout
77+
}

pkg/deployment/reconcile/action_rotate_member.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
2930
"github.com/rs/zerolog"
@@ -116,3 +117,8 @@ func (a *actionRotateMember) CheckProgress(ctx context.Context) (bool, error) {
116117
}
117118
return true, nil
118119
}
120+
121+
// Timeout returns the amount of time after which this action will timeout.
122+
func (a *actionRotateMember) Timeout() time.Duration {
123+
return rotateMemberTimeout
124+
}

pkg/deployment/reconcile/action_shutdown_member.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,8 @@ func (a *actionShutdownMember) CheckProgress(ctx context.Context) (bool, error)
111111
// Member still not shutdown, retry soon
112112
return false, nil
113113
}
114+
115+
// Timeout returns the amount of time after which this action will timeout.
116+
func (a *actionShutdownMember) Timeout() time.Duration {
117+
return shutdownMemberTimeout
118+
}

pkg/deployment/reconcile/action_upgrade_member.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
2930
"github.com/rs/zerolog"
@@ -126,3 +127,8 @@ func (a *actionUpgradeMember) CheckProgress(ctx context.Context) (bool, error) {
126127
}
127128
return isUpgrading, nil
128129
}
130+
131+
// Timeout returns the amount of time after which this action will timeout.
132+
func (a *actionUpgradeMember) Timeout() time.Duration {
133+
return upgradeMemberTimeout
134+
}

pkg/deployment/reconcile/action_wait_for_member_up.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package reconcile
2424

2525
import (
2626
"context"
27+
"time"
2728

2829
driver "github.com/arangodb/go-driver"
2930
"github.com/arangodb/go-driver/agency"
@@ -164,3 +165,8 @@ func (a *actionWaitForMemberUp) checkProgressArangoSync(ctx context.Context) (bo
164165
}
165166
return true, nil
166167
}
168+
169+
// Timeout returns the amount of time after which this action will timeout.
170+
func (a *actionWaitForMemberUp) Timeout() time.Duration {
171+
return waitForMemberUpTimeout
172+
}

pkg/deployment/reconcile/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ type Context interface {
5454
GetAgencyClients(ctx context.Context, predicate func(id string) bool) ([]driver.Connection, error)
5555
// GetSyncServerClient returns a cached client for a specific arangosync server.
5656
GetSyncServerClient(ctx context.Context, group api.ServerGroup, id string) (client.API, error)
57+
// CreateEvent creates a given event.
58+
// On error, the error is logged.
59+
CreateEvent(evt *v1.Event)
5760
// CreateMember adds a new member to the given group.
5861
// If ID is non-empty, it will be used, otherwise a new ID is created.
5962
CreateMember(group api.ServerGroup, id string) error

0 commit comments

Comments
 (0)