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

WRKLDS-593 - reordering the stack unwinding to fix how we execute the backup collection #1273

Closed
wants to merge 1 commit into from

Conversation

sferich888
Copy link
Contributor

No description provided.

if !runBackCollection {
return
}
o.BackupGathering(context.TODO(), errs)
Copy link
Member

@wking wking Oct 21, 2022

Choose a reason for hiding this comment

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

Shifting this after the getNamespace call means that failing getNamespace() call will bail out of Run without performing BackupGathering. But we want BackupGathering even when we cannot create namespaces. Something like this could cover both:

var ns *corev1.Namespace
var cleanupNamespace func()

// ... ensure resource cleanup unless instructed otherwise ...
if !o.Keep {
  defer func() {
    if cleanupNamespace != nil {
      cleanupNamespace()
    }
  }()
}

// Due to 'stack unwiding', this should happen after 'clusterState' printing, to ensure that we always
// print our ClusterState information.
runBackCollection := true
defer func() {
  if runBackCollection {
    o.BackupGathering(context.TODO(), errs, ns) // FIXME: also updating BackupGathering to take a possibly-nil *corev1.Namespace, which gets namespace gathering if it's not nil.
  }
}()
	

// Get or create "working" namespace ...
var err error
ns, cleanupNamespace, err = o.getNamespace()
...

Then we'd have a flow tree like:

  • Namespace creation fails
    1. Pop the deferred gather. Gathers the default stuff, but no temporary namespace.
    2. Pop the deferred namespace removal. Nothing to remove.
  • Namespace creation succeeds
    • The main gather still fails, so runBackCollection is still true.
      1. Pop the deferred gather. Gathers the default stuff and also (new with this PR) the temporary namespace.
      2. Pop the deferred namespace removal. Removes the temporary namespace.
    • The main gather succeeds, so runBackCollectionisfalse`.
      1. Pop the deferred gather. runBackCollection is false, so it's a no-op.
      2. Pop the deferred namespace removal. Removes the temporary namespace.

Copy link
Member

Choose a reason for hiding this comment

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

With respect to ordering, I agree with @wking.

We can still run backing up even if the getNamespace fails and the proposed code snippet above ^ sounds reasonable to me.

However, backing up also must-gather temporary namespace might be handled in separate PR under the light of elaborated decision tree above.

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/approve
/assign @ardaguclu

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 22, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sferich888, soltysh

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

The pull request process is described here

Needs approval from an approver in each of these files:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2022
@candita
Copy link

candita commented Oct 24, 2022

/test e2e-agnostic-cmd

@sferich888
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 1, 2023

@sferich888: all tests passed!

Full PR test history. Your PR dashboard.

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.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 3, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 3, 2023
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

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.

@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 2, 2023
@openshift-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Jul 3, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 3, 2023

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants