@@ -33,7 +33,6 @@ import (
33
33
34
34
tunedv1 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/tuned/v1"
35
35
ntoclient "github.com/openshift/cluster-node-tuning-operator/pkg/client"
36
- "github.com/openshift/cluster-node-tuning-operator/pkg/config"
37
36
ntoconfig "github.com/openshift/cluster-node-tuning-operator/pkg/config"
38
37
tunedset "github.com/openshift/cluster-node-tuning-operator/pkg/generated/clientset/versioned"
39
38
tunedinformers "github.com/openshift/cluster-node-tuning-operator/pkg/generated/informers/externalversions"
@@ -383,7 +382,7 @@ func (c *Controller) sync(key wqKey) error {
383
382
384
383
// In HyperShift clusters, any Tuned changes should be overwritten by the tuned config
385
384
// in the management cluster
386
- if config .InHyperShift () {
385
+ if ntoconfig .InHyperShift () {
387
386
err = c .syncHostedClusterTuneds ()
388
387
if err != nil {
389
388
return fmt .Errorf ("failed to sync hosted cluster Tuneds: %v" , err )
@@ -534,7 +533,7 @@ func (c *Controller) syncDaemonSet(tuned *tunedv1.Tuned) error {
534
533
var update bool
535
534
536
535
dsMf := ntomf .TunedDaemonSet ()
537
- dsMf .ObjectMeta . OwnerReferences = getDefaultTunedRefs (tuned )
536
+ dsMf .OwnerReferences = getDefaultTunedRefs (tuned )
538
537
539
538
ds , err := c .listers .DaemonSets .Get (dsMf .Name )
540
539
if err != nil {
@@ -588,7 +587,7 @@ func (c *Controller) syncDaemonSet(tuned *tunedv1.Tuned) error {
588
587
589
588
func (c * Controller ) syncProfile (tuned * tunedv1.Tuned , nodeName string ) error {
590
589
profileMf := ntomf .TunedProfile ()
591
- profileMf .ObjectMeta . OwnerReferences = getDefaultTunedRefs (tuned )
590
+ profileMf .OwnerReferences = getDefaultTunedRefs (tuned )
592
591
593
592
profileMf .Name = nodeName
594
593
delete (c .bootcmdlineConflict , nodeName )
@@ -795,7 +794,7 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
795
794
796
795
if ok := c .allNodesAgreeOnBootcmdline (nodes ); ! ok {
797
796
// 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 )
799
798
return nil
800
799
}
801
800
@@ -816,9 +815,9 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
816
815
mc = NewMachineConfig (name , annotations , labels , kernelArguments )
817
816
_ , err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Create (context .TODO (), mc , metav1.CreateOptions {})
818
817
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 )
820
819
}
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 ))
822
821
return nil
823
822
}
824
823
return err
@@ -829,22 +828,22 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv
829
828
kernelArgsEq := util .StringSlicesEqual (mc .Spec .KernelArguments , kernelArguments )
830
829
if kernelArgsEq {
831
830
// 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 )
833
832
return nil
834
833
}
835
834
mc = mc .DeepCopy () // never update the objects from cache
836
- mc .ObjectMeta . Annotations = mcNew . ObjectMeta .Annotations
835
+ mc .Annotations = mcNew .Annotations
837
836
mc .Spec .KernelArguments = kernelArguments
838
837
mc .Spec .Config = mcNew .Spec .Config
839
838
840
839
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 )
842
841
_ , err = c .clients .MC .MachineconfigurationV1 ().MachineConfigs ().Update (context .TODO (), mc , metav1.UpdateOptions {})
843
842
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 )
845
844
}
846
845
847
- klog .Infof ("updated MachineConfig %s with%s" , mc .ObjectMeta . Name , l )
846
+ klog .Infof ("updated MachineConfig %s with%s" , mc .Name , l )
848
847
849
848
return nil
850
849
}
@@ -857,11 +856,11 @@ func (c *Controller) allNodesAgreeOnBootcmdline(nodes []*corev1.Node) bool {
857
856
}
858
857
859
858
match := true
860
- bootcmdline := c .pc .state .bootcmdline [nodes [0 ].ObjectMeta . Name ]
859
+ bootcmdline := c .pc .state .bootcmdline [nodes [0 ].Name ]
861
860
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
865
864
match = false
866
865
}
867
866
}
@@ -906,14 +905,14 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
906
905
// put the MC into a ConfigMap and create that instead
907
906
mcConfigMap , err = c .newConfigMapForMachineConfig (configMapName , nodePoolName , mc )
908
907
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 )
910
909
return nil
911
910
}
912
911
_ , err = c .clients .ManagementKube .CoreV1 ().ConfigMaps (ntoconfig .OperatorNamespace ()).Create (context .TODO (), mcConfigMap , metav1.CreateOptions {})
913
912
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 )
915
914
}
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 ))
917
916
return nil
918
917
}
919
918
return err
@@ -942,18 +941,18 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
942
941
// If mcfgs are equivalent don't update
943
942
if kernelArgsEq && cmLabelsAndAnnotationsCorrect {
944
943
// 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 )
946
945
return nil
947
946
}
948
947
949
948
// If mcfgs are not equivalent do update
950
949
mc = mc .DeepCopy () // never update the objects from cache
951
- mc .ObjectMeta . Annotations = mcNew . ObjectMeta .Annotations
950
+ mc .Annotations = mcNew .Annotations
952
951
mc .Spec .KernelArguments = kernelArguments
953
952
mc .Spec .Config = mcNew .Spec .Config
954
953
955
954
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 )
957
956
958
957
newData , err := c .serializeMachineConfig (mc )
959
958
if err != nil {
@@ -973,7 +972,7 @@ func (c *Controller) syncMachineConfigHyperShift(nodePoolName string, profile *t
973
972
return fmt .Errorf ("failed to update ConfigMap for MachineConfig %s: %v" , mcConfigMap .Name , err )
974
973
}
975
974
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 )
977
976
978
977
return nil
979
978
}
@@ -991,25 +990,25 @@ func (c *Controller) pruneMachineConfigs() error {
991
990
}
992
991
993
992
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 {
996
995
continue
997
996
}
998
997
// mc's annotations have the controller/operator key
999
998
1000
- if mcNames [mc .ObjectMeta . Name ] {
999
+ if mcNames [mc .Name ] {
1001
1000
continue
1002
1001
}
1003
1002
// This MachineConfig has this operator's annotations and it is not currently used by any
1004
1003
// Tuned CR; remove it and let MCO roll-back any changes
1005
1004
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 {})
1008
1007
if err != nil {
1009
1008
// Unable to delete the MachineConfig
1010
1009
return err
1011
1010
}
1012
- klog .Infof ("deleted MachineConfig %s" , mc .ObjectMeta . Name )
1011
+ klog .Infof ("deleted MachineConfig %s" , mc .Name )
1013
1012
}
1014
1013
}
1015
1014
@@ -1032,24 +1031,24 @@ func (c *Controller) pruneMachineConfigsHyperShift() error {
1032
1031
}
1033
1032
1034
1033
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 {
1037
1036
continue
1038
1037
}
1039
1038
// mc's annotations have the controller/operator key
1040
- if mcNames [cm .ObjectMeta . Name ] {
1039
+ if mcNames [cm .Name ] {
1041
1040
continue
1042
1041
}
1043
1042
1044
1043
// This ConfigMap has this operator's annotations and it is not currently used by any
1045
1044
// 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 {})
1048
1047
if err != nil {
1049
1048
// Unable to delete the ConfigMap
1050
1049
return err
1051
1050
}
1052
- klog .Infof ("deleted MachineConfig ConfigMap %s" , cm .ObjectMeta . Name )
1051
+ klog .Infof ("deleted MachineConfig ConfigMap %s" , cm .Name )
1053
1052
}
1054
1053
}
1055
1054
0 commit comments