Skip to content

Commit

Permalink
fix review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Jun 7, 2022
1 parent dce7674 commit 1b5950d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
3 changes: 3 additions & 0 deletions exp/runtime/hooks/api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ const (
// CommonRetryResponse is the data structure which contains all
// common retry fields.
type CommonRetryResponse struct {
// CommonResponse contains Status and Message fields common to all response types.
CommonResponse `json:",inline"`

// RetryAfterSeconds when set to a non-zero value signifies that the hook
// will be called again at a future time.
RetryAfterSeconds int32 `json:"retryAfterSeconds"`
Expand Down
12 changes: 0 additions & 12 deletions exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ var _ RetryResponseObject = &BeforeClusterCreateResponse{}
type BeforeClusterCreateResponse struct {
metav1.TypeMeta `json:",inline"`

// CommonResponse contains Status and Message fields common to all response types.
CommonResponse `json:",inline"`

// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
CommonRetryResponse `json:",inline"`
}
Expand Down Expand Up @@ -95,9 +92,6 @@ var _ RetryResponseObject = &BeforeClusterUpgradeResponse{}
type BeforeClusterUpgradeResponse struct {
metav1.TypeMeta `json:",inline"`

// CommonResponse contains Status and Message fields common to all response types.
CommonResponse `json:",inline"`

// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
CommonRetryResponse `json:",inline"`
}
Expand Down Expand Up @@ -125,9 +119,6 @@ var _ RetryResponseObject = &AfterControlPlaneUpgradeResponse{}
type AfterControlPlaneUpgradeResponse struct {
metav1.TypeMeta `json:",inline"`

// CommonResponse contains Status and Message fields common to all response types.
CommonResponse `json:",inline"`

// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
CommonRetryResponse `json:",inline"`
}
Expand Down Expand Up @@ -179,9 +170,6 @@ var _ RetryResponseObject = &BeforeClusterDeleteResponse{}
type BeforeClusterDeleteResponse struct {
metav1.TypeMeta `json:",inline"`

// CommonResponse contains Status and Message fields common to all response types.
CommonResponse `json:",inline"`

// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
CommonRetryResponse `json:",inline"`
}
Expand Down
9 changes: 4 additions & 5 deletions internal/runtime/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,17 @@ func aggregateSuccessfulResponses(aggregatedResponse runtimehooksv1.ResponseObje
aggregatedResponse.SetMessage("")
aggregatedResponse.SetStatus(runtimehooksv1.ResponseStatusSuccess)

if _, ok := aggregatedResponse.(runtimehooksv1.RetryResponseObject); !ok {
aggregatedRetryResponse, ok := aggregatedResponse.(runtimehooksv1.RetryResponseObject)
if !ok {
// If the aggregated response is not a RetryResponseObject then we're done.
return
}

// Note: as all responses have the same type we can assume now that
// they all implement the RetryResponseObject interface.
aggregatedRetryableResponse := aggregatedResponse.(runtimehooksv1.RetryResponseObject)

for _, resp := range responses {
aggregatedRetryableResponse.SetRetryAfterSeconds(lowestNonZeroRetryAfterSeconds(
aggregatedRetryableResponse.GetRetryAfterSeconds(),
aggregatedRetryResponse.SetRetryAfterSeconds(lowestNonZeroRetryAfterSeconds(
aggregatedRetryResponse.GetRetryAfterSeconds(),
resp.(runtimehooksv1.RetryResponseObject).GetRetryAfterSeconds(),
))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runtime/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func TestClient_CallExtension(t *testing.T) {
}
}

func Test_client_CallAllExtensions(t *testing.T) {
func TestClient_CallAllExtensions(t *testing.T) {
testHostPort := "127.0.0.1:9090"

fpFail := runtimev1.FailurePolicyFail
Expand Down

0 comments on commit 1b5950d

Please sign in to comment.