Skip to content

Commit

Permalink
commitment: remove empty behaviors.
Browse files Browse the repository at this point in the history
rearrange flatresourcetoplogy condition
  • Loading branch information
VoigtS committed Dec 5, 2024
1 parent 8f5f123 commit 95e45d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions internal/api/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ func (p *v1Provider) parseAndValidateCommitmentRequest(w http.ResponseWriter, r
http.Error(w, "commitments are not enabled for this resource", http.StatusUnprocessableEntity)
return nil, nil, nil
}
if resInfo.Topology != liquid.FlatResourceTopology {
if !slices.Contains(p.Cluster.Config.AvailabilityZones, req.AvailabilityZone) {
http.Error(w, "no such availability zone", http.StatusUnprocessableEntity)
if resInfo.Topology == liquid.FlatResourceTopology {
if req.AvailabilityZone != limes.AvailabilityZoneAny {
http.Error(w, `resource does not accept AZ-aware commitments, so the AZ must be set to "any"`, http.StatusUnprocessableEntity)
return nil, nil, nil
}
} else {
if req.AvailabilityZone != limes.AvailabilityZoneAny {
http.Error(w, `resource does not accept AZ-aware commitments, so the AZ must be set to "any"`, http.StatusUnprocessableEntity)
if !slices.Contains(p.Cluster.Config.AvailabilityZones, req.AvailabilityZone) {
http.Error(w, "no such availability zone", http.StatusUnprocessableEntity)
return nil, nil, nil
}
}
Expand Down
2 changes: 0 additions & 2 deletions internal/api/commitment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const testCommitmentsYAML = `
- resource: first/.*
commitment_durations: ["1 hour", "2 hours"]
commitment_min_confirm_date: '1970-01-08T00:00:00Z' # one week after start of mock.Clock
- resource: first/things
- resource: first/capacity
`
const testCommitmentsYAMLWithoutMinConfirmDate = `
availability_zones: [ az-one, az-two ]
Expand Down

0 comments on commit 95e45d5

Please sign in to comment.