Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Rahmansyah committed May 17, 2024
1 parent 71cce9c commit 2293cf7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/cluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (c *controller) Deploy(ctx context.Context, modelService *models.Service) (

if c.deploymentConfig.PodDisruptionBudget.Enabled {
// Create / update pdb
pdbs := createPodDisruptionBudgets(modelService, c.deploymentConfig.PodDisruptionBudget)
pdbs := generatePDBSpecs(modelService, c.deploymentConfig.PodDisruptionBudget)
if err := c.deployPodDisruptionBudgets(ctx, pdbs); err != nil {
log.Errorf("unable to create pdb: %v", err)
return nil, errors.Wrapf(err, fmt.Sprintf("%v", ErrUnableToCreatePDB))
Expand Down Expand Up @@ -321,7 +321,7 @@ func (c *controller) Delete(ctx context.Context, modelService *models.Service) (
}

if c.deploymentConfig.PodDisruptionBudget.Enabled {
pdbs := createPodDisruptionBudgets(modelService, c.deploymentConfig.PodDisruptionBudget)
pdbs := generatePDBSpecs(modelService, c.deploymentConfig.PodDisruptionBudget)
if err := c.deletePodDisruptionBudgets(ctx, pdbs); err != nil {
log.Errorf("unable to delete pdb %v", err)
return nil, ErrUnableToDeletePDB
Expand Down
2 changes: 1 addition & 1 deletion api/cluster/pdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (cfg PodDisruptionBudget) BuildPDBSpec() (*policyv1.PodDisruptionBudget, er
return pdb, nil
}

func createPodDisruptionBudgets(modelService *models.Service, pdbConfig config.PodDisruptionBudgetConfig) []*PodDisruptionBudget {
func generatePDBSpecs(modelService *models.Service, pdbConfig config.PodDisruptionBudgetConfig) []*PodDisruptionBudget {
pdbs := []*PodDisruptionBudget{}

// Only create PDB if: ceil(minReplica * minAvailablePercent) < minReplica
Expand Down
4 changes: 2 additions & 2 deletions api/cluster/pdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestPodDisruptionBudget_BuildPDBSpec(t *testing.T) {
}
}

func TestCreatePodDisruptionBudgets(t *testing.T) {
func Test_generatePDBSpecs(t *testing.T) {
err := models.InitKubernetesLabeller("gojek.com/", "dev")
assert.Nil(t, err)

Expand Down Expand Up @@ -343,7 +343,7 @@ func TestCreatePodDisruptionBudgets(t *testing.T) {

for name, tt := range tests {
t.Run(name, func(t *testing.T) {
pdbs := createPodDisruptionBudgets(tt.modelService, tt.pdbConfig)
pdbs := generatePDBSpecs(tt.modelService, tt.pdbConfig)
assert.Equal(t, tt.expected, pdbs)
})
}
Expand Down

0 comments on commit 2293cf7

Please sign in to comment.