Skip to content

Commit

Permalink
added option to disable monitor installation (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Jun 18, 2020
1 parent a7de550 commit 2a46cee
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lib/interface/cli/commands/hybrid/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ const deleteCmd = new Command({
const [listAgentsErr, agents] = await to(sdk.agents.list({ }));
await handleError(listAgentsErr, 'Failed to get agents');

if (!agents.length) {
console.log('No runners found on your codefresh account');
process.exit(0);
}

console.log(colors.green('This uninstaller will guide you through the runner uninstallation process'));

if (!kubeContextName) {
Expand Down
15 changes: 12 additions & 3 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const initCmd = new Command({
describe: 'Run a demo pipeline after the installation completes',
type: 'boolean',
})
.option('install-monitor', {
describe: 'Install a monitoring component that will help provide valueable data about your cluster to Codefresh',
type: 'boolean',
default: true,
})
.option('kube-namespace', {
describe: 'Name of the namespace on which venona should be installed [$CF_ARG_KUBE_NAMESPACE]',
})
Expand Down Expand Up @@ -164,6 +169,7 @@ const initCmd = new Command({
'set-value': setValue,
'set-file': setFile,
'skip-cluster-test': skipClusterTest,
'install-monitor': installMonitor,
} = _argv;
let {
'kube-context-name': kubeContextName,
Expand Down Expand Up @@ -214,11 +220,11 @@ const initCmd = new Command({
}

if (_.isUndefined(shouldMakeDefaultRe)) {
if (_.get(sdk, 'config.context.isNoAuth') || await isNewAccount()) {
if (!_.get(sdk, 'config.context.isNoAuth') && await isNewAccount()) {
// don't ask and set this runtime as default if it's a new account
shouldMakeDefaultRe = true;
} else {
let message = 'Set this as the default runtime environment for your Codefresh account? (Y/N)';
let message = 'Set this as the default runtime environment for your Codefresh account?';
const [, defaultRe] = await to(getDefaultRuntime());
if (defaultRe) {
message = `Change the current default runtime "${colors.cyan(defaultRe.metadata.name)}" to new runtime ?`;
Expand Down Expand Up @@ -494,6 +500,7 @@ const initCmd = new Command({
},
successMessage: 'Successfully installed cluster monitoring',
installationEvent: installationProgress.events.MONITOR_INSTALLED,
condition: installMonitor,
});

// Post Installation
Expand Down Expand Up @@ -545,7 +552,9 @@ const initCmd = new Command({

console.log(colors.green('\nRunner Status:'));
await getAgents.handler({});
console.log(colors.green(`\nGo to ${colors.blue('https://g.codefresh.io/kubernetes/monitor/services')} to view your cluster in codefresh dashbaord`));
if (installMonitor) {
console.log(colors.green(`\nGo to ${colors.blue('https://g.codefresh.io/kubernetes/monitor/services')} to view your cluster in codefresh dashbaord`));
}
console.log(colors.green(`\nDocumenation link: ${colors.blue('https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release')}`));
console.log(colors.green(`If you had any issues with the installation please report them at: ${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`));
await to(progressReporter.report(installationProgress.events.FINISHED, installationProgress.status.SUCCESS));
Expand Down
27 changes: 15 additions & 12 deletions lib/interface/cli/commands/hybrid/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async function migrate({
runtimeName,
kubeContextName,
kubeNamespace,
installMonitor,
agentName,
handleError,
kubeConfigPath,
Expand Down Expand Up @@ -151,18 +152,20 @@ async function migrate({
handleError(agentInstallErr, 'Failed to install new agent and runtime');

// Install new monitoring components
console.log('Installing monitoring components');
const monitorInstallOptions = {
'kube-config-path': kubeConfigPath,
'cluster-id': kubeContextName,
'kube-context-name': kubeContextName,
'kube-namespace': kubeNamespace,
token: _.get(sdk, 'config.context.token'),
verbose,
noExit: true, // to prevent if from calling inner: process.exit()
};
const [monitorErr] = await to(installMonitoring.handler(monitorInstallOptions));
await handleError(monitorErr, 'Monitor installation failed');
if (installMonitor) {
console.log('Installing monitoring components');
const monitorInstallOptions = {
'kube-config-path': kubeConfigPath,
'cluster-id': kubeContextName,
'kube-context-name': kubeContextName,
'kube-namespace': kubeNamespace,
token: _.get(sdk, 'config.context.token'),
verbose,
noExit: true, // to prevent if from calling inner: process.exit()
};
const [monitorErr] = await to(installMonitoring.handler(monitorInstallOptions));
await handleError(monitorErr, 'Monitor installation failed');
}

// Execute test pipeline on new runner
await createAndRunTestPipeline(runtimeName, handleError);
Expand Down
7 changes: 7 additions & 0 deletions lib/interface/cli/commands/hybrid/upgrade.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ const upgradeCmd = new Command({
.option('kube-config-path', {
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
})
.option('install-monitor', {
describe: 'Install a monitoring component that will help provide valueable data about your cluster to Codefresh (only useable when running migration)',
type: 'boolean',
default: true,
})
.option('verbose', {
describe: 'Print logs',
}),
handler: async (argv) => {
const {
'kube-config-path': kubeConfigPath,
'agent-name': agentName,
'install-monitor': installMonitor,
verbose,
} = argv;
let {
Expand Down Expand Up @@ -162,6 +168,7 @@ const upgradeCmd = new Command({
agentName,
agents,
runtimeName,
installMonitor,
verbose,
handleError,
}));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.68.9",
"version": "0.68.10",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 2a46cee

Please sign in to comment.