Skip to content

Use MultiTemplateDir for the support of multi-segment dir in template#1096

Open
amartyasinha wants to merge 1 commit into
openstack-k8s-operators:mainfrom
amartyasinha:restructure-template
Open

Use MultiTemplateDir for the support of multi-segment dir in template#1096
amartyasinha wants to merge 1 commit into
openstack-k8s-operators:mainfrom
amartyasinha:restructure-template

Conversation

@amartyasinha
Copy link
Copy Markdown
Contributor

@amartyasinha amartyasinha commented Apr 9, 2026

With the restructure of the templates dir to have multi-segment dir, this commit ensures the proper templating from these dirs.

lib-common change introducing MultiTemplateDir: openstack-k8s-operators/lib-common#682

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 9, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/f92eab4ff0494c3c974f4b47862cc437

openstack-meta-content-provider FAILURE in 9m 22s
⚠️ nova-operator-kuttl SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode-ceph SKIPPED Skipped due to failed job openstack-meta-content-provider

@amartyasinha amartyasinha force-pushed the restructure-template branch from 833acea to 4205714 Compare April 10, 2026 11:29
@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/bd483d15a9304711826243d8e3546a72

openstack-meta-content-provider FAILURE in 9m 49s
⚠️ nova-operator-kuttl SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode-ceph SKIPPED Skipped due to failed job openstack-meta-content-provider

@bogdando
Copy link
Copy Markdown
Contributor

So for Kinds that already had explicit cases in #1090, GetTemplateSubpath is intended to reproduce the same nova/... paths. For Kinds that previously fell through the old default strings.ToLower(kind), this PR implicitly switches them to the GetTemplateSubpath rule (NovaCell -> nova/cell instead of novacell). The
PR, as shown, does not:

  • document that audit,
  • add per-Kind overrides, or
  • move template trees for those Kinds (create templates/nova/cell/... and retire templates/novacell/... etc)

@amartyasinha
Copy link
Copy Markdown
Contributor Author

