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

[teleport-update] Support for Enterprise/FIPS migration #49451

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

sclevine
Copy link
Member

@sclevine sclevine commented Nov 26, 2024

This PR adds support for migrating agents to/from Enterprise or Enterprise FIPS editions of Teleport

This is accomplished by storing install flags in update.yaml, and appending _ent or _ent_fips to version directories.

ubuntu@legendary-mite:~$ ./teleport-update status
proxy: example.com
enabled: true
pinned: false
active:
    version: 16.4.7
    flags: [Enterprise]
target:
    version: 16.4.7
    flags: [Enterprise]
in_window: true
jitter: 1m0s

The teleport-update binary will be used to enable, disable, and trigger automatic Teleport agent updates. The new auto-updates system manages a local installation of the cluster-specified version of Teleport stored in /var/lib/teleport/versions.

RFD: #47126
Goal (internal): https://github.com/gravitational/cloud/issues/10289

@sclevine sclevine added the no-changelog Indicates that a PR does not require a changelog entry label Nov 26, 2024
@sclevine sclevine marked this pull request as ready for review November 26, 2024 07:45
@github-actions github-actions bot requested a review from bl-nero November 26, 2024 07:46
lib/autoupdate/agent/config.go Show resolved Hide resolved
lib/autoupdate/agent/config.go Outdated Show resolved Hide resolved
parts := strings.Split(dir, "_")
var out Revision
if len(parts) == 0 {
return out, fmt.Errorf("dir name empty")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use errors.New or trace.BadParameter here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I meant to use trace.Errorf. I know now that trace.Errorf breaks stack traces when used for wrapping. Are there any issues with using it outside of wrapping?

return ""
case FlagEnterprise:
return "ent"
case FlagFIPS:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these bit flags? Any risk of us converting to "unknown" if both FlagEnterprise and FlagFIPS is set? Maybe this helps?

Suggested change
case FlagFIPS:
case FlagFIPS, FlagEnterprise|FlagFIPS:

Copy link
Member Author

@sclevine sclevine Nov 26, 2024

Choose a reason for hiding this comment

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

These are bit flags. This method is just intended for single-bit contexts, similar to String(). The calling code ensures that FlagFIPS implies FlagEnterprise (and ensures that the order is always consistent).

return trace.Wrap(err)
}
if i == nil {
return trace.Errorf("nil install flags while parsing YAML")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return trace.Errorf("nil install flags while parsing YAML")
return trace.BadParameter("nil install flags while parsing YAML")

Copy link
Member Author

Choose a reason for hiding this comment

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

What's the motivation for using a typed error in these contexts? The YAML parser (or calling code) doesn't look for BadParameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Convention? We have an error type that is used heavily throughout the code base whose semantics match the use case here.

I'd be asking the inverse - why wouldn't we want to use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Happy to follow convention here -- just trying to understand this better.

why wouldn't we want to use it?

Using the same set of generic typed errors without expected matchers throughout the codebase seems like it would make it easy to introduce bugs in error handling. For example, someone may be looking for a specific BadParameter error further up the stack, but match this one from a different call stack instead. Or someone may replace this BadParameter with something else (because most BadParameter calls aren't actually matched) and break calling code by accident.

This is why standard library error types that are broadly used also are very specific (e.g., file does not exist).

lib/autoupdate/agent/updater.go Outdated Show resolved Hide resolved
Base automatically changed from sclevine/teleport-update-namespace to master December 3, 2024 22:30
cleanup

formatting

revert updater rename

cleanup

Update lib/autoupdate/agent/config.go

Co-authored-by: Zac Bergquist <[email protected]>

feedback
@sclevine sclevine force-pushed the sclevine/teleport-update-suffix branch from df1b765 to 04e3f9a Compare December 4, 2024 01:12
@sclevine sclevine enabled auto-merge December 4, 2024 01:15
@sclevine sclevine added this pull request to the merge queue Dec 4, 2024
Merged via the queue into master with commit d1b5f6c Dec 4, 2024
42 checks passed
@sclevine sclevine deleted the sclevine/teleport-update-suffix branch December 4, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants