Skip to content

Conversation

@khanhtc1202
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

You can deploy Lambda application under Pipeline sync strategy

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.50%. This pull request increases coverage by 0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.48%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%

@khanhtc1202 khanhtc1202 marked this pull request as ready for review January 20, 2021 10:02
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.48%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.48%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.48%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%

@pipecd-bot pipecd-bot added size/XL and removed size/L labels Jan 20, 2021
@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/executor/lambda/lambda_test.go
--- pkg/app/piped/executor/lambda/lambda_test.go.orig
+++ pkg/app/piped/executor/lambda/lambda_test.go
@@ -17,8 +17,9 @@
 import (
 	"testing"
 
-	provider "github.com/pipe-cd/pipe/pkg/app/piped/cloudprovider/lambda"
 	"github.com/stretchr/testify/assert"
+
+	provider "github.com/pipe-cd/pipe/pkg/app/piped/cloudprovider/lambda"
 )
 
 func TestConfigureTrafficRouting(t *testing.T) {

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.91%. This pull request decreases coverage by -0.59%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureSync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensurePromote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureRollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go Register -- 80.00% +80.00%
pkg/app/piped/executor/lambda/lambda.go findCloudProvider -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go loadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go decideRevisionName -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go sync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go rollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go promote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go configureTrafficRouting -- 100.00% +100.00%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

Comment on lines +300 to +308
} else {
// Update traffic to the secondary and keep it as new secondary.
if secondary, ok := trafficCfg["secondary"]; ok {
trafficCfg["secondary"] = provider.VersionTraffic{
Version: secondary.Version,
Percent: float64(100 - percent),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

How about using else if instead of using if inside else statement?

Suggested change
} else {
// Update traffic to the secondary and keep it as new secondary.
if secondary, ok := trafficCfg["secondary"]; ok {
trafficCfg["secondary"] = provider.VersionTraffic{
Version: secondary.Version,
Percent: float64(100 - percent),
}
}
}
} else if secondary, ok := trafficCfg["secondary"]; ok {
// Update traffic to the secondary and keep it as new secondary.
trafficCfg["secondary"] = provider.VersionTraffic{
Version: secondary.Version,
Percent: float64(100 - percent),
}
}

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 get your point 👍 To be honest, I quite don't like that else if statement 😓
The reason is that else if is short for

- } else if (primary.Version == version) && (secondary, ok := trafficCfg["secondary"]); ok {
+ } else if secondary, ok := trafficCfg["secondary"]; ok {

The if in else if condition should at least related to the first if to avoid misunderstanding. For example, in case A v B v C = 1 then if A else if B else (if C) is fine.

Copy link
Member

Choose a reason for hiding this comment

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

Okay I got your point exactly 👍 We have no explicit coding style guide, but have common ground here: avoid being deeply nested as much as possible.

So how about this?

	// Update traffic to the secondary and keep it as new secondary.
	if secondary, ok := trafficCfg["secondary"]; ok {
		trafficCfg["secondary"] = provider.VersionTraffic{
			Version: secondary.Version,
			Percent: float64(100 - percent),
		}
	}
	// Make the current primary version as new secondary version in case it's not the latest built version by rollout stage.
	if primary.Version != version {
		trafficCfg["secondary"] = provider.VersionTraffic{
			Version: primary.Version,
			Percent: float64(100 - percent),
		}
	}

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case, the above (Update traffic to the secondary and keep it as new secondary.) is redundant when the built version is not equal to the current primary version 😂 Edit the secondary first, then reset it to another value right after is quite weird to read, I guess 🤔

Copy link
Member

Choose a reason for hiding this comment

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

We've actually avoided being deeply nested by doing like that, but I'm unfamiliar with the standard for this case. Besides, it's a matter of taste, I respect your decision 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you 🙏

@nakabonne
Copy link
Member

Looks like executor.lambda.decideRevisionName() which acts exact the same as executor.cloudrun.decideRevisionName() is unused now but are you planning to use it?
https://github.com/pipe-cd/pipe/pull/1452/files#diff-c77a88dbb318a76fc9c9ff7a8bb1746acaf6ab9040b40826ed067a63af63faf4R78

@khanhtc1202
Copy link
Member Author

Looks like executor.lambda.decideRevisionName() which acts exact the same as executor.cloudrun.decideRevisionName() is unused now but are you planning to use it?
https://github.com/pipe-cd/pipe/pull/1452/files#diff-c77a88dbb318a76fc9c9ff7a8bb1746acaf6ab9040b40826ed067a63af63faf4R78

Nice catch, I think it safe to be deleted 👍

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.93%. This pull request decreases coverage by -0.56%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureSync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensurePromote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureRollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go Register -- 80.00% +80.00%
pkg/app/piped/executor/lambda/lambda.go findCloudProvider -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go loadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go sync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go rollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go promote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go configureTrafficRouting -- 100.00% +100.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.93%. This pull request decreases coverage by -0.56%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureSync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensurePromote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureRollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go Register -- 80.00% +80.00%
pkg/app/piped/executor/lambda/lambda.go findCloudProvider -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go loadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go sync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go rollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go promote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go configureTrafficRouting -- 100.00% +100.00%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.99%. This pull request decreases coverage by -0.50%.

File Function Base Head Diff
pkg/app/piped/cloudprovider/lambda/client.go percentageToPercent -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureSync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensurePromote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/deploy.go deployExecutor.ensureRollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go Register -- 80.00% +80.00%
pkg/app/piped/executor/lambda/lambda.go findCloudProvider -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go loadFunctionManifest -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go sync -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go rollout -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go promote -- 0.00% +0.00%
pkg/app/piped/executor/lambda/lambda.go configureTrafficRouting -- 100.00% +100.00%
pkg/app/piped/executor/lambda/lambda.go build -- 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.GetTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/cloudprovider/lambda/client.go client.UpdateTrafficConfig 0.00% 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/config/deployment.go PipelineStage.UnmarshalJSON 45.90% 43.75% -2.15%

@nakabonne
Copy link
Member

/lgtm

@nghialv
Copy link
Member

nghialv commented Jan 21, 2021

Nice. Thank you.
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nghialv.

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 1a45bee into master Jan 21, 2021
@pipecd-bot pipecd-bot deleted the pipeline-sync-lambda branch January 21, 2021 07:25
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.

5 participants