Skip to content

Commit 5424665

Browse files
committed
[hypervisor] add internal ip address field to status
1 parent 242294a commit 5424665

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
@@ -94,23 +94,37 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request)
9494
// continue with creation
9595
} else {
9696
// update Status if needed
97+
changed := false
98+
99+
// transfer internal IP
100+
for _, address := range node.Status.Addresses {
101+
if address.Type == corev1.NodeInternalIP && hypervisor.Status.InternalIP != address.Address {
102+
hypervisor.Status.InternalIP = address.Address
103+
changed = true
104+
break
105+
}
106+
}
107+
108+
// update terminating condition
97109
nodeTerminationCondition := FindNodeStatusCondition(node.Status.Conditions, "Terminating")
98110
if nodeTerminationCondition != nil && nodeTerminationCondition.Status == corev1.ConditionTrue {
99111
// Node might be terminating, propagate condition to hypervisor
100-
changed := meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
112+
changed = meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
101113
Type: kvmv1.ConditionTypeReady,
102114
Status: metav1.ConditionFalse,
103115
Reason: nodeTerminationCondition.Reason,
104116
Message: nodeTerminationCondition.Message,
105-
}) || meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
117+
}) || changed
118+
changed = meta.SetStatusCondition(&hypervisor.Status.Conditions, metav1.Condition{
106119
Type: kvmv1.ConditionTypeTerminating,
107120
Status: metav1.ConditionStatus(nodeTerminationCondition.Status),
108121
Reason: nodeTerminationCondition.Reason,
109122
Message: nodeTerminationCondition.Message,
110-
})
111-
if changed {
112-
return ctrl.Result{}, hv.Status().Update(ctx, hypervisor)
113-
}
123+
}) || changed
124+
}
125+
126+
if changed {
127+
return ctrl.Result{}, hv.Status().Update(ctx, hypervisor)
114128
}
115129

116130
// transport label/anotations changes

0 commit comments

Comments
 (0)