Skip to content

Conversation

@cgwalters
Copy link
Member

The saga of adding "firstboot MachineConfig" in
#798
is getting closer. This is a small amount of code that builds on
a lot of prep work that landed to add a systemd service + entrypoint
in the MCD that reads the
/etc/ignition-machine-config-encapsulated.json file. You
could think of this a lot like a variant of "once-from".

However, it doesn't run by default right now because the MCS still
serves /etc/pivot/image-pullspec, and this gives us a way to
"ratchet" the change as we need this new MCD code to land in RHCOS
before we can use it.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 27, 2019
@cgwalters cgwalters force-pushed the mcd-process-encapsulated-mc branch 2 times, most recently from dd694d3 to 636ff14 Compare June 27, 2019 18:06
@cgwalters
Copy link
Member Author

Vertical pod autoscaler flake looks like.
/test e2e-aws

@runcom
Copy link
Member

runcom commented Jul 2, 2019

/retest

@runcom
Copy link
Member

runcom commented Jul 2, 2019

This looks right to me and loving the diff methods as well

/approve

@cgwalters
Copy link
Member Author

Further progress here blocks on #662 (comment) I think since we need to handle the "4.1.0 bootimage" case no matter what.

But, I also think this PR is pretty safe to land as is; there's just some prep refactoring, the end commit doesn't do anything since as noted above the ConditionPathExists= will always be false.

@cgwalters
Copy link
Member Author

Would it help to split off a separate PR with the prep commits here?

@runcom
Copy link
Member

runcom commented Jul 8, 2019

Would it help to split off a separate PR with the prep commits here?

it would 🙏

@cgwalters
Copy link
Member Author

Done in #935

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2019
@sinnykumari
Copy link
Contributor

However, it doesn't run by default right now because the MCS still
serves /etc/pivot/image-pullspec, and this gives us a way to
"ratchet" the change as we need this new MCD code to land in RHCOS
before we can use it.

This PR has nice work done in MCD to read encapsulated MC available on nodes. It looks to me that we will need these changes in machine-config-daemon package shipped with RHCOS. It seems that this PR is going to make into 4.3+. Since we don't have a way to update bootimages, are we going to need some way to get latest machine-config-daemon binary for 4.2 cluster upgrade? Something similar to what we have been discussing for 4.1 cluster update for Day1 kargs in #798 (comment) and further comment?

@cgwalters
Copy link
Member Author

Something similar to what we have been discussing for 4.1 cluster update for Day1 kargs in #798 (comment) and further comment?

Yeah, encoding the mcd binary into Ignition is the best thing I can think of.

@sinnykumari
Copy link
Contributor

@cgwalters Can we get this PR rebased to get it tested with latest changes?

@cgwalters cgwalters force-pushed the mcd-process-encapsulated-mc branch from 636ff14 to ba7d45d Compare October 7, 2019 13:27
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 7, 2019
@cgwalters
Copy link
Member Author

So #935 had some prep cleanup but a bit surprisingly this PR seems to rebase cleanly and build at least without it. It might be there was some semantic stuff necessary there, or maybe I just jumped the gun and churned the code unnecessarily. Unfortunately now I've forgotten the full context.

Regardless...I think before we can really use this PR we need to land support for "MCD injection" i.e. injecting the MCD binary via Ignition.

Split off a function to diff two MCs without reconciling; it
is just cleaner.  Then add an API to ask whether the diff is empty,
as well as a wrapper that logs.

Change the once-from path to use `nil` to mean "use a canonical empty MC"
so we don't need to handle `nil` elsewhere.

This will be used by future work on "early kargs" where we want
to reboot only if the user provided non-default kargs.
I am getting spurious "changed" in the diff due to the difference
between a `nil` array and the empty array.

Someone please tell me there's a more elegant way to do this in Go...
The saga of adding "firstboot MachineConfig" in
openshift#798
is getting closer.  This is a small amount of code that builds on
a lot of prep work that landed to add a systemd service + entrypoint
in the MCD that reads the
`/etc/ignition-machine-config-encapsulated.json` file.  You
could think of this a lot like a variant of "once-from".