This PR intends to remove the InstanceType overloading (done in #1090), and leave InstanceType to only have kind as value. MultiTemplateDir is an optional parameter, when used will take over to set the subdir during templating. Only when this parameter is set, GetTemplateSubpath will be executed.

Regarding

  • document that audit,

I did not get where to audit this change. Should I amend the commit message to include all details, or add them somewhere else?

  • add per-Kind overrides, or

Sorry, did not get it. Could you please explain it a bit (maybe an example would be helpful)

  • move template trees for those Kinds (create templates/nova/cell/... and retire templates/novacell/... etc)

IIUC, #1090 has already moved template trees for all kinds as templates/nova/<kind>/.., and we do not have templates/nova<kind>/... Please correct me if I've missed something.

@amartyasinha amartyasinha marked this pull request as ready for review April 14, 2026 07:18
@openshift-ci openshift-ci Bot requested review from mrkisaolamb and stuggi April 14, 2026 07:18
@amartyasinha amartyasinha changed the title [DNM] Use MultiTemplateDir for the support of multi-segment dir in template Use MultiTemplateDir for the support of multi-segment dir in template Apr 14, 2026
@amartyasinha amartyasinha marked this pull request as draft April 14, 2026 07:19
@amartyasinha amartyasinha changed the title Use MultiTemplateDir for the support of multi-segment dir in template [DNM] Use MultiTemplateDir for the support of multi-segment dir in template Apr 14, 2026
Copy link
Copy Markdown
Contributor

@gibizer gibizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try to run a build and test in CI by temporarily adding the new lib-common hash to the go.mod file so the build can see the new field.

Comment thread internal/controller/nova/common.go Outdated
Type: util.TemplateTypeConfig,
InstanceType: getTemplateInstanceType(instance),
InstanceType: gvk.Kind,
MultiTemplateDir: util.GetTemplateSubpath(gvk.Group, gvk.Kind),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is where the change go too far by trying to generate the path instead of just defining the path per service. Trying to support the generation is just unnecessary complexity. Simply define the path per service in the nova-operator then we can avoid this complexity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack! I thought we need to generate path from kind, i.e. NovaAPI -> nova + api. Since we can define the path directly instead of generating, I'll remove the generation functions from lib-common, and close the CRD spec modification PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defined the path instead of generating them

Namespace: instance.Namespace,
Type: util.TemplateTypeScripts,
InstanceType: instance.GetObjectKind().GroupVersionKind().Kind,
MultiTemplateDir: "nova/nova-manage",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp this is the correct use of the new interface.

Explicit is better than implicit.
Simple is better than complex.

templateParameters map[string]any,
extraData map[string]string, cmLabels map[string]string,
additionalTemplates map[string]string,
withScripts bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You probably need a new param here to pass the template dir.
  • Or you can try to change the instance client.Object to be a specific interface type where the interface defines a getter for the template dir and then implement that
    interface function for our Objects
  • Or you can add the getter for the ReconcileBase and then implement it in each Reconciler to return the service specific path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new param templateDir.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amartyasinha
Once this PR has been reviewed and has the lgtm label, please ask for approval from gibizer. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@amartyasinha amartyasinha force-pushed the restructure-template branch 2 times, most recently from cb7af73 to 8e6c407 Compare April 16, 2026 08:29
@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/543c38b98e54484585ca5047ccff327d

openstack-meta-content-provider FAILURE in 9m 11s
⚠️ nova-operator-kuttl SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode-ceph SKIPPED Skipped due to failed job openstack-meta-content-provider

@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/de67ec79fde947fdb7710c52538dff49

✔️ openstack-meta-content-provider SUCCESS in 3h 47m 10s
nova-operator-kuttl FAILURE in 47m 24s
✔️ nova-operator-tempest-multinode SUCCESS in 2h 07m 44s
✔️ nova-operator-tempest-multinode-ceph SUCCESS in 3h 07m 09s

@amartyasinha
Copy link
Copy Markdown
Contributor Author

recheck nova-operator-kuttl

Copy link
Copy Markdown
Contributor

@gibizer gibizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me.

InstanceType: getTemplateInstanceType(instance),
InstanceType: instance.GetObjectKind().GroupVersionKind().Kind,
Labels: labels,
CustomData: data,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we are not loading any template from file here hence we don't need to pass a templateDir. If I'm correct then a comment would be nice here about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lib-common, we do not check InstanceType (old logic) or MultiTemplateDir (new change) if template type is none.
Ref: https://github.com/amartyasinha/lib-common/blob/135bf0acdeafc623f9f9f855ca6850748664ff69/modules/common/util/template_util.go#L297

Will add a comment in there in code to clarify.

Comment thread go.mod Outdated

replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250627150254-e9823e99808e //allow-merging

replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/amartyasinha/lib-common/modules/common v0.0.0-20260416075014-135bf0acdeaf
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yepp this way we can get CI results. After the lib-common change lands we need to remove this line but that is a small price to pay to have early CI results

Comment thread internal/controller/nova/nova_controller.go
@amartyasinha amartyasinha force-pushed the restructure-template branch from ff25b96 to ec94f8a Compare April 16, 2026 15:08
@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/31acb1fdb20342ca9bd0d672e26cc7d0

✔️ openstack-meta-content-provider SUCCESS in 2h 57m 37s
nova-operator-kuttl RETRY_LIMIT in 36m 59s
✔️ nova-operator-tempest-multinode SUCCESS in 2h 20m 35s
✔️ nova-operator-tempest-multinode-ceph SUCCESS in 2h 41m 38s

@amartyasinha
Copy link
Copy Markdown
Contributor Author

recheck nova-operator-kuttl

Type: util.TemplateTypeNone,
InstanceType: getTemplateInstanceType(instance),
InstanceType: instance.GetObjectKind().GroupVersionKind().Kind,
MultiTemplateDir: "nova/metadata",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that other callers with TemplateTypeNone do NOT provide MultiTemplateDir.
Why this one is special?

Please evaluate it for consistency with lib-common behavior and other call sites

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch! removed MultiTemplateDir here as this specific case is of TemplateTypeNone.

Namespace: instance.GetNamespace(),
Type: util.TemplateTypeConfig,
InstanceType: getTemplateInstanceType(instance),
InstanceType: instance.GetObjectKind().GroupVersionKind().Kind,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a NovaCell instance, lib-common will look under a subdir derived from "novacell", not "nova/compute". Is that expected?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks about right, sorry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np!

configName := instance.GetName() + "-compute-config"
err := r.GenerateConfigs(
ctx, h, instance, configName, &hashes, templateParameters, extraData, cmLabels, map[string]string{},
ctx, h, instance, configName, &hashes, templateParameters, extraData, cmLabels, map[string]string{}, "nova/compute",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see that this resolved the 'novacell' mismatching behavior I thought still takes place

@amartyasinha amartyasinha force-pushed the restructure-template branch 2 times, most recently from 3f89221 to ccbea21 Compare April 17, 2026 09:37
@amartyasinha amartyasinha marked this pull request as ready for review April 17, 2026 09:48
@openshift-ci openshift-ci Bot requested a review from abays April 17, 2026 09:48
@amartyasinha amartyasinha changed the title [DNM] Use MultiTemplateDir for the support of multi-segment dir in template Use MultiTemplateDir for the support of multi-segment dir in template Apr 17, 2026
@amartyasinha amartyasinha force-pushed the restructure-template branch 2 times, most recently from a13603e to 809d07c Compare April 17, 2026 10:48
@amartyasinha
Copy link
Copy Markdown
Contributor Author

lib-common bump PR: #1088

@softwarefactory-project-zuul
Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/5dd4abb4e8b844e8a0187f87ccbc6b30

openstack-meta-content-provider FAILURE in 8m 44s
⚠️ nova-operator-kuttl SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode SKIPPED Skipped due to failed job openstack-meta-content-provider
⚠️ nova-operator-tempest-multinode-ceph SKIPPED Skipped due to failed job openstack-meta-content-provider

@stuggi
Copy link
Copy Markdown
Contributor

stuggi commented Apr 17, 2026

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

@amartyasinha
Copy link
Copy Markdown
Contributor Author

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

The bump has happened in that PR. What's the procedure to get that merged?

@stuggi
Copy link
Copy Markdown
Contributor

stuggi commented Apr 20, 2026

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

The bump has happened in that PR. What's the procedure to get that merged?

the lib-common PR got merged, but the reference in the go.mod of the nova-operator was not bumped yet. you'd have to do that. https://github.com/openstack-k8s-operators/nova-operator/blob/main/go.mod#L15-L17

@amartyasinha
Copy link
Copy Markdown
Contributor Author

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

The bump has happened in that PR. What's the procedure to get that merged?

the lib-common PR got merged, but the reference in the go.mod of the nova-operator was not bumped yet. you'd have to do that. https://github.com/openstack-k8s-operators/nova-operator/blob/main/go.mod#L15-L17

Yes, get that. This automation PR [1] is bumping the lib-common changes in nova-operator. It now points to the latest commit id 81c71b3 of lib-common. So, I was wondering will you merge that PR or @gibizer ?

[1] https://github.com/openstack-k8s-operators/nova-operator/pull/1088/changes

@stuggi
Copy link
Copy Markdown
Contributor

stuggi commented Apr 20, 2026

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

The bump has happened in that PR. What's the procedure to get that merged?

the lib-common PR got merged, but the reference in the go.mod of the nova-operator was not bumped yet. you'd have to do that. https://github.com/openstack-k8s-operators/nova-operator/blob/main/go.mod#L15-L17

Yes, get that. This automation PR [1] is bumping the lib-common changes in nova-operator. It now points to the latest commit id 81c71b3 of lib-common. So, I was wondering will you merge that PR or @gibizer ?

[1] https://github.com/openstack-k8s-operators/nova-operator/pull/1088/changes

yes, when tests passed, we can approve it

@amartyasinha
Copy link
Copy Markdown
Contributor Author

lib-common bump PR: #1088

you'd have to bump lib-common in go.mod and api/go.mod in this pr, or wait for a next bump to happen.

The bump has happened in that PR. What's the procedure to get that merged?

the lib-common PR got merged, but the reference in the go.mod of the nova-operator was not bumped yet. you'd have to do that. https://github.com/openstack-k8s-operators/nova-operator/blob/main/go.mod#L15-L17

Yes, get that. This automation PR [1] is bumping the lib-common changes in nova-operator. It now points to the latest commit id 81c71b3 of lib-common. So, I was wondering will you merge that PR or @gibizer ?
[1] https://github.com/openstack-k8s-operators/nova-operator/pull/1088/changes

yes, when tests passed, we can approve it

ack! thanks

@amartyasinha amartyasinha force-pushed the restructure-template branch from 809d07c to 06fa137 Compare April 21, 2026 07:42
With the restructure of the templates dir to have multi-segment dir,
this commit ensures the proper templating from these dirs.

Signed-off-by: Amartya Sinha <amsinha@redhat.com>
@amartyasinha amartyasinha force-pushed the restructure-template branch from 06fa137 to defa882 Compare April 21, 2026 08:04
@amartyasinha
Copy link
Copy Markdown
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants