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

Added configMaps section in Kubernetes #6646

Merged
merged 7 commits into from
Mar 27, 2018

Conversation

Anumita
Copy link
Contributor

@Anumita Anumita commented Mar 9, 2018

image

image

@@ -13,7 +13,7 @@
"version": {
"Major": 0,
"Minor": 1,
"Patch": 15
"Patch": 53
Copy link
Contributor

Choose a reason for hiding this comment

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

53?

"label": "Force update configmap",
"defaultValue": "true",
"helpMarkDown": "Delete the configmap if it exists and create a new one with updated values.",
"groupName": "configMaps"
Copy link
Contributor

@jikuma jikuma Mar 12, 2018

Choose a reason for hiding this comment

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

From the spec, I can see that Secrets and Config map is combined. Did you talk to Atul.

executeCreateConfigMapCommand(clusterConnection, configMapName);
}
else {
executeKubectlCommand(clusterConnection);
Copy link
Contributor

Choose a reason for hiding this comment

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

in case of secret, then config map will command be executed?

}, function failure(err) {
tl.setResult(tl.TaskResult.Failed, err.message);
}).done();
}
else if(configMapName) {
executeCreateConfigMapCommand(clusterConnection, configMapName);
Copy link
Contributor

Choose a reason for hiding this comment

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

will command be executed after creating config map?

kubectlConfigMap.run(clusterConnection, configMapName).fin(function cleanup(){
clusterConnection.close();
}).then(function success() {
executeKubectlCommand(clusterConnection);
Copy link
Contributor

Choose a reason for hiding this comment

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

the function name is executeCreateConfigMapCommand, it should not run any other kubectl command. You need to refactor the code.

@@ -311,6 +315,84 @@ describe('Kubernetes Suite', function() {
console.log(tr.stderr);
done();
});

it('Runs successfully for kubectl create configMap from file or directory with forceUpdate', (done:MochaDone) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test cases to validate following scenerios.

  1. create secret -> create configmap -> kubectl commad execution. All three commands are getting executed.
  2. create configmap -> kubectl commad. These two commands are independently getting executed.
  3. create secret -> kubectl commad. These two commands are independently getting executed.

@jikuma
Copy link
Contributor

jikuma commented Mar 13, 2018

Please check the error scenarios also.

clusterConnection.close();
}).then(function success() {
executeKubectlCommand(clusterConnection);
}, function failure(err) {
tl.setResult(tl.TaskResult.Failed, err.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use try catch here. clusterConnection is not cleaned while exception occurs.

"loc.input.label.configMapFile": "ConfigMap File",
"loc.input.help.configMapFile": "Specify a file or directory that contains the configMaps",
"loc.input.label.configMapArguments": "Arguments",
"loc.input.help.configMapArguments": "Specify keys and literal values to insert in configMap.For example, --from-literal=key1=value1 --from-literal=key2=\"top secret\". Please use double quotes to specify any literals that have spaces.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Use not 'Please Use'. Get these messages reviewed by Atul.

connection.close();
});
}
catch (error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this try catch needed? catch at the end of promise should be enough, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That catches exceptions only in the run function and not in the open function

}

// execute kubectl command
function executeKubectlCommand(clusterConnection: ClusterConnection) : any {

var command = tl.getInput("command", true);
var result = "";
var ouputVariableName = tl.getInput("kubectlOutput", false);
kubectl.run(clusterConnection, command, (data) => result += data)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you have to return back the promise from kubectl.run


export function run(connection: ClusterConnection, configMapName: string): any {
if(tl.getBoolInput("forceUpdateConfigMap") == true) {
return deleteConfigMap(connection, configMapName).fin(() =>{
Copy link
Contributor

Choose a reason for hiding this comment

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

Is deletion of config map ok?

@@ -5,6 +5,7 @@ import path = require('path');

import ClusterConnection from "./clusterconnection";
Copy link
Contributor

Choose a reason for hiding this comment

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

As you mentioned, make sure that it works in a re-runnable scenario.

{
return executeKubetclGetConfigmapCommand(connection, configMapName).then(function success() {
tl.debug(tl.loc('ConfigMapExists', configMapName));
}, function failure() {
Copy link
Contributor

Choose a reason for hiding this comment

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

will it be failure?

}

return configMapFromFromFileArgument;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

why it is else here?

@Anumita Anumita merged commit 8b888d3 into master Mar 27, 2018
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.

4 participants