Skip to content

Commit

Permalink
OCPBUGS-29641: fix rendering extra ctrcfgs (#972)
Browse files Browse the repository at this point in the history
Fix bootstrap error  of "more than one ContainerRuntimeConfig found that matches MCP labels"
when an additional ContainerRuntimeConfig is provided by user.

Signed-off-by: Vitaly Grinberg <v.g@redhat.com>
Co-authored-by: Vitaly Grinberg <v.g@redhat.com>
  • Loading branch information
vitus133 and Vitaly Grinberg authored Feb 29, 2024
1 parent 11ca6b4 commit 28bebe3
Show file tree
Hide file tree
Showing 15 changed files with 759 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/performanceprofile/cmd/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,24 +391,25 @@ func selectMachineConfigPool(pools []*mcfgv1.MachineConfigPool, selectors map[st

func getContainerRuntimeName(profile *performancev2.PerformanceProfile, mcp *mcfgv1.MachineConfigPool, ctrcfgs []*mcfgv1.ContainerRuntimeConfig) (mcfgv1.ContainerRuntimeDefaultRuntime, error) {
mcpLabels := labels.Set(mcp.Labels)
var matchingCtrConfigs []*mcfgv1.ContainerRuntimeConfig
for _, ctrcfg := range ctrcfgs {
ctrcfgSelector, err := v1.LabelSelectorAsSelector(ctrcfg.Spec.MachineConfigPoolSelector)
if err != nil {
return "", err
}
if ctrcfgSelector.Matches(mcpLabels) {
ctrcfgs = append(ctrcfgs, ctrcfg)
matchingCtrConfigs = append(matchingCtrConfigs, ctrcfg)
}
}

if len(ctrcfgs) == 0 {
if len(matchingCtrConfigs) == 0 {
klog.Infof("no ContainerRuntimeConfig found that matches MCP labels %s that associated with performance profile %q; using default container runtime", mcpLabels.String(), profile.Name)
return mcfgv1.ContainerRuntimeDefaultRuntimeRunc, nil
}

if len(ctrcfgs) > 1 {
if len(matchingCtrConfigs) > 1 {
return "", fmt.Errorf("more than one ContainerRuntimeConfig found that matches MCP labels %s that associated with performance profile %q", mcpLabels.String(), profile.Name)
}

return ctrcfgs[0].Spec.ContainerRuntimeConfig.DefaultRuntime, nil
return matchingCtrConfigs[0].Spec.ContainerRuntimeConfig.DefaultRuntime, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: machineconfiguration.openshift.io/v1
kind: ContainerRuntimeConfig
metadata:
name: enable-crun-master
spec:
containerRuntimeConfig:
defaultRuntime: crun
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/master: ""
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
snoLegacyPinnedDir string
bootstrapPPDir string
extraMCPDir string
containerRuntimeConfigDir string
)

var _ = Describe("render command e2e test", func() {
Expand All @@ -44,6 +45,7 @@ var _ = Describe("render command e2e test", func() {
defaultPinnedDir = filepath.Join(workspaceDir, "test", "e2e", "performanceprofile", "cluster-setup", "pinned-cluster", "default")
snoLegacyPinnedDir = filepath.Join(workspaceDir, "test", "e2e", "performanceprofile", "cluster-setup", "pinned-cluster", "single-node-legacy")
testDataPath = filepath.Join(workspaceDir, "test", "e2e", "performanceprofile", "testdata")
containerRuntimeConfigDir = filepath.Join(workspaceDir, "test", "e2e", "performanceprofile", "cluster-setup", "container-runtime-crun")
assetsInDirs = []string{assetsInDir, ppDir}
assetsCpuFrequencyInDirs = []string{assetsInDir, ppCpuFrequencyDir}
})
Expand Down Expand Up @@ -196,6 +198,25 @@ var _ = Describe("render command e2e test", func() {
})
})

Context("With performance profile and matching extra ContainerRuntimeConfig during bootstrap", func() {
It("should render ContainerRuntimeConfig", func() {

bootstrapPPDirs := []string{bootstrapPPDir, defaultPinnedDir, containerRuntimeConfigDir}

cmdline := []string{
filepath.Join(binPath, "cluster-node-tuning-operator"),
"render",
"--asset-input-dir", strings.Join(bootstrapPPDirs, ","),
"--asset-output-dir", assetsOutDir,
}
fmt.Fprintf(GinkgoWriter, "running: %v\n", cmdline)

cmd := exec.Command(cmdline[0], cmdline[1:]...)
runAndCompare(cmd, path.Join(bootstrapExpectedDir, "extra-ctrcfg"))

})
})

AfterEach(func() {
cleanArtifacts()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
creationTimestamp: null
labels:
machineconfiguration.openshift.io/role: master
name: 01-master-cpu-partitioning
spec:
baseOSExtensionsContainerImage: ""
config:
ignition:
config:
replace:
verification: {}
proxy: {}
security:
tls: {}
timeouts: {}
version: 3.2.0
passwd: {}
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,CnsKICAibWFuYWdlbWVudCI6IHsKICAgICJjcHVzZXQiOiAiIgogIH0KfQo=
verification: {}
group: {}
mode: 420
path: /etc/kubernetes/openshift-workload-pinning
user: {}
- contents:
source: data:text/plain;charset=utf-8;base64,CltjcmlvLnJ1bnRpbWUud29ya2xvYWRzLm1hbmFnZW1lbnRdCmFjdGl2YXRpb25fYW5ub3RhdGlvbiA9ICJ0YXJnZXQud29ya2xvYWQub3BlbnNoaWZ0LmlvL21hbmFnZW1lbnQiCmFubm90YXRpb25fcHJlZml4ID0gInJlc291cmNlcy53b3JrbG9hZC5vcGVuc2hpZnQuaW8iCnJlc291cmNlcyA9IHsgImNwdXNoYXJlcyIgPSAwLCAiY3B1c2V0IiA9ICIiIH0K
verification: {}
group: {}
mode: 420
path: /etc/crio/crio.conf.d/01-workload-pinning-default.conf
user: {}
systemd: {}
extensions: null
fips: false
kernelArguments: null
kernelType: ""
osImageURL: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
creationTimestamp: null
labels:
machineconfiguration.openshift.io/role: worker
name: 01-worker-cpu-partitioning
spec:
baseOSExtensionsContainerImage: ""
config:
ignition:
config:
replace:
verification: {}
proxy: {}
security:
tls: {}
timeouts: {}
version: 3.2.0
passwd: {}
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,CnsKICAibWFuYWdlbWVudCI6IHsKICAgICJjcHVzZXQiOiAiIgogIH0KfQo=
verification: {}
group: {}
mode: 420
path: /etc/kubernetes/openshift-workload-pinning
user: {}
- contents:
source: data:text/plain;charset=utf-8;base64,CltjcmlvLnJ1bnRpbWUud29ya2xvYWRzLm1hbmFnZW1lbnRdCmFjdGl2YXRpb25fYW5ub3RhdGlvbiA9ICJ0YXJnZXQud29ya2xvYWQub3BlbnNoaWZ0LmlvL21hbmFnZW1lbnQiCmFubm90YXRpb25fcHJlZml4ID0gInJlc291cmNlcy53b3JrbG9hZC5vcGVuc2hpZnQuaW8iCnJlc291cmNlcyA9IHsgImNwdXNoYXJlcyIgPSAwLCAiY3B1c2V0IiA9ICIiIH0K
verification: {}
group: {}
mode: 420
path: /etc/crio/crio.conf.d/01-workload-pinning-default.conf
user: {}
systemd: {}
extensions: null
fips: false
kernelArguments: null
kernelType: ""
osImageURL: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: machineconfiguration.openshift.io/v1
kind: KubeletConfig
metadata:
creationTimestamp: null
labels:
performance.openshift.io/weak-owner-reference-name: openshift-bootstrap-master
name: performance-openshift-bootstrap-master
spec:
kubeletConfig:
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
anonymous: {}
webhook:
cacheTTL: 0s
x509: {}
authorization:
webhook:
cacheAuthorizedTTL: 0s
cacheUnauthorizedTTL: 0s
containerRuntimeEndpoint: ""
cpuManagerPolicy: static
cpuManagerReconcilePeriod: 5s
evictionHard:
imagefs.available: 15%
memory.available: 100Mi
nodefs.available: 10%
nodefs.inodesFree: 5%
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
kubeReserved:
memory: 500Mi
logging:
flushFrequency: 0
options:
json:
infoBufferSize: "0"
verbosity: 0
memorySwap: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
reservedSystemCPUs: 2-7
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
systemReserved:
memory: 500Mi
topologyManagerPolicy: best-effort
volumeStatsAggPeriod: 0s
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/master: ""
status:
conditions: null
Loading

0 comments on commit 28bebe3

Please sign in to comment.