diff --git a/pkg/app/api/grpcapi/piped_api.go b/pkg/app/api/grpcapi/piped_api.go index e56fccc6a7..2eb2b13e79 100644 --- a/pkg/app/api/grpcapi/piped_api.go +++ b/pkg/app/api/grpcapi/piped_api.go @@ -1030,7 +1030,6 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice. chainBlocks := make([]*model.ChainBlock, 0, len(req.Matchers)+1) // Add the first deployment which created by piped as the first block of the chain. chainBlocks = append(chainBlocks, &model.ChainBlock{ - Index: 0, Nodes: []*model.ChainNode{ { ApplicationRef: &model.ChainApplicationRef{ @@ -1042,6 +1041,7 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice. }, }, }, + StartedAt: time.Now().Unix(), }) blockAppsMap := make(map[int][]*model.Application, len(req.Matchers)) @@ -1053,8 +1053,8 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice. blockAppsMap[i+1] = blockApps chainBlocks = append(chainBlocks, &model.ChainBlock{ - Index: int32(i + 1), - Nodes: nodes, + Nodes: nodes, + StartedAt: time.Now().Unix(), }) } @@ -1089,7 +1089,7 @@ func (a *PipedAPI) CreateDeploymentChain(ctx context.Context, req *pipedservice. Type: model.Command_CHAIN_SYNC_APPLICATION, ChainSyncApplication: &model.Command_ChainSyncApplication{ DeploymentChainId: dc.Id, - BlockIndex: int32(blockIndex), + BlockIndex: uint32(blockIndex), ApplicationId: app.Id, SyncStrategy: model.SyncStrategy_AUTO, }, @@ -1131,7 +1131,7 @@ func (a *PipedAPI) InChainDeploymentPlannable(ctx context.Context, req *pipedser }, nil } - if req.Deployment.DeploymentChainBlockIndex >= int32(len(dc.Blocks)) { + if req.Deployment.DeploymentChainBlockIndex >= uint32(len(dc.Blocks)) { return nil, status.Error(codes.InvalidArgument, "invalid deployment with chain block index provided") } diff --git a/pkg/app/piped/trigger/deployment.go b/pkg/app/piped/trigger/deployment.go index a323fc9861..1918689871 100644 --- a/pkg/app/piped/trigger/deployment.go +++ b/pkg/app/piped/trigger/deployment.go @@ -50,7 +50,7 @@ func buildDeployment( now time.Time, noti *config.DeploymentNotification, deploymentChainID string, - deploymentChainBlockIndex int32, + deploymentChainBlockIndex uint32, ) (*model.Deployment, error) { var commitURL string diff --git a/pkg/app/piped/trigger/trigger.go b/pkg/app/piped/trigger/trigger.go index 01f5fde135..ac0b00f996 100644 --- a/pkg/app/piped/trigger/trigger.go +++ b/pkg/app/piped/trigger/trigger.go @@ -252,7 +252,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c strategy model.SyncStrategy strategySummary string deploymentChainID string - deploymentChainBlockIndex int32 + deploymentChainBlockIndex uint32 ) switch c.kind { diff --git a/pkg/datastore/deploymentchainstore.go b/pkg/datastore/deploymentchainstore.go index 295bb76709..2318f189ed 100644 --- a/pkg/datastore/deploymentchainstore.go +++ b/pkg/datastore/deploymentchainstore.go @@ -31,7 +31,7 @@ var deploymentChainFactory = func() interface{} { var ( DeploymentChainAddDeploymentToBlock = func(deployment *model.Deployment) func(*model.DeploymentChain) error { return func(dc *model.DeploymentChain) error { - if deployment.DeploymentChainBlockIndex == 0 || deployment.DeploymentChainBlockIndex >= int32(len(dc.Blocks)) { + if deployment.DeploymentChainBlockIndex == 0 || deployment.DeploymentChainBlockIndex >= uint32(len(dc.Blocks)) { return fmt.Errorf("invalid block index provided") } block := dc.Blocks[deployment.DeploymentChainBlockIndex] diff --git a/pkg/model/command.proto b/pkg/model/command.proto index eb1e7dbdf3..ceb6e5c54c 100644 --- a/pkg/model/command.proto +++ b/pkg/model/command.proto @@ -69,7 +69,7 @@ message Command { message ChainSyncApplication { string deployment_chain_id = 1; - int32 block_index = 2; + uint32 block_index = 2; string application_id = 3 [(validate.rules).string.min_len = 1]; SyncStrategy sync_strategy = 4; } diff --git a/pkg/model/deployment.proto b/pkg/model/deployment.proto index 8a1b5b2b50..99386a0003 100644 --- a/pkg/model/deployment.proto +++ b/pkg/model/deployment.proto @@ -91,7 +91,7 @@ message Deployment { string deployment_chain_id = 40; // Index represents the offset of the node which this deployment // belongs to. - int32 deployment_chain_block_index = 41; + uint32 deployment_chain_block_index = 41; int64 completed_at = 100 [(validate.rules).int64.gte = 0]; int64 created_at = 101 [(validate.rules).int64.gte = 0]; diff --git a/pkg/model/deployment_chain.proto b/pkg/model/deployment_chain.proto index d454d75362..f06b68a852 100644 --- a/pkg/model/deployment_chain.proto +++ b/pkg/model/deployment_chain.proto @@ -52,10 +52,8 @@ message ChainNode { } message ChainBlock { - // Index represent the offset of the node in chain. - int32 index = 1; // List of applications which should be deployed at the same time in chain. - repeated ChainNode nodes = 2; + repeated ChainNode nodes = 1; // Unix time when the deployment chain node is started. int64 started_at = 100 [(validate.rules).int64.gte = 0];