Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't inject must-gather fields directly into job yaml #138

Merged

Conversation

AlexVulaj
Copy link
Contributor

This change prevents values from the MustGather resource from bleeding into other fields from the Job template.

Resolves OSD-21667

@openshift-ci openshift-ci bot requested review from bng0y and dustman9000 June 3, 2024 18:48
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 3, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 132 lines in your changes missing coverage. Please review.

Project coverage is 7.83%. Comparing base (b7816d7) to head (4997ad9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #138      +/-   ##
=========================================
- Coverage   10.67%   7.83%   -2.85%     
=========================================
  Files           4       5       +1     
  Lines         281     383     +102     
=========================================
  Hits           30      30              
- Misses        248     350     +102     
  Partials        3       3              
Files Coverage Δ
controllers/mustgather/mustgather_controller.go 14.14% <0.00%> (+1.47%) ⬆️
controllers/mustgather/template.go 0.00% <0.00%> (ø)

Copy link
Contributor

@mjlshen mjlshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't notice any bugs, just feedback. Feel free to reach out to other reviewers for other opinions too

return job, nil
}

func processJobTemplate(jobTemplate string, instance *mustgatherv1alpha1.MustGather) (*batchv1.Job, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the jobTemplate YAML for anything? Should we just default values in the struct itself?

job := &batchv1.Job{
  ObjectMeta: metav1.ObjectMeta{
    Name:      instance.ObjectMeta.Name,
    Namespace: instance.ObjectMeta.Namespace,
  },
  Spec: {
    // The rest of the default/non-default values
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fully on board with this approach, but it's more work. Long term I think it's better and am more than happy to go through with this.

gatherCommandBinary = gatherCommandBinaryNoAudit
}

job.Spec.Template.Spec.Containers[0].Command = append(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context to the earlier comment, I'm mostly concerned about the brittleness of these array indices if someone comes in and changes the template in some way. My concerns could also be addressed with unit tests that would fail if someone mucked with the jobTemplate's containers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 this comment fully convinces me we should address this now. There's no guarantee of order in the unmarshalling.

@AlexVulaj
Copy link
Contributor Author

/label tide/merge-method-squash

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jun 4, 2024
Copy link
Contributor

@mjlshen mjlshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2024
@mjlshen
Copy link
Contributor

mjlshen commented Jun 4, 2024

/lgtm cancel

build/Dockerfile Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also need to take out this line

COPY --from=builder /src/build/templates /etc/templates

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2024
@AlexVulaj AlexVulaj force-pushed the no-direct-user-input branch from 2549aeb to 4997ad9 Compare June 4, 2024 17:17
Copy link
Contributor

openshift-ci bot commented Jun 4, 2024

@AlexVulaj: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@mjlshen
Copy link
Contributor

mjlshen commented Jun 4, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2024
Copy link
Contributor

openshift-ci bot commented Jun 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexVulaj, mjlshen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants