-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MULTIARCH-5058: Implement the node affinity scoring specs in the ClusterPodPlacementConfig #369
base: main
Are you sure you want to change the base?
Conversation
@pkenchap: This pull request references MULTIARCH-5058 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/assign @pkenchap |
2337fb3
to
7994305
Compare
7994305
to
e5e67dd
Compare
bundle/manifests/multiarch-tuning-operator.clusterserviceversion.yaml
Outdated
Show resolved
Hide resolved
bundle/manifests/multiarch.openshift.io_clusterpodplacementconfigs.yaml
Outdated
Show resolved
Hide resolved
config/crd/bases/multiarch.openshift.io_clusterpodplacementconfigs.yaml
Outdated
Show resolved
Hide resolved
bundle/manifests/multiarch.openshift.io_clusterpodplacementconfigs.yaml
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,5 @@ | |||
## Append samples you want in your CSV to this file as resources ## | |||
resources: | |||
- multiarch_v1beta1_nodeaffinityscoring_clusterpodplacementconfig.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this in a subfolder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not getting the point of this customization.... is it autogenerated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we do not need this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sure , I can remove this .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this and solve this comment to start wrapping up?
...les/nodeaffinityscoring/multiarch_v1beta1_nodeaffinityscoring_clusterpodplacementconfig.yaml
Outdated
Show resolved
Hide resolved
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
plugin := &plugins.BasePlugin{Enabled: tt.enabled} | ||
if plugin.IsEnabled() != tt.expected { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if plugin.IsEnabled() != tt.expected { | |
if plugin.IsEnabled() != tt.enabled { |
This unit test concers the correcteness of the IsEnabled
function. Given the simplicity, it's ok not to duplicate the expected value and use tt.enabled
.
|
||
// Plugins selects the namespaces where the pod placement operand can process the nodeAffinityScoring | ||
// of the pods. If left empty, all the namespaces are considered. | ||
// The default sample allows to exclude all the namespaces where the | ||
// +optional | ||
Plugins plugins.Plugins `json:"plugins,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Plugins selects the namespaces where the pod placement operand can process the nodeAffinityScoring | |
// of the pods. If left empty, all the namespaces are considered. | |
// The default sample allows to exclude all the namespaces where the | |
// +optional | |
Plugins plugins.Plugins `json:"plugins,omitempty"` |
We should not update the v1alpha1 api.
3c1b3d3
to
66961d9
Compare
/retest |
66961d9
to
ffcb685
Compare
By("Creating a v1beta1 ClusterPodPlacementConfig") | ||
// err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).Build()) | ||
// Expect(err).NotTo(HaveOccurred(), "failed to create ClusterPodPlacementConfig", err) | ||
// validateReconcile() | ||
// Get the details | ||
ppc := &v1beta1.ClusterPodPlacementConfig{} | ||
err := k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: common.SingletonResourceObjectName, | ||
Namespace: utils.Namespace(), | ||
}, | ||
Spec: v1beta1.ClusterPodPlacementConfigSpec{ | ||
LogVerbosity: "Normal", | ||
Plugins: plugins.Plugins{ | ||
NodeAffinityScoring: &plugins.NodeAffinityScoring{ | ||
BasePlugin: plugins.BasePlugin{ | ||
Enabled: true, | ||
}, | ||
Platforms: []plugins.NodeAffinityScoringPlatformTerm{ | ||
{Architecture: utils.ArchitectureArm64, Weight: 50}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), ppc) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Eventually(func(g Gomega) { | ||
// Verify the LogVerbosity field | ||
g.Expect(ppc.Spec.LogVerbosity).NotTo(Equal("Normal")) | ||
// Verify the Plugins field | ||
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring).To(BeNil()) | ||
}).Should(Succeed()) | ||
}) | ||
It("does not query the remote registry until the cache expires", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By("Creating a v1beta1 ClusterPodPlacementConfig") | |
// err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).Build()) | |
// Expect(err).NotTo(HaveOccurred(), "failed to create ClusterPodPlacementConfig", err) | |
// validateReconcile() | |
// Get the details | |
ppc := &v1beta1.ClusterPodPlacementConfig{} | |
err := k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: common.SingletonResourceObjectName, | |
Namespace: utils.Namespace(), | |
}, | |
Spec: v1beta1.ClusterPodPlacementConfigSpec{ | |
LogVerbosity: "Normal", | |
Plugins: plugins.Plugins{ | |
NodeAffinityScoring: &plugins.NodeAffinityScoring{ | |
BasePlugin: plugins.BasePlugin{ | |
Enabled: true, | |
}, | |
Platforms: []plugins.NodeAffinityScoringPlatformTerm{ | |
{Architecture: utils.ArchitectureArm64, Weight: 50}, | |
}, | |
}, | |
}, | |
}, | |
}), ppc) | |
Expect(err).NotTo(HaveOccurred()) | |
Eventually(func(g Gomega) { | |
// Verify the LogVerbosity field | |
g.Expect(ppc.Spec.LogVerbosity).NotTo(Equal("Normal")) | |
// Verify the Plugins field | |
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring).To(BeNil()) | |
}).Should(Succeed()) | |
}) | |
It("does not query the remote registry until the cache expires", func() { |
}).Should(Succeed()) | ||
}) | ||
It("does not query the remote registry until the cache expires", func() { | ||
cppc := &v1beta1.ClusterPodPlacementConfig{ObjectMeta: metav1.ObjectMeta{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the builder here.
cppc := &v1beta1.ClusterPodPlacementConfig{ObjectMeta: metav1.ObjectMeta{ | |
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).WithNodeAffinityScoringTerm(utils.ArchitectureArm64, 50).Build()) | |
Expect(err).NotTo(HaveOccurred(), "failed to create ClusterPodPlacementConfig", err) | |
validateReconcile() |
Where WithNodeAffinityScoringPlugin and WithNodeAffinityScoringTerm are two methods to be implemented in https://github.com/openshift/multiarch-tuning-operator/blob/main/pkg/testing/builder/clusterpodplacementconfig.go.
The first only gets the value for the enabled
field, the second gets (string, int) to append an element in the Platforms slice of the Plugins.NodeAffinityScoring spec of the CPPC.
}, v1alpha1obj) | ||
Eventually(func(g Gomega) { | ||
// Verify the LogVerbosity field | ||
g.Expect(v1alpha1obj.Spec.LogVerbosity).NotTo(Equal("Normal")) | ||
|
||
// Then, fetch it to ensure it exists and check the fields | ||
ppc := &v1beta1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(cppc), ppc) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
// Verify the LogVerbosity field | ||
g.Expect(ppc.Spec.LogVerbosity).To(Equal("Normal")) | ||
// Verify the Plugins field | ||
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring).NotTo(BeNil()) | ||
// verify the enabled bool | ||
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring.Enabled).To(BeTrue()) | ||
// verify platform | ||
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring.Platforms).To(ConsistOf( | ||
plugins.NodeAffinityScoringPlatformTerm{Architecture: "ppc64le", Weight: 50}, | ||
)) | ||
}).Should(Succeed()) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, v1alpha1obj) | |
Eventually(func(g Gomega) { | |
// Verify the LogVerbosity field | |
g.Expect(v1alpha1obj.Spec.LogVerbosity).NotTo(Equal("Normal")) | |
// Then, fetch it to ensure it exists and check the fields | |
ppc := &v1beta1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(cppc), ppc) | |
Expect(err).NotTo(HaveOccurred()) | |
// Verify the LogVerbosity field | |
g.Expect(ppc.Spec.LogVerbosity).To(Equal("Normal")) | |
// Verify the Plugins field | |
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring).NotTo(BeNil()) | |
// verify the enabled bool | |
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring.Enabled).To(BeTrue()) | |
// verify platform | |
g.Expect(ppc.Spec.Plugins.NodeAffinityScoring.Platforms).To(ConsistOf( | |
plugins.NodeAffinityScoringPlatformTerm{Architecture: "ppc64le", Weight: 50}, | |
)) | |
}).Should(Succeed()) | |
}) | |
}, v1alpha1obj) | |
Expect(err).NotTo(HaveOccurred()) |
No need for the Eventually block here.
4e57349
to
1188b97
Compare
/test unit |
1188b97
to
a473f06
Compare
} | ||
|
||
func (p *ClusterPodPlacementConfigBuilder) WithNodeAffinityScoringTerm(architecture string, weight int32) *ClusterPodPlacementConfigBuilder { | ||
p.Spec.Plugins.NodeAffinityScoring.Platforms = []plugins.NodeAffinityScoringPlatformTerm{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should append to an existing Platforms list or create if it's still nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes , even test was failing as it was not initialised . will check for nil.
@@ -34,3 +35,14 @@ func (p *ClusterPodPlacementConfigBuilder) WithLogVerbosity(logVerbosity common. | |||
func (p *ClusterPodPlacementConfigBuilder) Build() *v1beta1.ClusterPodPlacementConfig { | |||
return p.ClusterPodPlacementConfig | |||
} | |||
|
|||
func (p *ClusterPodPlacementConfigBuilder) WithNodeAffinityScoring(enabled bool) *ClusterPodPlacementConfigBuilder { | |||
p.Spec.Plugins.NodeAffinityScoring.Enabled = enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd check if Plugins and NodeAffinityScoring are initialized first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sure , updated .
034c721
to
63bda32
Compare
/retest-required |
It("Should be possible to get the CPPC as a v1alpha1 with specs invalid weight regarding the plugins", func() { | ||
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | ||
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).WithNodeAffinityScoringTerm(utils.ArchitectureArm64, 200).Build()) | ||
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig invalid weight", err) | ||
validateReconcile() | ||
// Get the details | ||
ppc := &v1beta1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: common.SingletonResourceObjectName, | ||
Namespace: utils.Namespace(), | ||
}, | ||
}), ppc) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig invalid weight", err) | ||
// Get v1alpha1 ClusterPodPlacementConfig | ||
By("Get a v1alpha1 ClusterPodPlacementConfig") | ||
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKey{ | ||
Name: common.SingletonResourceObjectName, | ||
}, v1alpha1obj) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig invalid weight", err) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It("Should be possible to get the CPPC as a v1alpha1 with specs invalid weight regarding the plugins", func() { | |
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | |
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).WithNodeAffinityScoringTerm(utils.ArchitectureArm64, 200).Build()) | |
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig invalid weight", err) | |
validateReconcile() | |
// Get the details | |
ppc := &v1beta1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: common.SingletonResourceObjectName, | |
Namespace: utils.Namespace(), | |
}, | |
}), ppc) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig invalid weight", err) | |
// Get v1alpha1 ClusterPodPlacementConfig | |
By("Get a v1alpha1 ClusterPodPlacementConfig") | |
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKey{ | |
Name: common.SingletonResourceObjectName, | |
}, v1alpha1obj) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig invalid weight", err) | |
}) | |
It("Should not allow invalid weigths", func() { | |
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | |
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).WithNodeAffinityScoringTerm(utils.ArchitectureArm64, 200).Build()) | |
Expect(err).To(HaveOccurred(), "no ClusterPodPlacementConfig with invalid weights in the plugins.NodeAffinityScoring.Platforms[].Weight should be accepted", err) | |
}) |
It("Should be possible to get the CPPC as a v1alpha1 with specs only enabled regarding the plugins", func() { | ||
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | ||
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).Build()) | ||
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig enabled", err) | ||
validateReconcile() | ||
// Get the details | ||
ppc := &v1beta1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: common.SingletonResourceObjectName, | ||
Namespace: utils.Namespace(), | ||
}, | ||
}), ppc) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig enabled", err) | ||
// Get v1alpha1 ClusterPodPlacementConfig | ||
By("Get a v1alpha1 ClusterPodPlacementConfig") | ||
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKey{ | ||
Name: common.SingletonResourceObjectName, | ||
}, v1alpha1obj) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig enabled", err) | ||
}) | ||
It("Should be possible to get the CPPC as a v1alpha1 with specs enabled false regarding the plugins", func() { | ||
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | ||
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(false).Build()) | ||
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig enabled false", err) | ||
validateReconcile() | ||
// Get the details | ||
ppc := &v1beta1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: common.SingletonResourceObjectName, | ||
Namespace: utils.Namespace(), | ||
}, | ||
}), ppc) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig enabled false", err) | ||
// Get v1alpha1 ClusterPodPlacementConfig | ||
By("Get a v1alpha1 ClusterPodPlacementConfig") | ||
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | ||
err = k8sClient.Get(ctx, crclient.ObjectKey{ | ||
Name: common.SingletonResourceObjectName, | ||
}, v1alpha1obj) | ||
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig enabled false", err) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It("Should be possible to get the CPPC as a v1alpha1 with specs only enabled regarding the plugins", func() { | |
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | |
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(true).Build()) | |
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig enabled", err) | |
validateReconcile() | |
// Get the details | |
ppc := &v1beta1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: common.SingletonResourceObjectName, | |
Namespace: utils.Namespace(), | |
}, | |
}), ppc) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig enabled", err) | |
// Get v1alpha1 ClusterPodPlacementConfig | |
By("Get a v1alpha1 ClusterPodPlacementConfig") | |
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKey{ | |
Name: common.SingletonResourceObjectName, | |
}, v1alpha1obj) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig enabled", err) | |
}) | |
It("Should be possible to get the CPPC as a v1alpha1 with specs enabled false regarding the plugins", func() { | |
By("Creating a v1beta1 ClusterPodPlacementConfig invalid weight") | |
err := k8sClient.Create(ctx, builder.NewClusterPodPlacementConfig().WithName(common.SingletonResourceObjectName).WithNodeAffinityScoring(false).Build()) | |
Expect(err).NotTo(HaveOccurred(), "failed to create v1beta1 ClusterPodPlacementConfig enabled false", err) | |
validateReconcile() | |
// Get the details | |
ppc := &v1beta1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKeyFromObject(&v1beta1.ClusterPodPlacementConfig{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: common.SingletonResourceObjectName, | |
Namespace: utils.Namespace(), | |
}, | |
}), ppc) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1beta1 ClusterPodPlacementConfig enabled false", err) | |
// Get v1alpha1 ClusterPodPlacementConfig | |
By("Get a v1alpha1 ClusterPodPlacementConfig") | |
v1alpha1obj := &v1alpha1.ClusterPodPlacementConfig{} | |
err = k8sClient.Get(ctx, crclient.ObjectKey{ | |
Name: common.SingletonResourceObjectName, | |
}, v1alpha1obj) | |
Expect(err).NotTo(HaveOccurred(), "failed to get v1alpha1 ClusterPodPlacementConfig enabled false", err) | |
}) |
2b1266b
to
42fcd8d
Compare
…terPodPlacementConfig Signed-off-by: Punith Kenchappa <[email protected]>
42fcd8d
to
b69a651
Compare
@pkenchap: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Task to add the nodeAffinityScoring for ClusterPodPlacemetnConfig API specs can be updated as in the following to host a skeleton of plugins, currently implementing only the nodeAffinityScoring.
Example: