-
Notifications
You must be signed in to change notification settings - Fork 22
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
CNF-14679: Adapt to single H/W manager plugin #220
base: main
Are you sure you want to change the base?
Conversation
@tliu2021: This pull request references CNF-14679 which is a valid jira issue. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Makefile
Outdated
@@ -170,7 +173,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified | |||
.PHONY: deploy | |||
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. | |||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | |||
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f - | |||
$(KUSTOMIZE) build config/default | sed 's|\plugin-namespace-placeholder|$(HWMGR_PLUGIN_NAMESPACE)|g' | $(KUBECTL) apply -f - |
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.
Is this a common method for doing such customizations? TALM sets a number of env variables by creating a patch.yaml that gets applied by the kustomization.yaml:
https://github.com/openshift-kni/cluster-group-upgrades-operator/blob/main/Makefile#L268
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 am not sure if the TALM approach is the best option. I'll investigate further to see if there's a better way to handle 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.
Kustomize in FluxCD (kustomize.toolkit.fluxcd.io) supports post-build variable substitution, but I don't think it's necessary to introduce that feature just for this. Instead, I'm using a ConfigMap to pass the environment variable to the deployment.
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 just seemed like TALM's method of creating a patch with env vars is a little more formal than doing a sed to modify the output of the kustomize build while piping to the apply
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 agree, but I believe using a ConfigMap with Kustomize Replacements is also a solid solution for this use case.
// GetHwMgrPluginNS returns the value of environment variable HWMGR_PLUGIN_NAMESPACE | ||
func GetHwMgrPluginNS() string { | ||
// Ensure that this code only runs once | ||
once.Do(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.
This once.Do
is new to me... Very cool!
@@ -42,6 +42,9 @@ type NodePoolSpec struct { | |||
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Location Spec",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} | |||
LocationSpec `json:",inline"` | |||
|
|||
// HwMgrId is the identifier for the hardware manager plugin adaptor. | |||
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` |
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.
This breaks the current plugin code, as it is adding a new required field. I think add omitempty
here may avoid that. We can likely drop the omitempty
later once the plugin is updated to know about the new field.
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.
Verified that adding omitempty
allows the current plugin code to work, which is referencing the previous version of the CRD, which it causes a failure to update the CR without it, as it would be missing this new field.
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` | |
HwMgrId string `json:"hwMgrId,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.
Right, need to support the current plugin code.
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.
Updated.
@@ -42,6 +42,9 @@ type NodePoolSpec struct { | |||
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Location Spec",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} | |||
LocationSpec `json:",inline"` | |||
|
|||
// HwMgrId is the identifier for the hardware manager plugin adaptor. | |||
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` |
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.
Is the yaml
field necessary? The code seems inconsistent about using it. It's there for some fields, but not all. If it's not needed, if the yaml would default to the json field, we should drop it altogether
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.
The yaml field is not needed and it will be removed.
/retest |
/lgtm |
/retest |
@tliu2021: 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. |
Signed-off-by: Tao Liu <tali@redhat.com>
This update introduces the following changes:
Note: To continue using the test plugin, use the following commands:
make run HWMGR_PLUGIN_NAMESPACE=oran-hwmgr-plugin-test
make deploy HWMGR_PLUGIN_NAMESPACE=oran-hwmgr-plugin-test