@@ -33,7 +33,6 @@ import (
3333
3434 tunedv1 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/tuned/v1"
3535 ntoclient "github.com/openshift/cluster-node-tuning-operator/pkg/client"
36- "github.com/openshift/cluster-node-tuning-operator/pkg/config"
3736 ntoconfig "github.com/openshift/cluster-node-tuning-operator/pkg/config"
3837 tunedset "github.com/openshift/cluster-node-tuning-operator/pkg/generated/clientset/versioned"
3938 tunedinformers "github.com/openshift/cluster-node-tuning-operator/pkg/generated/informers/externalversions"
@@ -383,7 +382,7 @@ func (c *Controller) sync(key wqKey) error {
383382
384383 // In HyperShift clusters, any Tuned changes should be overwritten by the tuned config
385384 // in the management cluster
386- if config .InHyperShift () {
385+ if ntoconfig .InHyperShift () {
387386 err = c .syncHostedClusterTuneds ()
388387 if err != nil {
389388 return fmt .Errorf ("failed to sync hosted cluster Tuneds: %v" , err )
@@ -534,7 +533,7 @@ func (c *Controller) syncDaemonSet(tuned *tunedv1.Tuned) error {
534533 var update bool
535534
536535 dsMf := ntomf .TunedDaemonSet ()
537- dsMf .ObjectMeta . OwnerReferences = getDefaultTunedRefs (tuned )
536+ dsMf .OwnerReferences = getDefaultTunedRefs (tuned )
538537
539538 ds , err := c .listers .DaemonSets .Get (dsMf .Name )
540539 if err != nil {
@@ -588,7 +587,7 @@ func (c *Controller) syncDaemonSet(tuned *tunedv1.Tuned) error {
588587
589588func (c * Controller ) syncProfile (tuned * tunedv1.Tuned , nodeName string ) error {
590589 profileMf := ntomf .TunedProfile ()
591- profileMf .ObjectMeta . OwnerReferences = getDefaultTunedRefs (tuned )
590+ profileMf .OwnerReferences = getDefaultTunedRefs (tuned )
592591
593592 profileMf .Name = nodeName
594593 delete (c .bootcmdlineConflict , nodeName )
@@ -795,7 +794,7 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
795794
796795 if ok := c .allNodesAgreeOnBootcmdline (nodes ); ! ok {
797796 // Log an error and do not requeue, this is a configuration issue.
798- klog .Errorf ("not all %d Nodes in MCP %v agree on bootcmdline: %s" , len (nodes ), pools [0 ].ObjectMeta . Name , bootcmdline )
797+ klog .Errorf ("not all %d Nodes in MCP %v agree on bootcmdline: %s" , len (nodes ), pools [0 ].Name , bootcmdline )
799798 return nil
800799 }
801800
@@ -816,9 +815,9 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
816815 mc = NewMachineConfig (name , annotations , labels , kernelArguments )
817816 _ , err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Create (context .TODO (), mc , metav1.CreateOptions {})
818817 if err != nil {
819- return fmt .Errorf ("failed to create MachineConfig %s: %v" , mc .ObjectMeta . Name , err )
818+ return fmt .Errorf ("failed to create MachineConfig %s: %v" , mc .Name , err )
820819 }
821- klog .Infof ("created MachineConfig %s with%s" , mc .ObjectMeta . Name , MachineConfigGenerationLogLine (len (bootcmdline ) != 0 , bootcmdline ))
820+ klog .Infof ("created MachineConfig %s with%s" , mc .Name , MachineConfigGenerationLogLine (len (bootcmdline ) != 0 , bootcmdline ))
822821 return nil
823822 }
824823 return err
@@ -829,22 +828,22 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
829828 kernelArgsEq := util .StringSlicesEqual (mc .Spec .KernelArguments , kernelArguments )
830829 if kernelArgsEq {
831830 // No update needed
832- klog .V (2 ).Infof ("syncMachineConfig(): MachineConfig %s doesn't need updating" , mc .ObjectMeta . Name )
831+ klog .V (2 ).Infof ("syncMachineConfig(): MachineConfig %s doesn't need updating" , mc .Name )
833832 return nil
834833 }
835834 mc = mc .DeepCopy () // never update the objects from cache
836- mc .ObjectMeta . Annotations = mcNew . ObjectMeta .Annotations
835+ mc .Annotations = mcNew .Annotations
837836 mc .Spec .KernelArguments = kernelArguments
838837 mc .Spec .Config = mcNew .Spec .Config
839838
840839 l := MachineConfigGenerationLogLine (! kernelArgsEq , bootcmdline )
841- klog .V (2 ).Infof ("syncMachineConfig(): updating MachineConfig %s with%s" , mc .ObjectMeta . Name , l )
840+ klog .V (2 ).Infof ("syncMachineConfig(): updating MachineConfig %s with%s" , mc .Name , l )
842841 _ , err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Update (context .TODO (), mc , metav1.UpdateOptions {})
843842 if err != nil {
844- return fmt .Errorf ("failed to update MachineConfig %s: %v" , mc .ObjectMeta . Name , err )
843+ return fmt .Errorf ("failed to update MachineConfig %s: %v" , mc .Name , err )
845844 }
846845
847- klog .Infof ("updated MachineConfig %s with%s" , mc .ObjectMeta . Name , l )
846+ klog .Infof ("updated MachineConfig %s with%s" , mc .Name , l )
848847
849848 return nil
850849}
@@ -857,11 +856,11 @@ func (c *Controller) allNodesAgreeOnBootcmdline(nodes []*corev1.Node) bool {
857856 }
858857
859858 match := true
860- bootcmdline := c .pc .state .bootcmdline [nodes [0 ].ObjectMeta . Name ]
859+ bootcmdline := c .pc .state .bootcmdline [nodes [0 ].Name ]
861860 for _ , node := range nodes [1 :] {
862- if bootcmdline != c .pc .state .bootcmdline [node .ObjectMeta . Name ] {
863- klog .V (2 ).Infof ("found a conflicting bootcmdline %q for Node %q" , c .pc .state .bootcmdline [node .ObjectMeta . Name ], node . ObjectMeta .Name )
864- c .bootcmdlineConflict [node .ObjectMeta . Name ] = true
861+ if bootcmdline != c .pc .state .bootcmdline [node .Name ] {
862+ klog .V (2 ).Infof ("found a conflicting bootcmdline %q for Node %q" , c .pc .state .bootcmdline [node .Name ], node .Name )
863+ c .bootcmdlineConflict [node .Name ] = true
865864 match = false
866865 }
867866 }
@@ -906,14 +905,14 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
906905 // put the MC into a ConfigMap and create that instead
907906 mcConfigMap , err = c .newConfigMapForMachineConfig (configMapName , nodePoolName , mc )
908907 if err != nil {
909- klog .Errorf ("failed to generate ConfigMap %s for MachineConfig %s: %v" , configMapName , mc .ObjectMeta . Name , err )
908+ klog .Errorf ("failed to generate ConfigMap %s for MachineConfig %s: %v" , configMapName , mc .Name , err )
910909 return nil
911910 }
912911 _ , err = c .clients .ManagementKube .CoreV1 ().ConfigMaps (ntoconfig .OperatorNamespace ()).Create (context .TODO (), mcConfigMap , metav1.CreateOptions {})
913912 if err != nil {
914- return fmt .Errorf ("failed to create ConfigMap %s for MachineConfig %s: %v" , configMapName , mc .ObjectMeta . Name , err )
913+ return fmt .Errorf ("failed to create ConfigMap %s for MachineConfig %s: %v" , configMapName , mc .Name , err )
915914 }
916- klog .Infof ("created ConfigMap %s for MachineConfig %s with%s" , configMapName , mc .ObjectMeta . Name , MachineConfigGenerationLogLine (len (bootcmdline ) != 0 , bootcmdline ))
915+ klog .Infof ("created ConfigMap %s for MachineConfig %s with%s" , configMapName , mc .Name , MachineConfigGenerationLogLine (len (bootcmdline ) != 0 , bootcmdline ))
917916 return nil
918917 }
919918 return err
@@ -942,18 +941,18 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
942941 // If mcfgs are equivalent don't update
943942 if kernelArgsEq && cmLabelsAndAnnotationsCorrect {
944943 // No update needed
945- klog .V (2 ).Infof ("syncMachineConfigHyperShift(): MachineConfig %s doesn't need updating" , mc .ObjectMeta . Name )
944+ klog .V (2 ).Infof ("syncMachineConfigHyperShift(): MachineConfig %s doesn't need updating" , mc .Name )
946945 return nil
947946 }
948947
949948 // If mcfgs are not equivalent do update
950949 mc = mc .DeepCopy () // never update the objects from cache
951- mc .ObjectMeta . Annotations = mcNew . ObjectMeta .Annotations
950+ mc .Annotations = mcNew .Annotations
952951 mc .Spec .KernelArguments = kernelArguments
953952 mc .Spec .Config = mcNew .Spec .Config
954953
955954 l := MachineConfigGenerationLogLine (! kernelArgsEq , bootcmdline )
956- klog .V (2 ).Infof ("syncMachineConfigHyperShift(): updating MachineConfig %s with%s" , mc .ObjectMeta . Name , l )
955+ klog .V (2 ).Infof ("syncMachineConfigHyperShift(): updating MachineConfig %s with%s" , mc .Name , l )
957956
958957 newData , err := c .serializeMachineConfig (mc )
959958 if err != nil {
@@ -973,7 +972,7 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
973972 return fmt .Errorf ("failed to update ConfigMap for MachineConfig %s: %v" , mcConfigMap .Name , err )
974973 }
975974
976- klog .Infof ("updated ConfigMap %s for MachineConfig %s with%s" , mcConfigMap .Name , mc .ObjectMeta . Name , l )
975+ klog .Infof ("updated ConfigMap %s for MachineConfig %s with%s" , mcConfigMap .Name , mc .Name , l )
977976
978977 return nil
979978}
@@ -991,25 +990,25 @@ func (c *Controller) pruneMachineConfigs() error {
991990 }
992991
993992 for _ , mc := range mcList {
994- if mc .ObjectMeta . Annotations != nil {
995- if _ , ok := mc .ObjectMeta . Annotations [GeneratedByControllerVersionAnnotationKey ]; ! ok {
993+ if mc .Annotations != nil {
994+ if _ , ok := mc .Annotations [GeneratedByControllerVersionAnnotationKey ]; ! ok {
996995 continue
997996 }
998997 // mc's annotations have the controller/operator key
999998
1000- if mcNames [mc .ObjectMeta . Name ] {
999+ if mcNames [mc .Name ] {
10011000 continue
10021001 }
10031002 // This MachineConfig has this operator's annotations and it is not currently used by any
10041003 // Tuned CR; remove it and let MCO roll-back any changes
10051004
1006- klog .V (2 ).Infof ("pruneMachineConfigs(): deleting MachineConfig %s" , mc .ObjectMeta . Name )
1007- err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Delete (context .TODO (), mc .ObjectMeta . Name , metav1.DeleteOptions {})
1005+ klog .V (2 ).Infof ("pruneMachineConfigs(): deleting MachineConfig %s" , mc .Name )
1006+ err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Delete (context .TODO (), mc .Name , metav1.DeleteOptions {})
10081007 if err != nil {
10091008 // Unable to delete the MachineConfig
10101009 return err
10111010 }
1012- klog .Infof ("deleted MachineConfig %s" , mc .ObjectMeta . Name )
1011+ klog .Infof ("deleted MachineConfig %s" , mc .Name )
10131012 }
10141013 }
10151014
@@ -1032,24 +1031,24 @@ func (c *Controller) pruneMachineConfigsHyperShift() error {
10321031 }
10331032
10341033 for _ , cm := range cmList .Items {
1035- if cm .ObjectMeta . Annotations != nil {
1036- if _ , ok := cm .ObjectMeta . Annotations [GeneratedByControllerVersionAnnotationKey ]; ! ok {
1034+ if cm .Annotations != nil {
1035+ if _ , ok := cm .Annotations [GeneratedByControllerVersionAnnotationKey ]; ! ok {
10371036 continue
10381037 }
10391038 // mc's annotations have the controller/operator key
1040- if mcNames [cm .ObjectMeta . Name ] {
1039+ if mcNames [cm .Name ] {
10411040 continue
10421041 }
10431042
10441043 // This ConfigMap has this operator's annotations and it is not currently used by any
10451044 // Tuned CR; remove it and let MCO roll-back any changes
1046- klog .V (2 ).Infof ("pruneMachineConfigsHyperShift(): deleting ConfigMap %s" , cm .ObjectMeta . Name )
1047- err = c .clients .ManagementKube .CoreV1 ().ConfigMaps (ntoconfig .OperatorNamespace ()).Delete (context .TODO (), cm .ObjectMeta . Name , metav1.DeleteOptions {})
1045+ klog .V (2 ).Infof ("pruneMachineConfigsHyperShift(): deleting ConfigMap %s" , cm .Name )
1046+ err = c .clients .ManagementKube .CoreV1 ().ConfigMaps (ntoconfig .OperatorNamespace ()).Delete (context .TODO (), cm .Name , metav1.DeleteOptions {})
10481047 if err != nil {
10491048 // Unable to delete the ConfigMap
10501049 return err
10511050 }
1052- klog .Infof ("deleted MachineConfig ConfigMap %s" , cm .ObjectMeta . Name )
1051+ klog .Infof ("deleted MachineConfig ConfigMap %s" , cm .Name )
10531052 }
10541053 }
10551054
0 commit comments