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

Bug 1853599: Fixes bug attaching block storage PVC to deployments #6221

Merged
merged 1 commit into from Sep 8, 2020

Conversation

vbnrh
Copy link
Contributor

@vbnrh vbnrh commented Aug 5, 2020

Using block storage provisioners with RWX access mode incorrectly attaches the path as volumeMount in PodSpec instead of volumeDevice. This caused the pods to be in a state of ContainerCreation indefinitely. This commit fixes this by sending the object with the right configuration for block storage.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1853599

Signed-off-by: Vineet Badrinath vbadrina@redhat.com

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Aug 5, 2020
@vbnrh
Copy link
Contributor Author

vbnrh commented Aug 5, 2020

/assign cloudbehl

Copy link
Contributor

@cloudbehl cloudbehl left a comment

Choose a reason for hiding this comment

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

Add bugzilla id to the PR.

frontend/public/components/storage/attach-storage.tsx Outdated Show resolved Hide resolved
frontend/public/components/storage/attach-storage.tsx Outdated Show resolved Hide resolved
frontend/public/components/storage/attach-storage.tsx Outdated Show resolved Hide resolved
frontend/public/components/storage/attach-storage.tsx Outdated Show resolved Hide resolved
@vbnrh vbnrh changed the title Fixes bug attaching block storage to pods, deployments Bug 1853599 : Fixes bug attaching block storage PVC to deployments Aug 10, 2020
@vbnrh vbnrh changed the title Bug 1853599 : Fixes bug attaching block storage PVC to deployments Bug 1853599: Fixes bug attaching block storage PVC to deployments Aug 10, 2020
@openshift-ci-robot
Copy link
Contributor

@vbnrh: An error was encountered adding this pull request to the external tracker bugs for bug 1853599 on the Bugzilla server at https://bugzilla.redhat.com:

JSONRPC error 32000: There was an error reported for a GitHub REST call. URL: https://api.github.com/repos/openshift/console/pulls/6221 Error: 403 Forbidden at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Type/GitHub.pm line 111. at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Type/GitHub.pm line 111. eval {...} called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Type/GitHub.pm line 98 Bugzilla::Extension::ExternalBugs::Type::GitHub::_do_rest_call('Bugzilla::Extension::ExternalBugs::Type::GitHub=HASH(0x56253e...', 'https://api.github.com/repos/openshift/console/pulls/6221', 'GET') called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Type/GitHub.pm line 62 Bugzilla::Extension::ExternalBugs::Type::GitHub::get_data('Bugzilla::Extension::ExternalBugs::Type::GitHub=HASH(0x56253e...', 'Bugzilla::Extension::ExternalBugs::Bug=HASH(0x56253b89c840)') called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Bug.pm line 302 eval {...} called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Bug.pm line 302 Bugzilla::Extension::ExternalBugs::Bug::update_ext_info('Bugzilla::Extension::ExternalBugs::Bug=HASH(0x56253b89c840)', 1) called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/Bug.pm line 125 Bugzilla::Extension::ExternalBugs::Bug::create('Bugzilla::Extension::ExternalBugs::Bug', 'HASH(0x56253cf820b8)') called at /var/www/html/bugzilla/extensions/ExternalBugs/Extension.pm line 877 Bugzilla::Extension::ExternalBugs::bug_start_of_update('Bugzilla::Extension::ExternalBugs=HASH(0x56253ca872b8)', 'HASH(0x562542172088)') called at /var/www/html/bugzilla/Bugzilla/Hook.pm line 21 Bugzilla::Hook::process('bug_start_of_update', 'HASH(0x562542172088)') called at /var/www/html/bugzilla/Bugzilla/Bug.pm line 1170 Bugzilla::Bug::update('Bugzilla::Bug=HASH(0x56253ca39e48)') called at /loader/0x562531de83b0/Bugzilla/Extension/ExternalBugs/WebService.pm line 88 Bugzilla::Extension::ExternalBugs::WebService::add_external_bug('Bugzilla::WebService::Server::JSONRPC::Bugzilla::Extension::E...', 'HASH(0x56253bd801b8)') called at (eval 2601) line 1 eval ' $procedure->{code}->($self, @params) ;' called at /usr/share/perl5/vendor_perl/JSON/RPC/Legacy/Server.pm line 220 JSON::RPC::Legacy::Server::_handle('Bugzilla::WebService::Server::JSONRPC::Bugzilla::Extension::E...', 'HASH(0x562541bf0a08)') called at /var/www/html/bugzilla/Bugzilla/WebService/Server/JSONRPC.pm line 295 Bugzilla::WebService::Server::JSONRPC::_handle('Bugzilla::WebService::Server::JSONRPC::Bugzilla::Extension::E...', 'HASH(0x562541bf0a08)') called at /usr/share/perl5/vendor_perl/JSON/RPC/Legacy/Server.pm line 126 JSON::RPC::Legacy::Server::handle('Bugzilla::WebService::Server::JSONRPC::Bugzilla::Extension::E...') called at /var/www/html/bugzilla/Bugzilla/WebService/Server/JSONRPC.pm line 70 Bugzilla::WebService::Server::JSONRPC::handle('Bugzilla::WebService::Server::JSONRPC::Bugzilla::Extension::E...') called at /var/www/html/bugzilla/jsonrpc.cgi line 31 ModPerl::ROOT::Bugzilla::ModPerl::ResponseHandler::var_www_html_bugzilla_jsonrpc_2ecgi::handler('Apache2::RequestRec=SCALAR(0x56253bb74408)') called at /usr/lib64/perl5/vendor_perl/ModPerl/RegistryCooker.pm line 207 eval {...} called at /usr/lib64/perl5/vendor_perl/ModPerl/RegistryCooker.pm line 207 ModPerl::RegistryCooker::run('Bugzilla::ModPerl::ResponseHandler=HASH(0x56253bf27738)') called at /usr/lib64/perl5/vendor_perl/ModPerl/RegistryCooker.pm line 173 ModPerl::RegistryCooker::default_handler('Bugzilla::ModPerl::ResponseHandler=HASH(0x56253bf27738)') called at /usr/lib64/perl5/vendor_perl/ModPerl/Registry.pm line 32 ModPerl::Registry::handler('Bugzilla::ModPerl::ResponseHandler', 'Apache2::RequestRec=SCALAR(0x56253bb74408)') called at /var/www/html/bugzilla/mod_perl.pl line 139 Bugzilla::ModPerl::ResponseHandler::handler('Bugzilla::ModPerl::ResponseHandler', 'Apache2::RequestRec=SCALAR(0x56253bb74408)') called at (eval 2601) line 0 eval {...} called at (eval 2601) line 0
Please contact an administrator to resolve this issue, then request a bug refresh with /bugzilla refresh.

