Skip to content

Commit

Permalink
Remove machine config render check for bundle generation
Browse files Browse the repository at this point in the history
It looks like if nothing other than the secret changes,
the MCO will just re-use the past rendered config (because it's already there
and it's what it would have rendered anyway) instead of rendering a new one.

The desired end state (the proper secret ending up on the node) seems to always be reached regardless of what I do.

What does happen, and what appears to result in it not rendering a new config is:

	- If the only thing you've changed is the secret (there are no other machine config changes in the pool)
	- That exact secret has already been patched in and rendered at least once before

Then the mco will:

	- notice the secret changed (and log "Re-syncing ControllerConfig due to secret pull-secret change")
	- notice that there is already a matching rendered machineconfig
	- roll out that previously rendered machineconfig

- https://bugzilla.redhat.com/show_bug.cgi?id=1999575#c1
  • Loading branch information
praveenkumar authored and guillaumerose committed Sep 3, 2021
1 parent cf730cd commit e60e9ad
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions pkg/crc/cluster/cluster.go
Expand Up @@ -177,43 +177,15 @@ func EnsureGeneratedClientCAPresentInTheCluster(ocConfig oc.Config, sshRunner *s
}

func RemovePullSecretFromCluster(ocConfig oc.Config, sshRunner *ssh.Runner) error {
mcBeforeRemovePullSecret, stderr, err := ocConfig.RunOcCommand("get mc --sort-by=.metadata.creationTimestamp --no-headers -oname")
if err != nil {
return fmt.Errorf("failed to get machineconfig resource %w: %s", err, stderr)
}
logging.Info("Removing user's pull secret from instance disk and from cluster secret...")
cmdArgs := []string{"patch", "secret", "pull-secret", "-p",
`'{"data":{".dockerconfigjson":"e30K"}}'`,
"-n", "openshift-config", "--type", "merge"}

_, stderr, err = ocConfig.RunOcCommand(cmdArgs...)
_, stderr, err := ocConfig.RunOcCommand(cmdArgs...)
if err != nil {
return fmt.Errorf("Failed to remove Pull secret %w: %s", err, stderr)
}

mcRenderedFunc := func() error {
mcAfterRemovePullSecret, stderr, err := ocConfig.RunOcCommand("get mc --sort-by=.metadata.creationTimestamp --no-headers -oname")
if err != nil {
return &errors.RetriableError{Err: fmt.Errorf("failed to get machineconfig resource %w: %s", err, stderr)}
}
if mcBeforeRemovePullSecret == mcAfterRemovePullSecret {
return &errors.RetriableError{Err: fmt.Errorf("machine config is not rendered after removing pull secret")}
}
// This 20sec sleep is required because just after machine config render happen it takes some time
// for machine config pool to process this new render file.
time.Sleep(20 * time.Second)
mcpDegradedMachineCount, stderr, err := ocConfig.RunOcCommand("get mcp master -ojsonpath='{.status.degradedMachineCount}'")
if err != nil {
return &errors.RetriableError{Err: fmt.Errorf("failed to get machineconfig resource %w: %s", err, stderr)}
}
if strings.TrimSpace(mcpDegradedMachineCount) != "0" {
return &errors.RetriableError{Err: fmt.Errorf("machine pool config is in degraded machine count")}
}
return nil
}
if err := errors.RetryAfter(1*time.Minute, mcRenderedFunc, 2*time.Second); err != nil {
return err
}
return waitForPullSecretRemovedFromInstanceDisk(sshRunner)
}

Expand Down

0 comments on commit e60e9ad

Please sign in to comment.