-
Notifications
You must be signed in to change notification settings - Fork 231
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
add "overwrite" option to attachPVC view #2176
add "overwrite" option to attachPVC view #2176
Conversation
app/scripts/controllers/attachPVC.js
Outdated
@@ -118,6 +118,51 @@ angular.module('openshiftConsole') | |||
$scope.$watchGroup(['attach.resource', 'attach.allContainers'], updateMountPaths); | |||
$scope.$watch('attach.containers', updateMountPaths, true); | |||
|
|||
var setVolumeMount = function(podTemplate, name, mountPath, subPath, readOnly) { | |||
for (var i = 0; i < podTemplate.spec.containers.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will switch to an angular.forEach
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use Lodash _.each
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, var
isn't block scoped (inside if statements), switching to _.each(function() { })
will fix. It wouldn't error, but its a bit sketch. yay js 😄
app/scripts/controllers/attachPVC.js
Outdated
containers[i].volumeMounts = []; | ||
} | ||
|
||
for (var idx = 0; idx < containers[i].volumeMounts.length; idx++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will switch to angular.forEach
app/scripts/controllers/attachPVC.js
Outdated
} | ||
} | ||
|
||
for (var mountIdx = 0; mountIdx < containers[i].volumeMounts.length; mountIdx++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will also switch to angular.forEach
app/views/attach-pvc.html
Outdated
@@ -211,7 +225,7 @@ <h2 class="text-center">No persistent volume claims.</h2> | |||
<button type="submit" | |||
class="btn btn-primary btn-lg" | |||
ng-click="attachPVC()" | |||
ng-disabled="attachPVCForm.$invalid || disableInputs || !attachPVC">Add</button> | |||
ng-disabled="(attachPVCForm.$invalid) || disableInputs || !attachPVC">Add</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shouldn't need the parens
app/scripts/controllers/attachPVC.js
Outdated
volumeExists = true; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use _.some
to make this a one-liner:
var volumeExists = _.some(podTemplate.spec.volumes, { name: newVolume.name });
@@ -83,6 +83,7 @@ <h2 class="text-center">No persistent volume claims.</h2> | |||
ng-model="attach.mountPath" | |||
ng-pattern="/^\/.*$/" | |||
osc-unique="existingMountPaths" | |||
osc-unique-disabled="attach.overwrite" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@spadgett thanks for the feedback, review comments addressed |
2baea1f
to
d6cd77c
Compare
prob just a rebase & a |
8e44b7f
to
afc011f
Compare
@benjaminapetersen thanks, PR re-built and rebased |
re[test] |
Built /dist does not match what is committed, run 'grunt build' and include the results in your commit. 😄 hack/clean-deps.sh
hack/install-deps.sh
grunt build
// commit this stuff |
afc011f
to
f118eb1
Compare
@benjaminapetersen thanks! that seems to have done the trick |
Yup, now you just have the same e2e test errors that all of our other PRs are struggling with. Woohoo! |
[test] since Jenkins file changed |
@spadgett friendly ping |
f4f32b0
to
bb9a408
Compare
bb9a408
to
9d5d868
Compare
app/scripts/controllers/attachPVC.js
Outdated
success = false; | ||
return success; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this reads a little better and avoids needing a success
flag.
var duplicateMount = _.find(container.volumeMounts, function(mount) {
return mount.mountPath === newVolumeMount.mountPath && mount.name !== newVolumeMount.name;
});
if (duplicateMount) {
displayError('The volume mount "' + duplicateMount.mountPath + '" with name "' + duplicateMount.name +'" already exists for container "' + container.name + '"');
return false;
}
return true;
app/scripts/controllers/attachPVC.js
Outdated
} | ||
}); | ||
|
||
return didReplace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var index = _.findIndex(container.volumeMounts, { name: newVolumeMount.name });
if (index === -1) {
return false;
}
container.volumeMounts[index] = newVolumeMount;
return true;
app/views/attach-pvc.html
Outdated
Overwrite | ||
</label> | ||
<div id="overwrite-help" class="help-block"> | ||
Overwrite the volume mount config (if it already exists). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just say "Overwrite a volume mount if it already exists."
app/scripts/controllers/attachPVC.js
Outdated
|
||
if (!$scope.attach.overwrite || ($scope.attach.overwrite && !volumeExists)) { | ||
podTemplate.spec.volumes.push(newVolume); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to continue if the volume exists and overwrite is not set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to continue if the volume exists and overwrite is not set?
Ah, no pushing a volume containing a duplicate name field would cause an error, however I think I was relying on the client-side checks that we currently have to stop a user from submitting the form if a duplicate name or mount path was found.
Will go ahead and update this to just be
if (!volumeExists) {
podTemplate.spec.volumes.push(newVolume);
}
app/scripts/controllers/attachPVC.js
Outdated
container.volumeMounts.push(newVolumeMount); | ||
} | ||
}); | ||
// angular.forEach(podTemplate.spec.containers, function(container) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code
9d5d868
to
9fe84ee
Compare
@spadgett thanks for the feedback, review comments addressed |
Evaluated for origin web console test up to 9fe84ee |
Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_web_console/327/) (Base Commit: 45d17ff) (PR Branch Commit: 9fe84ee) |
/test |
/lgtm |
/retest |
Automatic merge from submit-queue. |
…volume-overwrite-option Automatic merge from submit-queue. Revert "add "overwrite" option to attachPVC view" Reverts #2176 The change has introduced some bugs. Reverting for now. I've reopened the original issue.
Depends on: openshift/origin-web-common#203
Fixes #2045
Work in progress. Just wanted to begin gathering feedback.
Will post images.
cc @spadgett @benjaminapetersen