In response to this:

Bug 1853599: Fixes bug attaching block storage PVC to deployments

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/test-infra repository.

@cloudbehl
Copy link
Contributor

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 10, 2020
@openshift-ci-robot
Copy link
Contributor

@cloudbehl: This pull request references Bugzilla bug 1853599, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

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/test-infra repository.

@vbnrh
Copy link
Contributor Author

vbnrh commented Aug 11, 2020

/assign @spadgett @rhamilto

value={devicePath}
required
/>
<p className="help-block" id="mount-path-help">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<p className="help-block" id="mount-path-help">
<p className="help-block" id="volume-device-help">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

const newVolumeName = volume ? volume.name : newClaimName;
const newVolumeAlreadyMounted = !!volume;
setVolumeName(newVolumeName);
setVolumeAlreadyMounted(newVolumeAlreadyMounted);
}, [newPVCObj, obj, claimName, showCreatePVC]);
showCreatePVC === 'existing' && newClaimName.trim().length > 0
? k8sGet(PersistentVolumeClaimModel, newClaimName, namespace)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we already have all the PVCs since we get them for the dropdown? It would be nice to use the object we already have instead of requesting it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the component only returns the name of the PVC and not the entire PVC object. We may have to change the entire component to return a list of objects for that to be possible.

Copy link
Member

Choose a reason for hiding this comment

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

How hard is it to update the ListDropdown onChange prop to take a 3rd optional argument with the resource? Then we could skip this get, and it could be useful in other contexts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to use obj from listdropdown. thanks for the input.

showCreatePVC === 'existing' && newClaimName.trim().length > 0
? k8sGet(PersistentVolumeClaimModel, newClaimName, namespace)
.then((pvc) => {
setClaimVolumeMode(pvc?.spec?.volumeMode);
Copy link
Member

Choose a reason for hiding this comment

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

The optional chaining here shouldn't be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

.then((pvc) => {
setClaimVolumeMode(pvc?.spec?.volumeMode);
})
.catch((err) => setError(err))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.catch((err) => setError(err))
.catch(setError)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -117,6 +125,27 @@ export const AttachStorageForm: React.FC<AttachStorageFormProps> = (props) => {
validateMountPaths(event.currentTarget.value);
};

const getDevicePaths = (podTemplate: any): string[] => {
const containers: ContainerSpec[] = _.get(podTemplate, 'spec.containers', []);
Copy link
Member

Choose a reason for hiding this comment

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

Use optional chaining instead of _.get

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -117,6 +125,27 @@ export const AttachStorageForm: React.FC<AttachStorageFormProps> = (props) => {
validateMountPaths(event.currentTarget.value);
};

const getDevicePaths = (podTemplate: any): string[] => {
Copy link
Member

Choose a reason for hiding this comment

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

We should have a TypeScript type for pod templates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 141 to 143
const err = existingDevicePaths.includes(path) ? 'Device path is already in use.' : '';
setError(err);
Copy link
Member

Choose a reason for hiding this comment

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

Could this clear a different error that might have been previously set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it will set the last occurred error and display it to the user

Copy link
Member

Choose a reason for hiding this comment

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

But sometimes you call setError with '' as the value. It will clear any previous error in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh.... i got your point now. The changes should be suffice now

return patch;
}, []);
};
const getVolumePatches = (pvClaimName: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const getVolumePatches = (pvClaimName: string) => {
const getVolumePatches = (pvcName: string) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

name: volumeName,
devicePath,
};
const containers: ContainerSpec[] = _.get(obj, 'spec.template.spec.containers', []);
Copy link
Member

Choose a reason for hiding this comment

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

Prefer optional chaining for new code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@vbnrh vbnrh force-pushed the pvc-block-volume-fix branch 2 times, most recently from 083861c to 4f0a2a6 Compare August 25, 2020 14:50
@vbnrh
Copy link
Contributor Author

vbnrh commented Aug 25, 2020

/retest

const [newPVCObj, setNewPVCObj] = React.useState(null);
const [pvcResource, setPVCResource] = React.useState(null);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const [pvcResource, setPVCResource] = React.useState(null);
const [selectedPVC, setSelectedPVC] = React.useState<PersistentVolumeClaimKind>(null);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const newVolumeName = volume ? volume.name : newClaimName;
const newVolumeAlreadyMounted = !!volume;
setVolumeName(newVolumeName);
setVolumeAlreadyMounted(newVolumeAlreadyMounted);
}, [newPVCObj, obj, claimName, showCreatePVC]);
showCreatePVC === 'existing' && newClaimName.trim().length > 0
Copy link
Member

