Skip to content

Commit befb21d

Browse files
committed
[hypervisor] add internal ip address field to status
1 parent da93795 commit befb21d

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

api/v1/hypervisor_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ type HypervisorStatus struct {
181181
// Aggregates are the applied aggregates of the hypervisor.
182182
Aggregates []string `json:"aggregates,omitempty"`
183183

184+
// InternalIP is the internal IP address of the hypervisor.
185+
InternalIP string `json:"internalIp,omitempty"`
186+
184187
// Represents the Hypervisor node conditions.
185188
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
186189

@@ -199,6 +202,7 @@ type HypervisorStatus struct {
199202
// +kubebuilder:printcolumn:JSONPath=".spec.highAvailability",name="High Availability",type="boolean"
200203
// +kubebuilder:printcolumn:JSONPath=".spec.skipTests",name="Skip Tests",type="boolean"
201204
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.prettyVersion",name="Version",type="string"
205+
// +kubebuilder:printcolumn:JSONPath=".status.internalIp",name="IP",type="string"
202206
// +kubebuilder:printcolumn:JSONPath=".status.numInstances",name="Instances",type="integer"
203207
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.hardwareModel",name="Hardware",type="string",priority=2
204208
// +kubebuilder:printcolumn:JSONPath=".status.operatingSystem.kernelRelease",name="Kernel",type="string",priority=2

charts/openstack-hypervisor-operator/crds/hypervisor-crd.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ spec:
4646
- jsonPath: .status.operatingSystem.prettyVersion
4747
name: Version
4848
type: string
49+
- jsonPath: .status.internalIp
50+
name: IP
51+
type: string
4952
- jsonPath: .status.numInstances
5053
name: Instances
5154
type: integer
@@ -271,6 +274,9 @@ spec:
271274
- name
272275
type: object
273276
type: array
277+
internalIp:
278+
description: InternalIP is the internal IP address of the hypervisor.
279+
type: string
274280
libVirtVersion:
275281
default: unknown
276282
description: Represents the LibVirt version.

config/crd/bases/kvm.cloud.sap_hypervisors.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ spec:
4747
- jsonPath: .status.operatingSystem.prettyVersion
4848
name: Version
4949
type: string
50+
- jsonPath: .status.internalIp
51+
name: IP
52+
type: string
5053
- jsonPath: .status.numInstances
5154
name: Instances
5255
type: integer
@@ -272,6 +275,9 @@ spec:
272275
- name
273276
type: object
274277
type: array
278+
internalIp:
279+
description: InternalIP is the internal IP address of the hypervisor.
280+
type: string
275281
libVirtVersion:
276282
default: unknown
277283
description: Represents the LibVirt version.

internal/controller/hypervisor_controller.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,37 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request)
9393
// continue with creation
9494
} else {
9595
// update Status if needed
96+
changed := false
97+
98+
// transfer internal IP
99+
for _, address := range node.Status.Addresses {
100+
if address.Type == corev1.NodeInternalIP && hypervisor.Status.InternalIP != address.Address {
101+
hypervisor.Status.InternalIP = address.Address
102+
changed = true
103+
break
104+
}
105+
}
106+
107+
// update terminating condition
96108
nodeTerminationCondition := FindNodeStatusCondition(node.Status.Conditions, "Terminating")
97109
if nodeTerminationCondition != nil && nodeTerminationCondition.Status == corev1.ConditionTrue {
98110
// Node might be terminating, propagate condition to hypervisor
99-
changed := meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
111+
changed = meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
100112
Type: kvmv1.ConditionTypeReady,
101113
Status: metav1.ConditionFalse,
102114
Reason: nodeTerminationCondition.Reason,
103115
Message: nodeTerminationCondition.Message,
104-
}) || meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
116+
}) || changed
117+
changed = meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
105118
Type: kvmv1.ConditionTypeTerminating,
106119
Status: metav1.ConditionStatus(nodeTerminationCondition.Status),
107120
Reason: nodeTerminationCondition.Reason,
108121
Message: nodeTerminationCondition.Message,
109-
})
110-
if changed {
111-
return ctrl.Result{}, hv.Status().Update(ctx, hypervisor)
112-
}
122+
}) || changed
123+
}
124+
125+
if changed {
126+
return ctrl.Result{}, hv.Status().Update(ctx, hypervisor)
113127
}
114128
return ctrl.Result{}, nil
115129
}

0 commit comments

Comments
 (0)