However, it doesn't run by default right now because the MCS still
serves `/etc/pivot/image-pullspec`, and this gives us a way to
"ratchet" the change as we need this new MCD code to land in RHCOS
before we can use it.
@cgwalters cgwalters force-pushed the mcd-process-encapsulated-mc branch from ba7d45d to 40d8225 Compare October 9, 2019 00:10
# we can land this code and then get it built into the host.
ConditionPathExists=!/etc/pivot/image-pullspec
ConditionPathExists=/etc/ignition-machine-config-encapsulated.json
After=ignition-firstboot-complete.service
Copy link
Contributor

Choose a reason for hiding this comment

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

While I was testing this locally, noticed that machine-config-daemon-firstboot.service runs when a newly created cluster reboots after applying ignition configs and updates, which leads to another reboot. It's because /etc/pivot/image-pullspec gets deleted once cluster is updated to latest machine-os-content during first boot. Should we also add something like BindsTo=ignition-firstboot-complete.service here to avoid running it in next reboot or it's an acceptable behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm...we should be deleting /etc/pivot/image-pullspec during firstboot.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we delete /etc/pivot/image-pullspec during firstboot which happens after OS is upgraded to latest machine-os-content but machine-config-daemon-firstboot.service runs early enough and at that time image-pullspec file still exist. Once system reboots after updating OS, /etc/pivot/image-pullspec doesn't exist and /etc/ignition-machine-config-encapsulated.json exist which leads machine-config-daemon-firstboot.servicerun. That's probably because systemd After=ignition-firstboot-complete.service is not enough to not run machine-config-daemon-firstboot.service service if ignition-firstboot-complete.service service failed

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I see, though I think we should probably be deleting the /etc/ignition-machine-config-encapsulated.json file too.
But this BindsTo= approach is also fine.

@sinnykumari
Copy link
Contributor

So #935 had some prep cleanup but a bit surprisingly this PR seems to rebase cleanly and build at least without it. It might be there was some semantic stuff necessary there, or maybe I just jumped the gun and churned the code unnecessarily. Unfortunately now I've forgotten the full context.

Thanks for rebasing the PR!

Regardless...I think before we can really use this PR we need to land support for "MCD injection" i.e. injecting the MCD binary via Ignition.

Are we talking this in context of testing this PR by injecting machine-config-daemon binary (containing this change) through ignition config during cluster install or this is something else ?

I tried to test this PR locally by generating manifests and editing existing 99_openshift-machineconfig_worker.yaml and 99_openshift-machineconfig_master.yaml files injecting machine-config-daemon into /usr/local/bin/ path and machine-config-daemon-firstboot.service file which gets successfully added to nodes, even runs and applies kargs during initial boot if I edit service file accordingly. Is it right way to test it?

One issue which I am seeing with my test approach is mcd fails to apply rendered config with error daemon.go:1293] couldn't parse file: missing data prefix (error message from one of running mcd pod). It's because I am injecting mcd binary into ignition as https path instead of data in source and MCD doesn't seems to support it while validating source

@cgwalters
Copy link
Member Author

Are we talking this in context of testing this PR by injecting machine-config-daemon binary (containing this change) through ignition config during cluster install or this is something else ?

Yep! I think that's a hard prerequisite/requirement for this.

I tried to test this PR locally by generating manifests

Sounds reasonable to me!

One issue which I am seeing with my test approach is mcd fails to apply rendered config with error daemon.go:1293] couldn't parse file: missing data prefix (error message from one of running mcd pod).

Ah right; in general in the MCO I don't think we can easily support remote data sources in Ignition, becuase it breaks the "immutability" of the checksum in rendered-worker-<sha1>. We don't know when remote sources change so we wouldn't know when to update. So I think our code should encode the MCD binary directly via base64 encoding (as ugly as that is).

