-
Notifications
You must be signed in to change notification settings - Fork 519
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
CloudFormation signal program (issue #1581) #1728
CloudFormation signal program (issue #1581) #1728
Conversation
Thank you for the PR @mello7tre! We are looking at it 👀 . |
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.
@mello7tre thank you so much for putting this together! I took a look and had a few suggestions for changes. Please let me know if you have any questions about the suggestions. (And if you don't have the time to look at those suggestions, we can keep this open until you do or we can take a look at making those changes for you.)
thanks @samuelkarp for the comments. |
just pushed the requested changes. will came later... |
Is there any movement on this issue? Waiting to adopt Bottlerocket until I can be sure that my asg will wait for instances to register with ECS |
All, we're sorry this has been left open for quite some time. From what I can tell it seems to be on the right track. @mello7tre, would you be able to re-base, squash the commits, and request re-review? |
495c6f5
to
18fef5b
Compare
Rebased as requested. |
Hi @mello7tre, sorry about the delay. I'm gonna do my best and help you get this over the finish line. I took a look over the existing comments and resolved the ones that have been addressed. The only comment that still needs addressing is #1728 (comment). Another thing is we want to make sure bottlerocket/packages/os/early-boot-config.service Lines 9 to 11 in 9749af9
And the sentinel file is created like so: bottlerocket/sources/api/early-boot-config/src/main.rs Lines 144 to 149 in 9749af9
Let me know what you think and how I can help. And finally, since we're introducing new settings, we need to create a simple migration binary to migrate our settings datastore between OS versions. You can read more about migrations here and how to write them here. The closest example would be the bottlerocket/sources/api/migration/migrations/archived/v1.0.5/add-network-settings/src/main.rs Lines 7 to 15 in 9749af9
Of course, we can take care of this for you if you'd prefer not to dabble with it. Just let us know. Thanks again for your contribution! |
Hi @etungsten, just pushed the requested changes. |
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.
Looking good. We need to do a rebase to fix some minor conflicts and fix the migration crate path.
sources/cfsignal/src/main.rs
Outdated
let system_check = Box::new(SystemCheck {}); | ||
let system_status = system_check.system_running()?; | ||
info!( | ||
"System status is: {} [{}]", | ||
system_status.status, system_status.exit_code | ||
); | ||
|
||
// run only if the opt-in flag is set | ||
if config.should_signal { | ||
|
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.
Since we only do anything with the system check status if should_signal
is set, we can have the check inside the if block.
let system_check = Box::new(SystemCheck {}); | |
let system_status = system_check.system_running()?; | |
info!( | |
"System status is: {} [{}]", | |
system_status.status, system_status.exit_code | |
); | |
// run only if the opt-in flag is set | |
if config.should_signal { | |
// run only if the opt-in flag is set | |
if config.should_signal { | |
let system_check = Box::new(SystemCheck {}); | |
let system_status = system_check.system_running()?; | |
info!( | |
"System status is: {} [{}]", | |
system_status.status, system_status.exit_code | |
); |
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.
Could be useful to know which would be the system status even without signaling it to CloudFormation, maybe to try it out in a dry mode
or to debug.
sources/api/migration/migrations/archived/v1.2.0/cfsignal/src/main.rs
Outdated
Show resolved
Hide resolved
sources/api/migration/migrations/archived/v1.2.0/cfsignal/Cargo.toml
Outdated
Show resolved
Hide resolved
a3a9f71
to
29a6ac8
Compare
applied requested changes |
29a6ac8
to
c746961
Compare
i made a little mess rebasing, so i fixed it and force pushed the right "version" |
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.
Nice! I'm gonna start asking others to take a look.
https://github.com/bottlerocket-os/bottlerocket/pull/1728/files#r803845979 still needs a quick fix.
sources/api/migration/migrations/v1.7.0/add-cfsignal/Cargo.toml
Outdated
Show resolved
Hide resolved
Hi @etungsten, i think that to speed up the development is better if, from now on, you directly make all relevant changes. Regards, Alberto. |
c746961
to
01a5332
Compare
Push above addresses comments. Needed to label
|
01a5332
to
4ee5959
Compare
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.
🎸
4295732
to
b4cd707
Compare
b4cd707
to
90ed6c4
Compare
Push above and below addresses @arnaldo2792 's comments. Tested changes and it works as expected:
|
90ed6c4
to
046dbe7
Compare
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.
🦆
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.
🍨
Thanks!
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.
Nice! This looks ready to merge.
@mello7tre, I know this has been a long time coming! I really appreciate the contribution as well as your extraordinary patience. We're planning to ship it in the next release.
Thanks, i am glad to have given a little contribution to the project. |
046dbe7
to
61d634f
Compare
Push above rebases onto develop |
61d634f
to
0a5d75f
Compare
Push above addresses @bcressey 's comments. |
Created a new rust program, cfsignal to send signal to CloudFormation Stack. Program is a sort of cfn-signal https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html but as cfn-signal need python cannot be used by bottlerocket. cfsignal read configuration from a cfsignal.toml file configured reading user-data, so it depends on settings-applier.service. It cannot send a signal for a failure happening before settings-applier.service and network-online.target are started. It is able to send a failure signal for any other service starting from (included): activate-multi-user.service It use systemctl action is-system-running with --wait option. This way we can know if any service, after systemd boot process finished, is in a failure status. Requested changes: * removed author * signal parameter renamed to should_signal (is more specific that should_send) * added README.md * removed commented out lines * use imdsclient in place of ec2_instance_metadata * refactor service_check.rs and renamed to system_check.rs use weak dependency (WantedBy)for cfsignal.service use tokio LTS, only with needed features restart command some code refactor * use directly signal_resource as function * code simplification in system_check.rs * use standard boilerplate for main function semaphore file and migration * Use semaphore file to only run on first boot * Add migration file for downgrading * client.signal_resource collapsed * Fix to packages/os/os.spec: toml file is not copyed (introduced during rebase) Readme changes
0a5d75f
to
526c606
Compare
Push above moves the migration to the |
Tested migration again and it still works as expected |
Issue number:
#1581
Description of changes:
Created a new rust program, cfsignal to send signal to CloudFormation
Stack.
Program is a sort of cfn-signal
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html
but as cfn-signal need python cannot be used by bottlerocket.
cfsignal read configuration from a cfsignal.toml file configured reading
user-data, so it depends on settings-applier.service.
It cannot send a signal for a failure happening before
settings-applier.service and network-online.target are started.
It is able to send a failure signal for any other service starting from
(included):
activate-multi-user.service
It use systemctl action is-system-running with --wait option.
This way we can know if any service, after systemd boot process
finished, is in a failure status.
Detail
I have created a new setting named
cloudformation
.It support the keys:
If signal is false (default) program do nothing.
Other way it excute
systemctl --wait is-system-running
to find out the system state.Then it send the relative signal to the the stack_name stack.
Testing done:
Created and updated and AutoScalingGroup configured to wait signaling by created instances.
Tested that instance send SUCCESS signal if all service started successfully.
Tested that instance send FAILURE signal if a service after
activate-multi-user.service
fail.Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.