@@ -140,12 +140,12 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
140140 // add script files under the node /usr/local/bin directory
141141 mode := 0700
142142 for _ , script := range []string {hugepagesAllocation , ociHooks , setRPSMask } {
143- dst := getBashScriptPath (script )
143+ dst := GetBashScriptPath (script )
144144 content , err := assets .Scripts .ReadFile (fmt .Sprintf ("scripts/%s.sh" , script ))
145145 if err != nil {
146146 return nil , err
147147 }
148- addContent (ignitionConfig , content , dst , & mode )
148+ AddContent (ignitionConfig , content , dst , & mode )
149149 }
150150
151151 // add crio config snippet under the node /etc/crio/crio.conf.d/ directory
@@ -155,7 +155,7 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
155155 return nil , err
156156 }
157157 crioConfSnippetDst := filepath .Join (crioConfd , crioRuntimesConfig )
158- addContent (ignitionConfig , crioConfigSnippetContent , crioConfSnippetDst , & crioConfdRuntimesMode )
158+ AddContent (ignitionConfig , crioConfigSnippetContent , crioConfSnippetDst , & crioConfdRuntimesMode )
159159
160160 // add crio hooks config under the node cri-o hook directory
161161 crioHooksConfigsMode := 0644
@@ -164,7 +164,7 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
164164 return nil , err
165165 }
166166 ociHookConfigDst := filepath .Join (OCIHooksConfigDir , OCIHooksConfig )
167- addContent (ignitionConfig , ociHooksConfigContent , ociHookConfigDst , & crioHooksConfigsMode )
167+ AddContent (ignitionConfig , ociHooksConfigContent , ociHookConfigDst , & crioHooksConfigsMode )
168168
169169 // add rps udev rule
170170 rpsRulesMode := 0644
@@ -173,7 +173,7 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
173173 return nil , err
174174 }
175175 rpsRulesDst := filepath .Join (udevRulesDir , udevRpsRules )
176- addContent (ignitionConfig , rpsRulesContent , rpsRulesDst , & rpsRulesMode )
176+ AddContent (ignitionConfig , rpsRulesContent , rpsRulesDst , & rpsRulesMode )
177177
178178 if profile .Spec .HugePages != nil {
179179 for _ , page := range profile .Spec .HugePages .Pages {
@@ -187,7 +187,7 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
187187 return nil , err
188188 }
189189
190- hugepagesService , err := getSystemdContent ( getHugepagesAllocationUnitOptions (
190+ hugepagesService , err := GetSystemdContent ( GetHugepagesAllocationUnitOptions (
191191 hugepagesSize ,
192192 page .Count ,
193193 * page .Node ,
@@ -199,7 +199,7 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
199199 ignitionConfig .Systemd .Units = append (ignitionConfig .Systemd .Units , igntypes.Unit {
200200 Contents : & hugepagesService ,
201201 Enabled : pointer .BoolPtr (true ),
202- Name : getSystemdService (fmt .Sprintf ("%s-%skB-NUMA%d" , hugepagesAllocation , hugepagesSize , * page .Node )),
202+ Name : GetSystemdService (fmt .Sprintf ("%s-%skB-NUMA%d" , hugepagesAllocation , hugepagesSize , * page .Node )),
203203 })
204204 }
205205 }
@@ -210,33 +210,36 @@ func getIgnitionConfig(profile *performancev2.PerformanceProfile) (*igntypes.Con
210210 return nil , err
211211 }
212212
213- rpsService , err := getSystemdContent (getRPSUnitOptions (rpsMask ))
213+ rpsService , err := GetSystemdContent (getRPSUnitOptions (rpsMask ))
214214 if err != nil {
215215 return nil , err
216216 }
217217
218218 ignitionConfig .Systemd .Units = append (ignitionConfig .Systemd .Units , igntypes.Unit {
219219 Contents : & rpsService ,
220- Name : getSystemdService ("update-rps@" ),
220+ Name : GetSystemdService ("update-rps@" ),
221221 })
222222 }
223223
224224 return ignitionConfig , nil
225225}
226226
227- func getBashScriptPath (scriptName string ) string {
227+ //GetBashScriptPath returns the script path containing teh directory and the script name
228+ func GetBashScriptPath (scriptName string ) string {
228229 return fmt .Sprintf ("%s/%s.sh" , bashScriptsDir , scriptName )
229230}
230231
231232func getSystemdEnvironment (key string , value string ) string {
232233 return fmt .Sprintf ("%s=%s" , key , value )
233234}
234235
235- func getSystemdService (serviceName string ) string {
236+ //GetSystemdService returns the service name in systemd
237+ func GetSystemdService (serviceName string ) string {
236238 return fmt .Sprintf ("%s.service" , serviceName )
237239}
238240
239- func getSystemdContent (options []* unit.UnitOption ) (string , error ) {
241+ //GetSystemdContent get systemd content from list of unit options
242+ func GetSystemdContent (options []* unit.UnitOption ) (string , error ) {
240243 outReader := unit .Serialize (options )
241244 outBytes , err := ioutil .ReadAll (outReader )
242245 if err != nil {
@@ -281,7 +284,8 @@ func GetHugepagesSizeKilobytes(hugepagesSize performancev2.HugePageSize) (string
281284 }
282285}
283286
284- func getHugepagesAllocationUnitOptions (hugepagesSize string , hugepagesCount int32 , numaNode int32 ) []* unit.UnitOption {
287+ //GetHugepagesAllocationUnitOptions returns list of unit options based on the settings of the hugepage
288+ func GetHugepagesAllocationUnitOptions (hugepagesSize string , hugepagesCount int32 , numaNode int32 ) []* unit.UnitOption {
285289 return []* unit.UnitOption {
286290 // [Unit]
287291 // Description
@@ -298,15 +302,15 @@ func getHugepagesAllocationUnitOptions(hugepagesSize string, hugepagesCount int3
298302 // RemainAfterExit
299303 unit .NewUnitOption (systemdSectionService , systemdRemainAfterExit , systemdTrue ),
300304 // ExecStart
301- unit .NewUnitOption (systemdSectionService , systemdExecStart , getBashScriptPath (hugepagesAllocation )),
305+ unit .NewUnitOption (systemdSectionService , systemdExecStart , GetBashScriptPath (hugepagesAllocation )),
302306 // [Install]
303307 // WantedBy
304308 unit .NewUnitOption (systemdSectionInstall , systemdWantedBy , systemdTargetMultiUser ),
305309 }
306310}
307311
308312func getRPSUnitOptions (rpsMask string ) []* unit.UnitOption {
309- cmd := fmt .Sprintf ("%s %%i %s" , getBashScriptPath (setRPSMask ), rpsMask )
313+ cmd := fmt .Sprintf ("%s %%i %s" , GetBashScriptPath (setRPSMask ), rpsMask )
310314 return []* unit.UnitOption {
311315 // [Unit]
312316 // Description
@@ -319,7 +323,8 @@ func getRPSUnitOptions(rpsMask string) []*unit.UnitOption {
319323 }
320324}
321325
322- func addContent (ignitionConfig * igntypes.Config , content []byte , dst string , mode * int ) {
326+ //AddContent appends more content to the ignition configuration
327+ func AddContent (ignitionConfig * igntypes.Config , content []byte , dst string , mode * int ) {
323328 contentBase64 := base64 .StdEncoding .EncodeToString (content )
324329 ignitionConfig .Storage .Files = append (ignitionConfig .Storage .Files , igntypes.File {
325330 Node : igntypes.Node {
0 commit comments