Skip to content

Commit

Permalink
infra: use poolnames
Browse files Browse the repository at this point in the history
The setup code is heavily integrated with MCPs.
This is good enough for OpenShift but a no-go
for HyperShift.

Hence, lets generalize the flow to use PoolName
instead, which is acceptable for both platforms.

Signed-off-by: Talor Itzhak <[email protected]>
  • Loading branch information
Tal-or committed Jan 27, 2025
1 parent d986e3a commit 0f3b426
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
17 changes: 4 additions & 13 deletions nrovalidate/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ import (
"github.com/k8stopologyawareschedwg/deployer/pkg/validator"
deployervalidator "github.com/k8stopologyawareschedwg/deployer/pkg/validator"

nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
"github.com/openshift-kni/numaresources-operator/internal/machineconfigpools"
"github.com/openshift-kni/numaresources-operator/internal/nodegroups"
"github.com/openshift-kni/numaresources-operator/pkg/objectnames"

nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
)

type Report struct {
Expand Down Expand Up @@ -176,19 +175,11 @@ func GetNodesByNRO(ctx context.Context, cli client.Client) (sets.Set[string], er
if err != nil {
return enabledNodeNames, err
}

nroMcps, err := machineconfigpools.GetListByNodeGroupsV1(ctx, cli, nroInstance.Spec.NodeGroups)
nodes, err := nodegroups.GetNodesFrom(ctx, cli, nroInstance.Spec.NodeGroups)
if err != nil {
return enabledNodeNames, err
}

for _, mcp := range nroMcps {
nodes, err := getNodeListFromMachineConfigPool(ctx, cli, *mcp)
if err != nil {
return enabledNodeNames, err
}
enabledNodeNames.Insert(getNodeNames(nodes)...)
}
enabledNodeNames.Insert(getNodeNames(nodes)...)

return enabledNodeNames, nil
}
Expand Down
22 changes: 9 additions & 13 deletions test/e2e/serial/config/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import (
nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"

nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
"github.com/openshift-kni/numaresources-operator/internal/machineconfigpools"
"github.com/openshift-kni/numaresources-operator/pkg/objectnames"

"github.com/openshift-kni/numaresources-operator/internal/wait"

numacellapi "github.com/openshift-kni/numaresources-operator/test/deviceplugin/pkg/numacell/api"
numacellmanifests "github.com/openshift-kni/numaresources-operator/test/deviceplugin/pkg/numacell/manifests"

"github.com/openshift-kni/numaresources-operator/internal/nodegroups"
e2efixture "github.com/openshift-kni/numaresources-operator/test/utils/fixture"
"github.com/openshift-kni/numaresources-operator/test/utils/images"
)
Expand All @@ -61,10 +61,9 @@ func setupNUMACell(fxt *e2efixture.Fixture, nodeGroups []nropv1.NodeGroup, nrtLi

Expect(nodeGroups).ToNot(BeEmpty(), "cannot autodetect the TAS node groups from the cluster")

mcps, err := machineconfigpools.GetListByNodeGroupsV1(context.TODO(), fxt.Client, nodeGroups)
poolNames, err := nodegroups.GetPoolNamesFrom(context.TODO(), fxt.Client, nodeGroups)
Expect(err).ToNot(HaveOccurred())

klog.Infof("setting e2e infra for %d MCPs", len(mcps))
klog.Infof("setting e2e infra for %d pools", len(poolNames))

sa := numacellmanifests.ServiceAccount(fxt.Namespace.Name, numacellmanifests.Prefix)
err = fxt.Client.Create(context.TODO(), sa)
Expand All @@ -79,17 +78,14 @@ func setupNUMACell(fxt *e2efixture.Fixture, nodeGroups []nropv1.NodeGroup, nrtLi
Expect(err).ToNot(HaveOccurred(), "cannot create the numacell rolebinding %q in the namespace %q", sa.Name, sa.Namespace)

var dss []*appsv1.DaemonSet
for _, mcp := range mcps {
if mcp.Spec.NodeSelector == nil {
klog.Warningf("the machine config pool %q does not have node selector", mcp.Name)
continue
}

dsName := objectnames.GetComponentName(numacellmanifests.Prefix, mcp.Name)
klog.Infof("setting e2e infra for %q: daemonset %q", mcp.Name, dsName)
for _, poolName := range poolNames {
dsName := objectnames.GetComponentName(numacellmanifests.Prefix, poolName)
klog.Infof("setting e2e infra for %q: daemonset %q", poolName, dsName)

pullSpec := GetNUMACellDevicePluginPullSpec()
ds := numacellmanifests.DaemonSet(mcp.Spec.NodeSelector.MatchLabels, fxt.Namespace.Name, dsName, sa.Name, pullSpec)
labels, err := nodegroups.NodeSelectorFromPoolName(context.TODO(), fxt.Client, poolName)
Expect(err).ToNot(HaveOccurred())
ds := numacellmanifests.DaemonSet(labels, fxt.Namespace.Name, dsName, sa.Name, pullSpec)
err = fxt.Client.Create(context.TODO(), ds)
Expect(err).ToNot(HaveOccurred(), "cannot create the numacell daemonset %q in the namespace %q", ds.Name, ds.Namespace)

Expand Down

0 comments on commit 0f3b426

Please sign in to comment.