Skip to content

Commit

Permalink
api: types: remove MCP conditions status
Browse files Browse the repository at this point in the history
No longer needed since
#837 and
ever since there have been no breakages because removing that or complaints so omit them from the MCP status.

Signed-off-by: Shereen Haj <[email protected]>
  • Loading branch information
shajmakh committed Sep 20, 2024
1 parent 5d77880 commit e2e5478
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 57 deletions.
5 changes: 0 additions & 5 deletions api/numaresourcesoperator/v1/numaresourcesoperator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

configv1 "github.com/openshift/api/config/v1"
operatorv1 "github.com/openshift/api/operator/v1"
mcov1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
)

// NUMAResourcesOperatorSpec defines the desired state of NUMAResourcesOperator
Expand Down Expand Up @@ -141,10 +140,6 @@ type NUMAResourcesOperatorStatus struct {
type MachineConfigPool struct {
// Name the name of the machine config pool
Name string `json:"name"`
// Conditions represents the latest available observations of MachineConfigPool current state.
// +optional
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="Optional conditions reported for this NodeGroup"
Conditions []mcov1.MachineConfigPoolCondition `json:"conditions,omitempty"`
// NodeGroupConfig represents the latest available configuration applied to this MachineConfigPool
// +optional
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="Optional configuration enforced on this NodeGroup"
Expand Down
8 changes: 0 additions & 8 deletions api/numaresourcesoperator/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/conversion"

nropv1 "github.com/openshift-kni/numaresources-operator/api/numaresourcesoperator/v1"
mcov1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
)

var _ conversion.Convertible = &NUMAResourcesOperator{}
Expand Down Expand Up @@ -146,10 +145,6 @@ func (dst *NUMAResourcesOperator) ConvertFromV1Rote(src *nropv1.NUMAResourcesOpe
func convertMachineConfigPoolV1Alpha1ToV1(src MachineConfigPool) nropv1.MachineConfigPool {
dst := nropv1.MachineConfigPool{}
dst.Name = src.Name
if src.Conditions != nil {
dst.Conditions = make([]mcov1.MachineConfigPoolCondition, len(src.Conditions))
copy(dst.Conditions, src.Conditions)
}
if src.Config != nil {
dst.Config = convertNodeGroupConfigV1Alpha1ToV1(*src.Config)
}
Expand All @@ -159,10 +154,6 @@ func convertMachineConfigPoolV1Alpha1ToV1(src MachineConfigPool) nropv1.MachineC
func convertMachineConfigPoolV1ToV1Alpha1(src nropv1.MachineConfigPool) MachineConfigPool {
dst := MachineConfigPool{}
dst.Name = src.Name
if src.Conditions != nil {
dst.Conditions = make([]mcov1.MachineConfigPoolCondition, len(src.Conditions))
copy(dst.Conditions, src.Conditions)
}
if src.Config != nil {
dst.Config = convertNodeGroupConfigV1ToV1Alpha1(*src.Config)
}
Expand Down
18 changes: 3 additions & 15 deletions controllers/numaresourcesoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ type NUMAResourcesOperatorReconciler struct {
Images images.Data
ImagePullPolicy corev1.PullPolicy
Recorder record.EventRecorder
ForwardMCPConds bool
}

// TODO: narrow down
Expand Down Expand Up @@ -219,7 +218,7 @@ func (r *NUMAResourcesOperatorReconciler) reconcileResourceMachineConfig(ctx con

// MCO need to update SELinux context and other stuff, and need to trigger a reboot.
// It can take a while.
mcpStatuses, allMCPsUpdated := syncMachineConfigPoolsStatuses(instance.Name, trees, r.ForwardMCPConds)
mcpStatuses, allMCPsUpdated := syncMachineConfigPoolsStatuses(instance.Name, trees)
instance.Status.MachineConfigPools = mcpStatuses
if !allMCPsUpdated {
// the Machine Config Pool still did not apply the machine config, wait for one minute
Expand Down Expand Up @@ -351,14 +350,14 @@ func (r *NUMAResourcesOperatorReconciler) syncMachineConfigs(ctx context.Context
return (updatedCount == len(objStates)), err
}

func syncMachineConfigPoolsStatuses(instanceName string, trees []nodegroupv1.Tree, forwardMCPConds bool) ([]nropv1.MachineConfigPool, bool) {
func syncMachineConfigPoolsStatuses(instanceName string, trees []nodegroupv1.Tree) ([]nropv1.MachineConfigPool, bool) {
klog.V(4).InfoS("Machine Config Status Sync start", "trees", len(trees))
defer klog.V(4).Info("Machine Config Status Sync stop")

mcpStatuses := []nropv1.MachineConfigPool{}
for _, tree := range trees {
mcp := tree.MachineConfigPool
mcpStatuses = append(mcpStatuses, extractMCPStatus(mcp, forwardMCPConds))
mcpStatuses = append(mcpStatuses, nropv1.MachineConfigPool{Name: mcp.Name})

isUpdated := IsMachineConfigPoolUpdated(instanceName, mcp)
klog.V(5).InfoS("Machine Config Pool state", "name", mcp.Name, "instance", instanceName, "updated", isUpdated)
Expand All @@ -370,17 +369,6 @@ func syncMachineConfigPoolsStatuses(instanceName string, trees []nodegroupv1.Tre
return mcpStatuses, true
}

func extractMCPStatus(mcp *machineconfigv1.MachineConfigPool, forwardMCPConds bool) nropv1.MachineConfigPool {
mcpStatus := nropv1.MachineConfigPool{
Name: mcp.Name,
}
if !forwardMCPConds {
return mcpStatus
}
mcpStatus.Conditions = mcp.Status.Conditions
return mcpStatus
}

func syncMachineConfigPoolNodeGroupConfigStatuses(mcpStatuses []nropv1.MachineConfigPool, trees []nodegroupv1.Tree) []nropv1.MachineConfigPool {
klog.V(4).InfoS("Machine Config Pool Node Group Status Sync start", "mcpStatuses", len(mcpStatuses), "trees", len(trees))
defer klog.V(4).Info("Machine Config Pool Node Group Status Sync stop")
Expand Down
37 changes: 17 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,23 @@ type RenderParams struct {
}

type Params struct {
webhookPort int
metricsAddr string
enableLeaderElection bool
probeAddr string
platformName string
platformVersion string
detectPlatformOnly bool
showVersion bool
enableScheduler bool
renderMode bool
render RenderParams
enableWebhooks bool
enableMetrics bool
enableHTTP2 bool
enableMCPCondsForward bool
image ImageParams
inspectFeatures bool
enableReplicasDetect bool
webhookPort int
metricsAddr string
enableLeaderElection bool
probeAddr string
platformName string
platformVersion string
detectPlatformOnly bool
showVersion bool
enableScheduler bool
renderMode bool
render RenderParams
enableWebhooks bool
enableMetrics bool
enableHTTP2 bool
image ImageParams
inspectFeatures bool
enableReplicasDetect bool
}

func (pa *Params) SetDefaults() {
Expand Down Expand Up @@ -150,7 +149,6 @@ func (pa *Params) FromFlags() {
flag.IntVar(&pa.webhookPort, "webhook-port", defaultWebhookPort, "The port the operator webhook should listen to.")
flag.BoolVar(&pa.enableMetrics, "enable-metrics", pa.enableMetrics, "enable metrics server")
flag.BoolVar(&pa.enableHTTP2, "enable-http2", pa.enableHTTP2, "If HTTP/2 should be enabled for the webhook servers.")
flag.BoolVar(&pa.enableMCPCondsForward, "enable-mcp-conds-fwd", pa.enableMCPCondsForward, "enable MCP Status Condition forwarding")
flag.StringVar(&pa.image.Exporter, "image-exporter", pa.image.Exporter, "use this image as default for the RTE")
flag.StringVar(&pa.image.Scheduler, "image-scheduler", pa.image.Scheduler, "use this image as default for the scheduler")
flag.BoolVar(&pa.enableReplicasDetect, "detect-replicas", pa.enableReplicasDetect, "autodetect optimal replica count")
Expand Down Expand Up @@ -263,7 +261,6 @@ func main() {
Images: imgs,
ImagePullPolicy: pullPolicy,
Namespace: namespace,
ForwardMCPConds: params.enableMCPCondsForward,
}).SetupWithManager(mgr); err != nil {
klog.ErrorS(err, "unable to create controller", "controller", "NUMAResourcesOperator")
os.Exit(1)
Expand Down

0 comments on commit e2e5478

Please sign in to comment.