Skip to content

Conversation

@sanposhiho
Copy link
Member

What this PR does / why we need it:

Currently, there is no way to configure the timeout value for the WAIT_APPROVAL stage.

Which issue(s) this PR fixes:

Fixes #1371

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.82%. This pull request increases coverage by 0.02%.

File Function Base Head Diff
pkg/config/deployment.go PipelineStage.UnmarshalJSON 44.07% 45.90% +1.83%

@sanposhiho sanposhiho marked this pull request as ready for review January 8, 2021 16:54
Approvers []string `json:"approvers"`
}

var defaultWaitApprovalTimeout int64 = 600
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the default value for timeout?


// WaitStageOptions contains all configurable values for a WAIT_APPROVAL stage.
type WaitApprovalStageOptions struct {
// number of seconds to timeout wait approval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "The maximum length of time to wait before giving up."

// WaitStageOptions contains all configurable values for a WAIT_APPROVAL stage.
type WaitApprovalStageOptions struct {
// number of seconds to timeout wait approval
Timeout int64 `json:"timeout"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change this to use Duration instead of int64?
https://github.com/pipe-cd/pipe/blob/master/pkg/config/duration.go#L23

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK 👍

Approvers []string `json:"approvers"`
}

var defaultWaitApprovalTimeout int64 = 600
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value could be 6 * time.Hour

return model.StageStatus_STAGE_FAILURE
}
case <-timer.C:
e.LogPersister.Info("Timeout wait approval")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w.LogPersister.Errorf("Timed out %v", e.StageConfig.WaitApprovalStageOptions.Timeout)

@nghialv
Copy link
Member

nghialv commented Jan 11, 2021

@sanposhiho Many thanks for your great effort.
I have just left some comments. Please take a look.

@sanposhiho
Copy link
Member Author

@nghialv Thanks you for your reviews, fixed them :D

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.82%. This pull request increases coverage by 0.02%.

File Function Base Head Diff
pkg/config/deployment.go PipelineStage.UnmarshalJSON 44.07% 45.90% +1.83%

Approvers []string `json:"approvers"`
}

var defaultWaitApprovalTimeout = Duration(6 * time.Hour)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, should move to the top of this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this I'm still debating. I'm trying to figure out where to define the default values.

Currently most of all default values are populated at the pakcages where they are used. We have not debated this point until now, but I followed that rule because this current design can hide the way how to use each configuration field and leave it to each package that uses them.

But on the dark side, it can't guarantee that all field is populated when it parsed. Happy to hear your thoughts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently most of all default values are populated at the packages where they are used.

Got it, I think I'm okay with this convention 👍 What I mentioned here is, should we move this default value to the top of this file and make it const, currently it's been used before declared make it hard to read.
For the point of "where to define the default value", I think we should debate and address it by another PR. 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this default value to the top of this file and make it const,
I think we should debate and address it by another PR.

I am fine with these things. To be honest I was thinking about where to define and how to configure the default value of our config. And I think all of them should be defined in the config package (as public consts) and loaded when the configuration is parsed. So the comment about the default value is the same in that package too. The docs refer to them too.

It would be nice if we can define the default value by go tag (as JSON tag). There are some libs for doing that thing but still not found a good enough one.
Let me make a PR for this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we can define the default value by go tag (as JSON tag).

👍 👍 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, let's debate about all of them on another PR.

should we move this default value to the top of this file and make it const,

@sanposhiho Could you address it if no objection to that? 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just caught up on this conversation. OK, move the default value to the top 👍

Name: model.StageWaitApproval,
WaitApprovalStageOptions: &WaitApprovalStageOptions{
Approvers: []string{"foo", "bar"},
Timeout: defaultWaitApprovalTimeout, // set default timeout value when nothing sets on config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

WaitApprovalStageOptions: &WaitApprovalStageOptions{
    Approvers: []string{"foo", "bar"},
    // Use defaultWaitApprovalTimeout on unset timeout value for WaitApprovalStage.
    Timeout: defaultWaitApprovalTimeout,

or remove this comment and place it to implement source at L137

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.82%. This pull request increases coverage by 0.02%.

File Function Base Head Diff
pkg/config/deployment.go PipelineStage.UnmarshalJSON 44.07% 45.90% +1.83%

@nghialv
Copy link
Member

nghialv commented Jan 12, 2021

Thank you.
/lgtm

@khanhtc1202
Copy link
Member

thank you
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit fefe157 into master Jan 12, 2021
@pipecd-bot pipecd-bot deleted the timeout-for-wait-approval branch January 12, 2021 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make timeout of WAIT_APPROVAL stage configurable

6 participants