@@ -45,25 +45,23 @@ const (
45
45
var (
46
46
// Declared as variables for testing.
47
47
defaultFS = afero .NewOsFs ()
48
- defaultExecutor = exec .New ()
49
- newAgentDumper = support .NewAgentDumper
50
48
51
49
clock clockutils.Clock = clockutils.RealClock {}
52
50
)
53
51
54
52
// NewControllerStorage creates a sampling storage for working on antrea controller.
55
53
func NewControllerStorage () Storage {
56
- bundle := & supportBundleREST {
54
+ bundle := & samplingPacketsREST {
57
55
mode : modeController ,
58
- cache : & systemv1beta1.SupportBundle {
56
+ cache : & systemv1beta1.CapturedPacket {
59
57
ObjectMeta : metav1.ObjectMeta {Name : modeController },
60
- Status : systemv1beta1 .SupportBundleStatusNone ,
58
+ Status : systemv1beta1 .SamplingPacketStatusNone ,
61
59
},
62
60
}
63
61
return Storage {
64
62
Mode : modeController ,
65
- SupportBundle : bundle ,
66
- Download : & downloadREST {supportBundle : bundle },
63
+ SamplingPacket : bundle ,
64
+ Download : & downloadREST {capturedPacket : bundle },
67
65
}
68
66
}
69
67
@@ -78,7 +76,7 @@ func NewAgentStorage() Storage {
78
76
return Storage {
79
77
Mode : modeAgent ,
80
78
SupportBundle : bundle ,
81
- Download : & downloadREST {supportBundle : bundle },
79
+ Download : & downloadREST {capturedPacket : bundle },
82
80
}
83
81
}
84
82
@@ -125,17 +123,13 @@ func (r *samplingPacketsREST) Create(ctx context.Context, obj runtime.Object, _
125
123
r .cancelFunc = cancelFunc
126
124
go func () {
127
125
var err error
128
- var b * systemv1beta1.SupportBundle
129
- if r .mode == modeAgent {
130
- b , err = r .collectAgent (ctx , since )
131
- } else if r .mode == modeController {
132
- b , err = r .collectController (ctx , since )
133
- }
126
+ var b * systemv1beta1.CapturedPacket
127
+ b , err = r .collectAgent (ctx , since )
134
128
func () {
135
129
r .statusLocker .Lock ()
136
130
defer r .statusLocker .Unlock ()
137
131
if err != nil {
138
- klog .Errorf ("Error when collecting supportBundle : %v" , err )
132
+ klog .Errorf ("Error when collecting capturedPacket : %v" , err )
139
133
r .cache .Status = systemv1beta1 .SamplingPacketStatusNone
140
134
return
141
135
}
@@ -167,7 +161,7 @@ func (r *samplingPacketsREST) Get(_ context.Context, name string, _ *metav1.GetO
167
161
r .statusLocker .RLock ()
168
162
defer r .statusLocker .RUnlock ()
169
163
if r .cache .Name != name {
170
- return nil , errors .NewNotFound (systemv1beta1 .Resource ("supportBundle " ), name )
164
+ return nil , errors .NewNotFound (systemv1beta1 .Resource ("capturedPacket " ), name )
171
165
}
172
166
return r .cache , nil
173
167
}
@@ -176,7 +170,7 @@ func (r *samplingPacketsREST) Get(_ context.Context, name string, _ *metav1.GetO
176
170
// collecting. It only allows querying the resource whose name is equal to the mode.
177
171
func (r * samplingPacketsREST ) Delete (_ context.Context , name string , _ rest.ValidateObjectFunc , _ * metav1.DeleteOptions ) (runtime.Object , bool , error ) {
178
172
if name != r .mode {
179
- return nil , false , errors .NewNotFound (systemv1beta1 .Resource ("supportBundle " ), name )
173
+ return nil , false , errors .NewNotFound (systemv1beta1 .Resource ("capturedPacket " ), name )
180
174
}
181
175
r .statusLocker .Lock ()
182
176
defer r .statusLocker .Unlock ()
@@ -213,7 +207,7 @@ func (r *samplingPacketsREST) collect(ctx context.Context, dumpers ...func(strin
213
207
defer outputFile .Close ()
214
208
hashSum , err := compress .PackDir (defaultFS , basedir , outputFile )
215
209
if err != nil {
216
- return nil , fmt .Errorf ("error when packaging supportBundle : %w" , err )
210
+ return nil , fmt .Errorf ("error when packaging capturedPacket : %w" , err )
217
211
}
218
212
219
213
select {
@@ -242,31 +236,10 @@ func (r *samplingPacketsREST) collect(ctx context.Context, dumpers ...func(strin
242
236
}, nil
243
237
}
244
238
245
- func (r * samplingPacketsREST ) collectAgent (ctx context.Context , name string ) (* systemv1beta1.SupportBundle , error ) {
246
- dumper := newAgentDumper (defaultFS , defaultExecutor , r .ovsCtlClient , r .aq , r .npq , since , r .v4Enabled , r .v6Enabled )
247
- return r .collect (
248
- ctx ,
249
- dumper .DumpLog ,
250
- dumper .DumpHostNetworkInfo ,
251
- dumper .DumpFlows ,
252
- dumper .DumpNetworkPolicyResources ,
253
- dumper .DumpAgentInfo ,
254
- dumper .DumpHeapPprof ,
255
- dumper .DumpOVSPorts ,
256
- dumper .DumpMemberlist ,
257
- )
239
+ func (r * samplingPacketsREST ) collectAgent (ctx context.Context , name string ) (* systemv1beta1.CapturedPacket , error ) {
240
+ return r .collect (ctx )
258
241
}
259
242
260
- func (r * samplingPacketsREST ) collectController (ctx context.Context , since string ) (* systemv1beta1.SupportBundle , error ) {
261
- dumper := support .NewControllerDumper (defaultFS , defaultExecutor , since )
262
- return r .collect (
263
- ctx ,
264
- dumper .DumpLog ,
265
- dumper .DumpNetworkPolicyResources ,
266
- dumper .DumpControllerInfo ,
267
- dumper .DumpHeapPprof ,
268
- )
269
- }
270
243
271
244
func (r * samplingPacketsREST ) clean (ctx context.Context , bundlePath string , duration time.Duration ) {
272
245
select {
@@ -278,10 +251,10 @@ func (r *samplingPacketsREST) clean(ctx context.Context, bundlePath string, dura
278
251
select { // check the context again in case of cancellation when acquiring the lock.
279
252
case <- ctx .Done ():
280
253
default :
281
- if r .cache .Status == systemv1beta1 .SupportBundleStatusCollected {
282
- r .cache = & systemv1beta1.SupportBundle {
254
+ if r .cache .Status == systemv1beta1 .SamplingPacketStatusCollected {
255
+ r .cache = & systemv1beta1.CapturedPacket {
283
256
ObjectMeta : metav1.ObjectMeta {Name : r .mode },
284
- Status : systemv1beta1 .SupportBundleStatusNone ,
257
+ Status : systemv1beta1 .SamplingPacketStatusNone ,
285
258
}
286
259
}
287
260
}
@@ -298,18 +271,18 @@ var (
298
271
299
272
// downloadREST implements the REST for downloading the bundle.
300
273
type downloadREST struct {
301
- supportBundle * samplingPacketsREST
274
+ capturedPacket * samplingPacketsREST
302
275
}
303
276
304
277
func (d * downloadREST ) New () runtime.Object {
305
- return & systemv1beta1.SupportBundle {}
278
+ return & systemv1beta1.CapturedPacket {}
306
279
}
307
280
308
281
func (d * downloadREST ) Destroy () {
309
282
}
310
283
311
284
func (d * downloadREST ) Get (_ context.Context , _ string , _ * metav1.GetOptions ) (runtime.Object , error ) {
312
- return & bundleStream {d .supportBundle .cache }, nil
285
+ return & bundleStream {d .capturedPacket .cache }, nil
313
286
}
314
287
315
288
func (d * downloadREST ) ProducesMIMETypes (_ string ) []string {
@@ -326,7 +299,7 @@ var (
326
299
)
327
300
328
301
type bundleStream struct {
329
- cache * systemv1beta1.SupportBundle
302
+ cache * systemv1beta1.CapturedPacket
330
303
}
331
304
332
305
func (b * bundleStream ) GetObjectKind () schema.ObjectKind {
0 commit comments