Skip to content

Commit

Permalink
Skip userdata deletion during rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Nov 23, 2022
1 parent 54c2b2f commit 78fa5c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions hypershift-operator/controllers/nodepool/nodepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,9 @@ func (r *NodePoolReconciler) reconcile(ctx context.Context, hcluster *hyperv1.Ho
}
}

userDataSecret := IgnitionUserDataSecret(controlPlaneNamespace, nodePool.GetName(), nodePool.GetAnnotations()[nodePoolAnnotationCurrentConfigVersion])
err = r.Get(ctx, client.ObjectKeyFromObject(userDataSecret), userDataSecret)
if err != nil && !apierrors.IsNotFound(err) {
return ctrl.Result{}, fmt.Errorf("failed to get user data Secret: %w", err)
}
if err == nil {
if err := r.Delete(ctx, userDataSecret); err != nil && !apierrors.IsNotFound(err) {
return ctrl.Result{}, fmt.Errorf("failed to delete user data Secret: %w", err)
}
}
// We keep the old userdata Secret so old Machines during rolled out can be deleted.
// Otherwise, deletion fails because of https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/3805.
// TODO (Alberto): enable back deletion when the PR above gets merged.
}

tokenSecret = TokenSecret(controlPlaneNamespace, nodePool.Name, targetConfigVersionHash)
Expand Down Expand Up @@ -2098,10 +2091,10 @@ func (r *NodePoolReconciler) doesCPODecompressAndDecodeConfig(ctx context.Contex
return managesDecompressAndDecodeConfig, nil
}

// ensureMachineDeletion ensures all the machines belonging to the NodePool's MachineSet are fully deleted
// This function can be deleted once the upstream PR (https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/3805) is merged and pulled into https://github.com/openshift/cluster-api
// ensureMachineDeletion ensures all the machines belonging to the NodePool's MachineSet are fully deleted.
// This function can be deleted once the upstream PR (https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/3805) is merged and pulled into https://github.com/openshift/cluster-api-provider-aws.
// This function is necessary to ensure AWSMachines are fully deleted prior to deleting the NodePull secrets being deleted due to a bug introduced by https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/2271
// See https://github.com/openshift/hypershift/pull/1826#discussion_r1007349564 for more details
// See https://github.com/openshift/hypershift/pull/1826#discussion_r1007349564 for more details.
func (r *NodePoolReconciler) ensureMachineDeletion(nodePool *hyperv1.NodePool, controlPlaneNamespace string) error {
// Get list of CAPI Machines to filter through
machines := capiv1.MachineList{}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func validateAWSGuestResourcesDeletedFunc(ctx context.Context, t *testing.T, inf
taggingClient := resourcegroupstaggingapi.New(awsSession, awsConfig)

// Find load balancers, persistent volumes, or s3 buckets belonging to the guest cluster
err := wait.PollImmediate(5*time.Second, 40*time.Minute, func() (bool, error) {
err := wait.PollImmediate(5*time.Second, 15*time.Minute, func() (bool, error) {
// Filter get cluster resources.
output, err := taggingClient.GetResourcesWithContext(ctx, &resourcegroupstaggingapi.GetResourcesInput{
ResourceTypeFilters: []*string{
Expand Down

0 comments on commit 78fa5c3

Please sign in to comment.