Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shawn Wang <wshaoquan@vmware.com>
  • Loading branch information
wsquan171 committed Dec 7, 2022
1 parent 6d31169 commit 982bc6b
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pkg/apiserver/registry/system/supportbundle/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,20 @@ func (r *supportBundleREST) Create(ctx context.Context, obj runtime.Object, _ re
go func(since string) {
var err error
var b *systemv1alpha1.SupportBundle
b, err = r.collectController(ctx, since)
func() {
r.statusLocker.Lock()
defer r.statusLocker.Unlock()
if err != nil {
klog.Errorf("Error when collecting supportBundle: %v", err)
r.cache.Status = systemv1alpha1.SupportBundleStatusNone
return
}
select {
case <-ctx.Done():
default:
r.cache = b
}
}()
b, err = r.collectManager(ctx, since)

r.statusLocker.Lock()
defer r.statusLocker.Unlock()
if err != nil {
klog.Errorf("Error when collecting supportBundle: %v", err)
r.cache.Status = systemv1alpha1.SupportBundleStatusNone
return
}
select {
case <-ctx.Done():
default:
r.cache = b
}

if err == nil {
r.clean(ctx, b.Filepath, bundleExpireDuration)
Expand Down Expand Up @@ -242,7 +241,7 @@ func (r *supportBundleREST) collect(ctx context.Context, dumpers ...func(string)
}, nil
}

func (r *supportBundleREST) collectController(ctx context.Context, since string) (*systemv1alpha1.SupportBundle, error) {
func (r *supportBundleREST) collectManager(ctx context.Context, since string) (*systemv1alpha1.SupportBundle, error) {
clickhousePodNames, err := r.fetchPodNameByLabel(ctx, clickhouseLabel, r.namespace)
if err != nil {
return nil, err
Expand Down

0 comments on commit 982bc6b

Please sign in to comment.