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

Fix potential nil pointer dereference in reconcile loop #1138

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

amisevsk
Copy link
Collaborator

What does this PR do?

Fix potential for a panic due to nil pointer dereference if the workspace ServiceAccount does not exist.

What issues does this PR fix or reference?

Closes #1137

Is it tested? How?

  1. Disable Service Account creation
  2. Attempt to start a workspace (workspace expected to fail to start)

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

Fix potential for a panic due to nil pointer dereference if the
workspace ServiceAccount does not exist.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Copy link
Collaborator

@AObuchow AObuchow left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

Was able to reproduce the original bug on the main branch and verified that this PR fixes it.

Setting Config.Workspace.ServiceAccount.DisableCreation = true and Config.Workspace.ServiceAccount.DisableCreation = "test" now results in the workspace safely failing, as expected:


NAME                 DEVWORKSPACE ID             PHASE    INFO
plain-devworkspace   workspacefbc5a709fd0e4913   Failed   Error creating DevWorkspace deployment: Detected unrecoverable deployment condition: FailedCreate pods "workspacefbc5a709fd0e4913-b8dd747df-" is forbidden: error looking up service account devworkspace-controller/test: serviceaccount "test" not found

@openshift-ci
Copy link

openshift-ci bot commented Jun 29, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, AObuchow, l0rd

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

@amisevsk
Copy link
Collaborator Author

/retest

@amisevsk amisevsk mentioned this pull request Jun 29, 2023
3 tasks
@amisevsk
Copy link
Collaborator Author

/retest

1 similar comment
@amisevsk
Copy link
Collaborator Author

/retest

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage: 80.00% and project coverage change: -0.01 ⚠️

Comparison is base (b4fc4ea) 52.42% compared to head (a24cb21) 52.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1138      +/-   ##
==========================================
- Coverage   52.42%   52.41%   -0.01%     
==========================================
  Files          81       81              
  Lines        7380     7381       +1     
==========================================
  Hits         3869     3869              
- Misses       3231     3232       +1     
  Partials      280      280              
Impacted Files Coverage Δ
pkg/provision/workspace/pull_secret.go 0.00% <0.00%> (ø)
controllers/workspace/devworkspace_controller.go 62.65% <100.00%> (+0.07%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@amisevsk amisevsk merged commit 559bb39 into devfile:main Jun 30, 2023
5 of 6 checks passed
@amisevsk amisevsk deleted the pullsecrets-fixup branch June 30, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential nil pointer dereference in main controller loop
3 participants