Skip to content

Commit

Permalink
[noVNCProxy] Change order in reconcile loop
Browse files Browse the repository at this point in the history
Change order to get correct host of novncproxy to set it in
nova.conf
  • Loading branch information
mrkisaolamb committed Jun 5, 2023
1 parent 51692e2 commit fc81248
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 deletions.
1 change: 0 additions & 1 deletion api/v1beta1/novametadata_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ func NewNovaMetadataSpec(
KeystoneAuthURL: novaCell.KeystoneAuthURL,
ServiceUser: novaCell.ServiceUser,
PasswordSelectors: novaCell.PasswordSelectors,
ServiceAccount: novaCell.ServiceAccount,
}
return metadataSpec
}
1 change: 1 addition & 0 deletions api/v1beta1/novanovncproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func NewNovaNoVNCProxySpec(
ServiceUser: novaCell.ServiceUser,
PasswordSelectors: novaCell.PasswordSelectors,
ServiceAccount: novaCell.ServiceAccount,
ExternalEndpoints: novaCell.NoVNCProxyServiceTemplate.ExternalEndpoints,
}
return noVNCProxSpec
}
10 changes: 10 additions & 0 deletions controllers/novanovncproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type NovaNoVNCProxyReconciler struct {
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete;
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete;
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete;
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneendpoints,verbs=get;list;watch;create;update;patch;delete;
// +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch

// Reconcile is part of the main kubernetes reconciliation loop which aims to
Expand Down Expand Up @@ -152,6 +153,13 @@ func (r *NovaNoVNCProxyReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// all our input checks out so report InputReady
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

result, err = r.ensureServiceExposed(ctx, h, instance)
if (err != nil || result != ctrl.Result{}) {
// We can ignore RequeueAfter as we are watching the Service and Route resource
// but we have to return while waiting for the service to be exposed
return ctrl.Result{}, err
}

err = r.ensureConfigMaps(ctx, h, instance, &hashes)
if err != nil {
return ctrl.Result{}, err
Expand Down Expand Up @@ -304,6 +312,7 @@ func (r *NovaNoVNCProxyReconciler) generateConfigs(
"cell_db_address": instance.Spec.CellDatabaseHostname,
"cell_db_port": 3306,
"novncproxy_service_host": novncproxy.Host,
"novncproxy_base_url": instance.Status.APIEndpoints["public"],
"nova_novncproxy_listen_port": novncproxy.NoVNCProxyPort,
"api_interface_address": "", // fixme
"public_protocol": "http", // fixme
Expand Down Expand Up @@ -415,6 +424,7 @@ func (r *NovaNoVNCProxyReconciler) ensureServiceExposed(
instance *novav1beta1.NovaNoVNCProxy,
) (ctrl.Result, error) {
var ports = map[endpoint.Endpoint]endpoint.Data{
endpoint.EndpointPublic: {Port: novncproxy.NoVNCProxyPort},
endpoint.EndpointInternal: {Port: novncproxy.NoVNCProxyPort},
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/novncproxy/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ func StatefulSet(
args = append(args, nova.KollaServiceCommand)
livenessProbe.HTTPGet = &corev1.HTTPGetAction{
Port: intstr.IntOrString{Type: intstr.Int, IntVal: int32(NoVNCProxyPort)},
Path: "/vnc_auto.html",
Path: "/vnc_lite.html",
}
readinessProbe.HTTPGet = &corev1.HTTPGetAction{
Port: intstr.IntOrString{Type: intstr.Int, IntVal: int32(NoVNCProxyPort)},
Path: "/vnc_auto.html",
Path: "/vnc_lite.html",
}
startupProbe.HTTPGet = &corev1.HTTPGetAction{
Port: intstr.IntOrString{Type: intstr.Int, IntVal: int32(NoVNCProxyPort)},
Path: "/vnc_auto.html",
Path: "/vnc_lite.html",
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/nova.conf
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ notify_on_state_change = vm_and_task_state
enabled = True
novncproxy_host = {{ .novncproxy_service_host }}
novncproxy_port = {{ .nova_novncproxy_listen_port }}
novncproxy_base_url = {{ .public_protocol }}://{{ .novncproxy_service_host }}:{{ .nova_novncproxy_listen_port }}/vnc_auto.html
novncproxy_base_url = {{ .novncproxy_base_url }}/vnc_lite.html
{{end}}

[cache]
Expand Down
12 changes: 6 additions & 6 deletions test/functional/nova_multicell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ var _ = Describe("Nova multicell", func() {
Expect(configDataMap.Data["01-nova.conf"]).To(
ContainSubstring(fmt.Sprintf("[api_database]\nconnection = mysql+pymysql://nova_api:12345678@hostname-for-%s/nova_api", novaNames.APIMariaDBDatabaseName.Name)),
)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.ExpectCondition(
cell1.CellConductorName,
ConditionGetterFunc(NovaConductorConditionGetter),
condition.DBSyncReadyCondition,
corev1.ConditionTrue,
)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName)
th.SimulateJobSuccess(cell1.CellMappingJobName)
th.ExpectCondition(
Expand Down Expand Up @@ -337,8 +337,8 @@ var _ = Describe("Nova multicell", func() {
th.SimulateStatefulSetReplicaReady(novaNames.MetadataStatefulSetName)
th.SimulateMariaDBDatabaseCompleted(cell1.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell1.TransportURLName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName)
th.SimulateJobSuccess(cell1.CellMappingJobName)

Expand Down Expand Up @@ -372,14 +372,14 @@ var _ = Describe("Nova multicell", func() {
Expect(configDataMap.Data["01-nova.conf"]).ToNot(
ContainSubstring("[api_database]"),
)
th.SimulateStatefulSetReplicaReady(cell2.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell2.CellDBSyncJobName)
th.ExpectCondition(
cell2.CellConductorName,
ConditionGetterFunc(NovaConductorConditionGetter),
condition.DBSyncReadyCondition,
corev1.ConditionTrue,
)
th.SimulateStatefulSetReplicaReady(cell2.NoVNCProxyNameStatefulSetName)
th.SimulateStatefulSetReplicaReady(cell2.ConductorStatefulSetName)
th.SimulateJobSuccess(cell2.CellMappingJobName)

Expand Down Expand Up @@ -450,14 +450,14 @@ var _ = Describe("Nova multicell", func() {
GetNovaCell(cell2.CellName)
GetNovaConductor(cell2.CellConductorName)

th.SimulateStatefulSetReplicaReady(cell2.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell2.CellDBSyncJobName)
th.ExpectCondition(
cell2.CellConductorName,
ConditionGetterFunc(NovaConductorConditionGetter),
condition.DBSyncReadyCondition,
corev1.ConditionTrue,
)
th.SimulateStatefulSetReplicaReady(cell2.NoVNCProxyNameStatefulSetName)
th.SimulateStatefulSetReplicaReady(cell2.ConductorStatefulSetName)
th.ExpectCondition(
cell2.CellName,
Expand Down Expand Up @@ -601,8 +601,8 @@ var _ = Describe("Nova multicell", func() {
th.SimulateJobSuccess(cell0.CellMappingJobName)

// As cell0 is ready cell1 is deployed
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName)
th.SimulateJobSuccess(cell1.CellMappingJobName)

Expand Down Expand Up @@ -769,10 +769,10 @@ var _ = Describe("Nova multicell", func() {
Expect(cell0cond.Get(novav1.NovaMetadataReadyCondition)).Should(BeNil())

// As cell0 is ready cell1 is deployed
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName)
th.SimulateStatefulSetReplicaReady(cell1.MetadataStatefulSetName)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellMappingJobName)

th.ExpectCondition(
Expand Down
2 changes: 1 addition & 1 deletion test/functional/nova_novncproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var _ = Describe("NovaNoVNCProxy controller", func() {
ContainSubstring("novncproxy_port = 6080")))
Expect(configDataMap.Data).Should(
HaveKeyWithValue("01-nova.conf",
ContainSubstring("novncproxy_base_url = http://0.0.0.0:6080/vnc_auto.html")))
ContainSubstring("novncproxy_base_url = http:/vnc_lite.htm")))
Expect(configDataMap.Data).Should(
HaveKeyWithValue("02-nova-override.conf", "foo=bar"))
})
Expand Down
4 changes: 2 additions & 2 deletions test/functional/nova_reconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
th.SimulateStatefulSetReplicaReady(novaNames.APIDeploymentName)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)

th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell1.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName)
th.SimulateJobSuccess(cell1.CellMappingJobName)

th.SimulateJobSuccess(cell2.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell2.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell2.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell2.ConductorStatefulSetName)
th.SimulateJobSuccess(cell2.CellMappingJobName)
th.SimulateStatefulSetReplicaReady(novaNames.SchedulerStatefulSetName)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/novaexternalcompute_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func CreateNovaCellAndEnsureReady(cell CellNames) {
spec["cellName"] = cell.CellName.Name
DeferCleanup(th.DeleteInstance, CreateNovaCell(cell.CellName, spec))

th.SimulateJobSuccess(cell.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell.NoVNCProxyNameStatefulSetName)
th.SimulateJobSuccess(cell.CellDBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell.ConductorStatefulSetName)

th.ExpectCondition(
Expand Down

0 comments on commit fc81248

Please sign in to comment.