Skip to content

Commit

Permalink
Use value rather than reference (#261)
Browse files Browse the repository at this point in the history
Use factory.jobConfig value rather than reference before setting NamespaceLabels to nil.
Also removing the "name" label from the created namespaces, I don't recall why is there, but it's not used anywhere.

Signed-off-by: Raul Sevilla <rsevilla@redhat.com>
  • Loading branch information
rsevilla87 committed Mar 1, 2023
1 parent 9ee4980 commit 92a429b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pkg/burner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (ex *Executor) RunCreateJob(iterationStart, iterationEnd int) {
}
if ex.nsObjects && !ex.Config.NamespacedIterations {
ns = ex.Config.Namespace
nsLabels["name"] = ns
if err = createNamespace(ClientSet, ns, nsLabels); err != nil {
log.Fatal(err.Error())
}
Expand All @@ -118,7 +117,6 @@ func (ex *Executor) RunCreateJob(iterationStart, iterationEnd int) {
log.Debugf("Creating object replicas from iteration %d", i)
if ex.nsObjects && ex.Config.NamespacedIterations {
ns = fmt.Sprintf("%s-%d", ex.Config.Namespace, i)
nsLabels["name"] = ns
if err = createNamespace(ClientSet, fmt.Sprintf("%s-%d", ex.Config.Namespace, i), nsLabels); err != nil {
log.Error(err.Error())
continue
Expand Down
1 change: 1 addition & 0 deletions pkg/burner/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func createNamespace(clientset *kubernetes.Clientset, namespaceName string, nsLa
ns := v1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: namespaceName, Labels: nsLabels},
}

return RetryWithExponentialBackOff(func() (done bool, err error) {
_, err = clientset.CoreV1().Namespaces().Create(context.TODO(), &ns, metav1.CreateOptions{})
if errors.IsForbidden(err) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/measurements/pod_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func init() {
func (p *podLatency) handleCreatePod(obj interface{}) {
now := time.Now().UTC()
pod := obj.(*v1.Pod)
jobConfig := factory.jobConfig
jobConfig.NamespaceLabels = nil // metric doesn't need this data
jobConfig := *factory.jobConfig
jobConfig.NamespaceLabels = nil // metric doesn't need this data
jobConfig.Objects = nil // metric doesn't need this data
if _, exists := p.metrics[string(pod.UID)]; !exists {
if strings.Contains(pod.Namespace, factory.jobConfig.Namespace) {
Expand All @@ -82,7 +82,7 @@ func (p *podLatency) handleCreatePod(obj interface{}) {
Name: pod.Name,
MetricName: podLatencyMeasurement,
UUID: factory.uuid,
JobConfig: *jobConfig,
JobConfig: jobConfig,
JobName: factory.jobConfig.Name,
Metadata: factory.metadata,
}
Expand Down

0 comments on commit 92a429b

Please sign in to comment.