That said, I think I'd test this out via changing the MCS to serve the binary as that should be the final plan - we only need the MCD binary during firstboot - after that we've already updated to the target machine-os-content (and for that matter the MCD runs also as a pod) - anyways we know it's new enough. To say this another way, we're encoding the MCD as a special "extra" in Ignition but not MachineConfig.

@sinnykumari
Copy link
Contributor

Ah right; in general in the MCO I don't think we can easily support remote data sources in Ignition, becuase it breaks the "immutability" of the checksum in rendered-worker-<sha1>. We don't know when remote sources change so we wouldn't know when to update. So I think our code should encode the MCD binary directly via base64 encoding (as ugly as that is).

got it!

That said, I think I'd test this out via changing the MCS to serve the binary as that should be the final plan - we only need the MCD binary during firstboot - after that we've already updated to the target machine-os-content (and for that matter the MCD runs also as a pod) - anyways we know it's new enough.

Hmm, to start with we were thinking of having kargs day1 feature available to 4.3 and onward clusters where we can have latest machine-config-daemon binary available in installer bootimage(updating machine-config-daemon package which ships with RHCOS) . Injecting mcd binary through ignition which is served by MCS was next step (which I believe will also help us to support karg day1 in 4.1/4.2 based cluster)

To say this another way, we're encoding the MCD as a special "extra" in Ignition but not MachineConfig.

Right!
I was editing MachineConfig to inject mcd binary just for testing. Once this code gets merged, we should only be updating machine-config-daemon package which should provide required functionality to apply kargs during first boot

@sinnykumari
Copy link
Contributor

/retest e2e-aws-scaleup-rhel7

@sinnykumari
Copy link
Contributor

/retest

…boot

We first want to make sure that updated machine-config-dameon
package get in into bootimage and things runs as expected.
Once verified, we will update m-c-d-firstboot service to run
during firstboot
@sinnykumari sinnykumari force-pushed the mcd-process-encapsulated-mc branch from f839c39 to a465088 Compare October 15, 2019 17:50
Copy link
Contributor

@kikisdeliveryservice kikisdeliveryservice left a comment

Choose a reason for hiding this comment

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

some fixup suggestions to simplify this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes perf! simple and clean.

Both empty and nil slices are of size zero and contains
nothing. Consider them as equal while doing kargs comparison
in old and new MachineConfigs
@sinnykumari sinnykumari force-pushed the mcd-process-encapsulated-mc branch from cb4b39d to aa2e045 Compare October 16, 2019 18:19
Copy link
Contributor

@kikisdeliveryservice kikisdeliveryservice left a comment

Choose a reason for hiding this comment

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

Thanks for all of the updates @sinnykumari ! They look good. =D

@sinnykumari
Copy link
Contributor

yay! all tests are passing.Thanks everyone for the review!

@sinnykumari
Copy link
Contributor

Have done another round of cluster run with mcd binary and custom payload with latest changes, looks good to me.

@cgwalters Please take a look at it, want to make sure we didn't miss anything.

@runcom
Copy link
Member

runcom commented Oct 17, 2019

awesome
/approve

I'll leave to others on the team to lgtm but looks good otherwise!

@cgwalters
Copy link
Member Author

/lgtm

@openshift-ci-robot
Copy link
Contributor

@cgwalters: you cannot LGTM your own PR.

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ericavonb
Copy link

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, ericavonb, runcom

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [cgwalters,ericavonb,runcom]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sinnykumari
Copy link
Contributor

/retest

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Oct 17, 2019

@cgwalters: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws-disruptive 636ff14e947bf4651ee6bdb762259e13df487799 link /test e2e-aws-disruptive
ci/prow/e2e-aws-op a465088 link /test e2e-aws-op
ci/prow/e2e-gcp-upgrade aa2e045 link /test e2e-gcp-upgrade

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@sinnykumari
Copy link
Contributor

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants