Skip to content

Commit 24ebebd

Browse files
committed
Port: Make port available only when reported as active
Ports reports their statuses via a status field, we should take that into consideration when computing if the port is available or not. With this change, ports are reported as Available when the object has a known ID for the resource, and the resource has ACTIVE status. Fixes k-orc#198
1 parent 1691242 commit 24ebebd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/controllers/port/status.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import (
2424
orcapplyconfigv1alpha1 "github.com/k-orc/openstack-resource-controller/pkg/clients/applyconfiguration/api/v1alpha1"
2525
)
2626

27+
const (
28+
PortStatusActive = "ACTIVE"
29+
)
30+
2731
type objectApplyPT = *orcapplyconfigv1alpha1.PortApplyConfiguration
2832
type statusApplyPT = *orcapplyconfigv1alpha1.PortStatusApplyConfiguration
2933

@@ -35,9 +39,8 @@ func (portStatusWriter) GetApplyConfigConstructor() generic.ORCApplyConfigConstr
3539
return orcapplyconfigv1alpha1.Port
3640
}
3741

38-
func (portStatusWriter) ResourceIsAvailable(_ orcObjectPT, osResource *osResourceT) bool {
39-
// A port is available as soon as it exists
40-
return osResource != nil
42+
func (portStatusWriter) ResourceIsAvailable(orcObject orcObjectPT, osResource *osResourceT) bool {
43+
return orcObject.Status.ID != nil && osResource != nil && osResource.Status == PortStatusActive
4144
}
4245

4346
func (portStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResourceT, statusApply statusApplyPT) {

0 commit comments

Comments
 (0)