Choose a reason for hiding this comment

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

Why check newClaimName when it's an existing PVC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const newClaimName =
showCreatePVC === 'existing' ? claimName : _.get(newPVCObj, 'metadata.name', '');`

newClaimName can represent both the exisiting and newer claim name.

@@ -135,16 +168,15 @@ export const AttachStorageForm: React.FC<AttachStorageFormProps> = (props) => {
: Promise.resolve(claimName);
};

const getVolumePatches = (pvClaimName: string) => {
const getVolumeMountPatches = (): any[] => {
Copy link
Member

Choose a reason for hiding this comment

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

Not specifying a type and letting TypeScript infer it would be better than any, but we do have a Patch type.

Suggested change
const getVolumeMountPatches = (): any[] => {
const getVolumeMountPatches = (): Patch[] => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -163,10 +195,41 @@ export const AttachStorageForm: React.FC<AttachStorageFormProps> = (props) => {
}
return patch;
}, []);
};

const getVolumeDevicePatches = (): any[] => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const getVolumeDevicePatches = (): any[] => {
const getVolumeDevicePatches = (): Patch[] => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -21,7 +22,7 @@ export const PVCDropdown: React.FC<PVCDropdownProps> = (props) => {
export type PVCDropdownProps = {
namespace: string;
selectedKey: string;
onChange: (string) => void;
onChange: (claimName: string, kindlabel?: string, pvc?: PersistentVolumeClaimKind) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
onChange: (claimName: string, kindlabel?: string, pvc?: PersistentVolumeClaimKind) => void;
onChange: (claimName: string, kindLabel?: string, pvc?: PersistentVolumeClaimKind) => void;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

…age page

Using  block storage provisioners with RWX access mode incorrectly attaches the path as volumeMount in PodSpec instead of volumeDevice. This caused the pods to be in a state of ContainerCreation indefinitely. This  commit fixes this by  sending the object with the right configuration for block storage.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1853599

Signed-off-by: Vineet Badrinath <vbadrina@redhat.com>
Copy link
Member

@spadgett spadgett 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-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnehapk, spadgett, vbnrh

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 8, 2020
@openshift-ci-robot
Copy link
Contributor

@vbnrh: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp-console 48f057e link /test e2e-gcp-console

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/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 9cdb472 into openshift:master Sep 8, 2020
@openshift-ci-robot
Copy link
Contributor

@vbnrh: All pull requests linked via external trackers have merged:

Bugzilla bug 1853599 has been moved to the MODIFIED state.

In response to this:

Bug 1853599: Fixes bug attaching block storage PVC to deployments

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/test-infra repository.

@spadgett spadgett added this to the v4.6 milestone Sep 11, 2020
@vbnrh
Copy link
Contributor Author

vbnrh commented Sep 14, 2020

/cherry-pick release-4.5

@openshift-cherrypick-robot

@vbnrh: #6221 failed to apply on top of branch "release-4.5":

Applying: Fixes bug attaching block storage to pods, deployments in attach-storage page
Using index info to reconstruct a base tree...
M	frontend/public/components/storage/attach-storage.tsx
M	frontend/public/components/utils/list-dropdown.jsx
A	frontend/public/components/utils/pvc-dropdown.tsx
M	frontend/public/module/k8s/types.ts
Falling back to patching base and 3-way merge...
Auto-merging frontend/public/module/k8s/types.ts
CONFLICT (modify/delete): frontend/public/components/utils/pvc-dropdown.tsx deleted in HEAD and modified in Fixes bug attaching block storage to pods, deployments in attach-storage page. Version Fixes bug attaching block storage to pods, deployments in attach-storage page of frontend/public/components/utils/pvc-dropdown.tsx left in tree.
Auto-merging frontend/public/components/utils/list-dropdown.jsx
Auto-merging frontend/public/components/storage/attach-storage.tsx
CONFLICT (content): Merge conflict in frontend/public/components/storage/attach-storage.tsx
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fixes bug attaching block storage to pods, deployments in attach-storage page
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-4.5

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/test-infra repository.

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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants