@@ -21,17 +21,17 @@ const (
21
21
// ScopeAll means chaos works on all host
22
22
ScopeAll = "all"
23
23
24
- // ModeError means return error for DNS request
25
- ModeError = "error"
26
- // ModeRandom means return random IP for DNS request
27
- ModeRandom = "random"
24
+ // ActionError means return error for DNS request
25
+ ActionError = "error"
26
+ // ActionRandom means return random IP for DNS request
27
+ ActionRandom = "random"
28
28
)
29
29
30
30
// PodInfo saves some information for pod
31
31
type PodInfo struct {
32
32
Namespace string
33
33
Name string
34
- Mode string
34
+ Action string
35
35
Scope string
36
36
IP string
37
37
LastUpdateTime time.Time
@@ -49,7 +49,7 @@ func (p *PodInfo) IsOverdue() bool {
49
49
}
50
50
51
51
func (k Kubernetes ) chaosDNS (ctx context.Context , w dns.ResponseWriter , r * dns.Msg , state request.Request , podInfo * PodInfo ) (int , error ) {
52
- if podInfo .Mode == ModeError {
52
+ if podInfo .Action == ActionError {
53
53
return dns .RcodeServerFailure , nil
54
54
}
55
55
@@ -165,9 +165,11 @@ func (k Kubernetes) needChaos(podInfo *PodInfo, state request.Request) bool {
165
165
return true
166
166
}
167
167
168
+ // FIXME: this function is wrong, need to fix it
168
169
qname := state .QName ()
169
170
zone := plugin .Zones (k .Zones ).Matches (qname )
170
171
172
+ log .Infof ("qname: %s, zone: %s, scope: %s, zones: %s" , qname , zone , podInfo .Scope , k .Zones )
171
173
if zone == "" {
172
174
// is outer host
173
175
if podInfo .Scope == ScopeOuter {
@@ -184,5 +186,10 @@ func (k Kubernetes) needChaos(podInfo *PodInfo, state request.Request) bool {
184
186
}
185
187
186
188
func (k Kubernetes ) getPodFromCluster (namespace , name string ) (* api.Pod , error ) {
187
- return k .Client .Pods (namespace ).Get (context .Background (), name , meta.GetOptions {})
189
+ pods := k .Client .Pods (namespace )
190
+ if pods == nil {
191
+ log .Infof ("getPodFromCluster, pods is nil" )
192
+ return nil , nil
193
+ }
194
+ return pods .Get (context .Background (), name , meta.GetOptions {})
188
195
}
0 commit comments