Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Provide tctl inside cluster. #688

Merged
merged 5 commits into from
Sep 19, 2019
Merged

Provide tctl inside cluster. #688

merged 5 commits into from
Sep 19, 2019

Conversation

r0mant
Copy link
Contributor

@r0mant r0mant commented Sep 18, 2019

This PR makes sure that tctl can be used inside gravity clusters and is pre-configured so it can be used without any configuration from user's side. Refs https://github.com/gravitational/gravity.e/issues/4198, #580.

Also a couple of other things:

  • Update some parts of "cli/system" to use "update/system" instead (specifically the "system reinstall" command) which removed a lot of duplicated code and allowed to reuse the same logic during upgrade and install.

I'm actually thinking we should just nuke the whole "cli/system" module as 90% of its commands are not used anymore and moreover they're not kept up-to-date with the logic in "update/system" so it's probably even harmful to use them. Refs https://github.com/gravitational/gravity.e/issues/4175.

}

// renderTctlScript renders the contents of the script that invokes tctl binary
// with apporpriate configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

apporpriate -> appropriate

logrus.ErrorKey: err,
"output": string(out),
}).Warn("Failed to update kubectl symlink.")
logger.WithError(err).WithField("output", string(out)).Warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

What if I want to add another field - should I chain it with another WithFeild? Each WithField is also potentially allocating memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily, you can still use WithFields(), I just think WithField() looks cleaner when you have only 1 field.

// tctlScript is the template of the script that invokes tctl binary with
// configuration supplied via an environment variable.
var tctlScript = template.Must(template.New("tctl").Parse(`#!/bin/bash
TELEPORT_CONFIG={{.conf}} {{.path}} "$@"`))
Copy link
Contributor

Choose a reason for hiding this comment

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

Will path be properly escaped if it contains special characters? Ditto for teleport configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think path can contain special characters. It points to the unpacked teleport package directory inside our state dir, and if somebody overrides state dir to have special characters in it, I think they'll have bigger problems than non-working tctl script.

And the configuration is base64-encoded so it doesn't need to be escaped.

}

args := []string{"system", "reinstall", newPackage.String()}
args := []string{"system", "reinstall", newPackage.String(), "--cluster-role", clusterRole}
Copy link
Contributor

Choose a reason for hiding this comment

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

According to flag description it's optional.

@r0mant r0mant merged commit cf01c50 into master Sep 19, 2019
@r0mant r0mant deleted the roman/tctl2 branch September 19, 2019 18:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants