id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
162,400
cilium/cilium
pkg/datapath/maps/map.go
CollectStaleMapGarbage
func CollectStaleMapGarbage() { if err := filepath.Walk(bpf.MapPrefixPath(), globalSweeper.walk); err != nil { log.WithError(err).Warn("Error while scanning for stale maps") } }
go
func CollectStaleMapGarbage() { if err := filepath.Walk(bpf.MapPrefixPath(), globalSweeper.walk); err != nil { log.WithError(err).Warn("Error while scanning for stale maps") } }
[ "func", "CollectStaleMapGarbage", "(", ")", "{", "if", "err", ":=", "filepath", ".", "Walk", "(", "bpf", ".", "MapPrefixPath", "(", ")", ",", "globalSweeper", ".", "walk", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", "...
// CollectStaleMapGarbage cleans up stale content in the BPF maps from the // datapath.
[ "CollectStaleMapGarbage", "cleans", "up", "stale", "content", "in", "the", "BPF", "maps", "from", "the", "datapath", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/maps/map.go#L153-L157
162,401
cilium/cilium
pkg/datapath/maps/map.go
RemoveDisabledMaps
func RemoveDisabledMaps() { maps := []string{} if !option.Config.EnableIPv6 { maps = append(maps, []string{ "cilium_ct6_global", "cilium_ct_any6_global", "cilium_lb6_reverse_nat", "cilium_lb6_rr_seq", "cilium_lb6_services", "cilium_snat_v6_external", "cilium_proxy6"}...) } if !option.Config.EnableIPv4 { maps = append(maps, []string{ "cilium_ct4_global", "cilium_ct_any4_global", "cilium_lb4_reverse_nat", "cilium_lb4_rr_seq", "cilium_lb4_services", "cilium_snat_v4_external", "cilium_proxy4"}...) } for _, m := range maps { p := path.Join(bpf.MapPrefixPath(), m) if _, err := os.Stat(p); !os.IsNotExist(err) { globalSweeper.removeMapPath(p) } } }
go
func RemoveDisabledMaps() { maps := []string{} if !option.Config.EnableIPv6 { maps = append(maps, []string{ "cilium_ct6_global", "cilium_ct_any6_global", "cilium_lb6_reverse_nat", "cilium_lb6_rr_seq", "cilium_lb6_services", "cilium_snat_v6_external", "cilium_proxy6"}...) } if !option.Config.EnableIPv4 { maps = append(maps, []string{ "cilium_ct4_global", "cilium_ct_any4_global", "cilium_lb4_reverse_nat", "cilium_lb4_rr_seq", "cilium_lb4_services", "cilium_snat_v4_external", "cilium_proxy4"}...) } for _, m := range maps { p := path.Join(bpf.MapPrefixPath(), m) if _, err := os.Stat(p); !os.IsNotExist(err) { globalSweeper.removeMapPath(p) } } }
[ "func", "RemoveDisabledMaps", "(", ")", "{", "maps", ":=", "[", "]", "string", "{", "}", "\n\n", "if", "!", "option", ".", "Config", ".", "EnableIPv6", "{", "maps", "=", "append", "(", "maps", ",", "[", "]", "string", "{", "\"", "\"", ",", "\"", ...
// RemoveDisabledMaps removes BPF maps in the filesystem for features that have // been disabled. The maps may still be in use in which case they will continue // to live until the BPF program using them is being replaced.
[ "RemoveDisabledMaps", "removes", "BPF", "maps", "in", "the", "filesystem", "for", "features", "that", "have", "been", "disabled", ".", "The", "maps", "may", "still", "be", "in", "use", "in", "which", "case", "they", "will", "continue", "to", "live", "until",...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/maps/map.go#L162-L193
162,402
cilium/cilium
api/v1/server/restapi/policy/get_identity_endpoints_responses.go
WithPayload
func (o *GetIdentityEndpointsOK) WithPayload(payload []*models.IdentityEndpoints) *GetIdentityEndpointsOK { o.Payload = payload return o }
go
func (o *GetIdentityEndpointsOK) WithPayload(payload []*models.IdentityEndpoints) *GetIdentityEndpointsOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityEndpointsOK", ")", "WithPayload", "(", "payload", "[", "]", "*", "models", ".", "IdentityEndpoints", ")", "*", "GetIdentityEndpointsOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity endpoints o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "endpoints", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_endpoints_responses.go#L38-L41
162,403
cilium/cilium
pkg/datapath/linux/linux_defaults/mark.go
GetMagicProxyMark
func GetMagicProxyMark(isIngress bool, identity int) int { var mark int if isIngress { mark = MagicMarkIngress } else { mark = MagicMarkEgress } if identity != 0 { mark |= (identity >> 16) & 0xFF mark |= (identity & 0xFFFF) << 16 } return mark }
go
func GetMagicProxyMark(isIngress bool, identity int) int { var mark int if isIngress { mark = MagicMarkIngress } else { mark = MagicMarkEgress } if identity != 0 { mark |= (identity >> 16) & 0xFF mark |= (identity & 0xFFFF) << 16 } return mark }
[ "func", "GetMagicProxyMark", "(", "isIngress", "bool", ",", "identity", "int", ")", "int", "{", "var", "mark", "int", "\n\n", "if", "isIngress", "{", "mark", "=", "MagicMarkIngress", "\n", "}", "else", "{", "mark", "=", "MagicMarkEgress", "\n", "}", "\n\n"...
// getMagicMark returns the magic marker with which each packet must be marked. // The mark is different depending on whether the proxy is injected at ingress // or egress.
[ "getMagicMark", "returns", "the", "magic", "marker", "with", "which", "each", "packet", "must", "be", "marked", ".", "The", "mark", "is", "different", "depending", "on", "whether", "the", "proxy", "is", "injected", "at", "ingress", "or", "egress", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/linux_defaults/mark.go#L86-L101
162,404
cilium/cilium
api/v1/models/controller_status.go
Validate
func (m *ControllerStatus) Validate(formats strfmt.Registry) error { var res []error if err := m.validateConfiguration(formats); err != nil { res = append(res, err) } if err := m.validateStatus(formats); err != nil { res = append(res, err) } if err := m.validateUUID(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *ControllerStatus) Validate(formats strfmt.Registry) error { var res []error if err := m.validateConfiguration(formats); err != nil { res = append(res, err) } if err := m.validateStatus(formats); err != nil { res = append(res, err) } if err := m.validateUUID(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "ControllerStatus", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateConfiguration", "(", "formats", ")", ";", "err", "!...
// Validate validates this controller status
[ "Validate", "validates", "this", "controller", "status" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/controller_status.go#L36-L55
162,405
cilium/cilium
pkg/datapath/linux/route/route.go
LogFields
func (r *Route) LogFields() logrus.Fields { return logrus.Fields{ "prefix": r.Prefix, "nexthop": r.Nexthop, "local": r.Local, logfields.Interface: r.Device, } }
go
func (r *Route) LogFields() logrus.Fields { return logrus.Fields{ "prefix": r.Prefix, "nexthop": r.Nexthop, "local": r.Local, logfields.Interface: r.Device, } }
[ "func", "(", "r", "*", "Route", ")", "LogFields", "(", ")", "logrus", ".", "Fields", "{", "return", "logrus", ".", "Fields", "{", "\"", "\"", ":", "r", ".", "Prefix", ",", "\"", "\"", ":", "r", ".", "Nexthop", ",", "\"", "\"", ":", "r", ".", ...
// LogFields returns the route attributes as logrus.Fields map
[ "LogFields", "returns", "the", "route", "attributes", "as", "logrus", ".", "Fields", "map" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/route/route.go#L40-L47
162,406
cilium/cilium
pkg/datapath/loader/compile.go
progLDFlags
func progLDFlags(prog *progInfo, dir *directoryInfo) []string { return []string{ fmt.Sprintf("-filetype=%s", prog.OutputType), "-o", path.Join(dir.Output, prog.Output), } }
go
func progLDFlags(prog *progInfo, dir *directoryInfo) []string { return []string{ fmt.Sprintf("-filetype=%s", prog.OutputType), "-o", path.Join(dir.Output, prog.Output), } }
[ "func", "progLDFlags", "(", "prog", "*", "progInfo", ",", "dir", "*", "directoryInfo", ")", "[", "]", "string", "{", "return", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "prog", ".", "OutputType", ")", ",", "\"", "\"", ",...
// progLDFlags determines the loader flags for the specified prog and paths.
[ "progLDFlags", "determines", "the", "loader", "flags", "for", "the", "specified", "prog", "and", "paths", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L109-L114
162,407
cilium/cilium
pkg/datapath/loader/compile.go
prepareCmdPipes
func prepareCmdPipes(cmd *exec.Cmd) (io.ReadCloser, io.ReadCloser, error) { stdout, err := cmd.StdoutPipe() if err != nil { return nil, nil, fmt.Errorf("Failed to get stdout pipe: %s", err) } stderr, err := cmd.StderrPipe() if err != nil { stdout.Close() return nil, nil, fmt.Errorf("Failed to get stderr pipe: %s", err) } return stdout, stderr, nil }
go
func prepareCmdPipes(cmd *exec.Cmd) (io.ReadCloser, io.ReadCloser, error) { stdout, err := cmd.StdoutPipe() if err != nil { return nil, nil, fmt.Errorf("Failed to get stdout pipe: %s", err) } stderr, err := cmd.StderrPipe() if err != nil { stdout.Close() return nil, nil, fmt.Errorf("Failed to get stderr pipe: %s", err) } return stdout, stderr, nil }
[ "func", "prepareCmdPipes", "(", "cmd", "*", "exec", ".", "Cmd", ")", "(", "io", ".", "ReadCloser", ",", "io", ".", "ReadCloser", ",", "error", ")", "{", "stdout", ",", "err", ":=", "cmd", ".", "StdoutPipe", "(", ")", "\n", "if", "err", "!=", "nil",...
// prepareCmdPipes attaches pipes to the stdout and stderr of the specified // command, and returns the stdout, stderr, and any error that may have // occurred while creating the pipes.
[ "prepareCmdPipes", "attaches", "pipes", "to", "the", "stdout", "and", "stderr", "of", "the", "specified", "command", "and", "returns", "the", "stdout", "stderr", "and", "any", "error", "that", "may", "have", "occurred", "while", "creating", "the", "pipes", "."...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L119-L132
162,408
cilium/cilium
pkg/datapath/loader/compile.go
compileAndLink
func compileAndLink(ctx context.Context, prog *progInfo, dir *directoryInfo, debug bool, compileArgs ...string) error { compileCmd, cancelCompile := exec.WithCancel(ctx, compiler, compileArgs...) defer cancelCompile() compilerStdout, compilerStderr, err := prepareCmdPipes(compileCmd) if err != nil { return err } linkArgs := make([]string, 0, 8) if debug { linkArgs = append(linkArgs, "-mattr=dwarfris") } linkArgs = append(linkArgs, standardLDFlags...) linkArgs = append(linkArgs, progLDFlags(prog, dir)...) linkCmd := exec.CommandContext(ctx, linker, linkArgs...) linkCmd.Stdin = compilerStdout if err := compileCmd.Start(); err != nil { return fmt.Errorf("Failed to start command %s: %s", compileCmd.Args, err) } var compileOut []byte /* Ignoring the output here because pkg/command/exec will log it. */ _, err = linkCmd.CombinedOutput(log, true) if err == nil { compileOut, _ = ioutil.ReadAll(compilerStderr) err = compileCmd.Wait() } else { cancelCompile() } if err != nil { err = fmt.Errorf("Failed to compile %s: %s", prog.Output, err) log.WithFields(logrus.Fields{ "compiler-pid": pidFromProcess(compileCmd.Process), "linker-pid": pidFromProcess(linkCmd.Process), }).Error(err) if compileOut != nil { scopedLog := log.Warn if debug { scopedLog = log.Debug } scanner := bufio.NewScanner(bytes.NewReader(compileOut)) for scanner.Scan() { scopedLog(scanner.Text()) } } } return err }
go
func compileAndLink(ctx context.Context, prog *progInfo, dir *directoryInfo, debug bool, compileArgs ...string) error { compileCmd, cancelCompile := exec.WithCancel(ctx, compiler, compileArgs...) defer cancelCompile() compilerStdout, compilerStderr, err := prepareCmdPipes(compileCmd) if err != nil { return err } linkArgs := make([]string, 0, 8) if debug { linkArgs = append(linkArgs, "-mattr=dwarfris") } linkArgs = append(linkArgs, standardLDFlags...) linkArgs = append(linkArgs, progLDFlags(prog, dir)...) linkCmd := exec.CommandContext(ctx, linker, linkArgs...) linkCmd.Stdin = compilerStdout if err := compileCmd.Start(); err != nil { return fmt.Errorf("Failed to start command %s: %s", compileCmd.Args, err) } var compileOut []byte /* Ignoring the output here because pkg/command/exec will log it. */ _, err = linkCmd.CombinedOutput(log, true) if err == nil { compileOut, _ = ioutil.ReadAll(compilerStderr) err = compileCmd.Wait() } else { cancelCompile() } if err != nil { err = fmt.Errorf("Failed to compile %s: %s", prog.Output, err) log.WithFields(logrus.Fields{ "compiler-pid": pidFromProcess(compileCmd.Process), "linker-pid": pidFromProcess(linkCmd.Process), }).Error(err) if compileOut != nil { scopedLog := log.Warn if debug { scopedLog = log.Debug } scanner := bufio.NewScanner(bytes.NewReader(compileOut)) for scanner.Scan() { scopedLog(scanner.Text()) } } } return err }
[ "func", "compileAndLink", "(", "ctx", "context", ".", "Context", ",", "prog", "*", "progInfo", ",", "dir", "*", "directoryInfo", ",", "debug", "bool", ",", "compileArgs", "...", "string", ")", "error", "{", "compileCmd", ",", "cancelCompile", ":=", "exec", ...
// compileAndLink links the specified program from the specified path to the // intermediate representation, to the output specified in the prog's info.
[ "compileAndLink", "links", "the", "specified", "program", "from", "the", "specified", "path", "to", "the", "intermediate", "representation", "to", "the", "output", "specified", "in", "the", "prog", "s", "info", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L144-L193
162,409
cilium/cilium
pkg/datapath/loader/compile.go
progCFlags
func progCFlags(prog *progInfo, dir *directoryInfo) []string { var output string if prog.OutputType == outputSource { output = path.Join(dir.Output, prog.Output) } else { output = "-" // stdout } return append(testIncludes, fmt.Sprintf("-I%s", path.Join(dir.Runtime, "globals")), fmt.Sprintf("-I%s", dir.State), fmt.Sprintf("-I%s", dir.Library), fmt.Sprintf("-I%s", path.Join(dir.Library, "include")), "-c", path.Join(dir.Library, prog.Source), "-o", output, ) }
go
func progCFlags(prog *progInfo, dir *directoryInfo) []string { var output string if prog.OutputType == outputSource { output = path.Join(dir.Output, prog.Output) } else { output = "-" // stdout } return append(testIncludes, fmt.Sprintf("-I%s", path.Join(dir.Runtime, "globals")), fmt.Sprintf("-I%s", dir.State), fmt.Sprintf("-I%s", dir.Library), fmt.Sprintf("-I%s", path.Join(dir.Library, "include")), "-c", path.Join(dir.Library, prog.Source), "-o", output, ) }
[ "func", "progCFlags", "(", "prog", "*", "progInfo", ",", "dir", "*", "directoryInfo", ")", "[", "]", "string", "{", "var", "output", "string", "\n\n", "if", "prog", ".", "OutputType", "==", "outputSource", "{", "output", "=", "path", ".", "Join", "(", ...
// progLDFlags determines the compiler flags for the specified prog and paths.
[ "progLDFlags", "determines", "the", "compiler", "flags", "for", "the", "specified", "prog", "and", "paths", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L196-L213
162,410
cilium/cilium
pkg/datapath/loader/compile.go
compile
func compile(ctx context.Context, prog *progInfo, dir *directoryInfo, debug bool) (err error) { args := make([]string, 0, 16) if prog.OutputType == outputSource { args = append(args, "-E") // Preprocessor } else { args = append(args, "-emit-llvm") if debug { args = append(args, "-g") } } args = append(args, standardCFlags...) args = append(args, progCFlags(prog, dir)...) // Compilation is split between two exec calls. First clang generates // LLVM bitcode and then later llc compiles it to byte-code. log.WithFields(logrus.Fields{ "target": compiler, "args": args, }).Debug("Launching compiler") if prog.OutputType == outputSource { compileCmd := exec.CommandContext(ctx, compiler, args...) _, err = compileCmd.CombinedOutput(log, debug) } else { switch prog.OutputType { case outputObject: err = compileAndLink(ctx, prog, dir, debug, args...) case outputAssembly: err = compileAndLink(ctx, prog, dir, false, args...) default: log.Fatalf("Unhandled progInfo.OutputType %s", prog.OutputType) } } return err }
go
func compile(ctx context.Context, prog *progInfo, dir *directoryInfo, debug bool) (err error) { args := make([]string, 0, 16) if prog.OutputType == outputSource { args = append(args, "-E") // Preprocessor } else { args = append(args, "-emit-llvm") if debug { args = append(args, "-g") } } args = append(args, standardCFlags...) args = append(args, progCFlags(prog, dir)...) // Compilation is split between two exec calls. First clang generates // LLVM bitcode and then later llc compiles it to byte-code. log.WithFields(logrus.Fields{ "target": compiler, "args": args, }).Debug("Launching compiler") if prog.OutputType == outputSource { compileCmd := exec.CommandContext(ctx, compiler, args...) _, err = compileCmd.CombinedOutput(log, debug) } else { switch prog.OutputType { case outputObject: err = compileAndLink(ctx, prog, dir, debug, args...) case outputAssembly: err = compileAndLink(ctx, prog, dir, false, args...) default: log.Fatalf("Unhandled progInfo.OutputType %s", prog.OutputType) } } return err }
[ "func", "compile", "(", "ctx", "context", ".", "Context", ",", "prog", "*", "progInfo", ",", "dir", "*", "directoryInfo", ",", "debug", "bool", ")", "(", "err", "error", ")", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "16", ...
// compile and link a program.
[ "compile", "and", "link", "a", "program", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L216-L250
162,411
cilium/cilium
pkg/datapath/loader/compile.go
Compile
func Compile(ctx context.Context, src string, out string) error { debug := option.Config.BPFCompilationDebug prog := progInfo{ Source: src, Output: out, OutputType: outputObject, } dirs := directoryInfo{ Library: option.Config.BpfDir, Runtime: option.Config.StateDir, Output: option.Config.StateDir, State: option.Config.StateDir, } return compile(ctx, &prog, &dirs, debug) }
go
func Compile(ctx context.Context, src string, out string) error { debug := option.Config.BPFCompilationDebug prog := progInfo{ Source: src, Output: out, OutputType: outputObject, } dirs := directoryInfo{ Library: option.Config.BpfDir, Runtime: option.Config.StateDir, Output: option.Config.StateDir, State: option.Config.StateDir, } return compile(ctx, &prog, &dirs, debug) }
[ "func", "Compile", "(", "ctx", "context", ".", "Context", ",", "src", "string", ",", "out", "string", ")", "error", "{", "debug", ":=", "option", ".", "Config", ".", "BPFCompilationDebug", "\n", "prog", ":=", "progInfo", "{", "Source", ":", "src", ",", ...
// Compile compiles a BPF program generating an object file.
[ "Compile", "compiles", "a", "BPF", "program", "generating", "an", "object", "file", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L295-L309
162,412
cilium/cilium
pkg/datapath/loader/compile.go
compileTemplate
func compileTemplate(ctx context.Context, out string) error { dirs := directoryInfo{ Library: option.Config.BpfDir, Runtime: option.Config.StateDir, Output: out, State: out, } return compileDatapath(ctx, &dirs, option.Config.BPFCompilationDebug, log) }
go
func compileTemplate(ctx context.Context, out string) error { dirs := directoryInfo{ Library: option.Config.BpfDir, Runtime: option.Config.StateDir, Output: out, State: out, } return compileDatapath(ctx, &dirs, option.Config.BPFCompilationDebug, log) }
[ "func", "compileTemplate", "(", "ctx", "context", ".", "Context", ",", "out", "string", ")", "error", "{", "dirs", ":=", "directoryInfo", "{", "Library", ":", "option", ".", "Config", ".", "BpfDir", ",", "Runtime", ":", "option", ".", "Config", ".", "Sta...
// compileTemplate compiles a BPF program generating a template object file.
[ "compileTemplate", "compiles", "a", "BPF", "program", "generating", "a", "template", "object", "file", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/compile.go#L312-L320
162,413
cilium/cilium
pkg/envoy/xds/set.go
AddResourceVersionObserver
func (s *BaseObservableResourceSource) AddResourceVersionObserver(observer ResourceVersionObserver) { s.locker.Lock() defer s.locker.Unlock() s.observers[observer] = struct{}{} }
go
func (s *BaseObservableResourceSource) AddResourceVersionObserver(observer ResourceVersionObserver) { s.locker.Lock() defer s.locker.Unlock() s.observers[observer] = struct{}{} }
[ "func", "(", "s", "*", "BaseObservableResourceSource", ")", "AddResourceVersionObserver", "(", "observer", "ResourceVersionObserver", ")", "{", "s", ".", "locker", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "locker", ".", "Unlock", "(", ")", "\n\n", "s"...
// AddResourceVersionObserver registers an observer to be notified of new // resource version.
[ "AddResourceVersionObserver", "registers", "an", "observer", "to", "be", "notified", "of", "new", "resource", "version", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/set.go#L164-L169
162,414
cilium/cilium
pkg/envoy/xds/set.go
RemoveResourceVersionObserver
func (s *BaseObservableResourceSource) RemoveResourceVersionObserver(observer ResourceVersionObserver) { s.locker.Lock() defer s.locker.Unlock() delete(s.observers, observer) }
go
func (s *BaseObservableResourceSource) RemoveResourceVersionObserver(observer ResourceVersionObserver) { s.locker.Lock() defer s.locker.Unlock() delete(s.observers, observer) }
[ "func", "(", "s", "*", "BaseObservableResourceSource", ")", "RemoveResourceVersionObserver", "(", "observer", "ResourceVersionObserver", ")", "{", "s", ".", "locker", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "locker", ".", "Unlock", "(", ")", "\n\n", ...
// RemoveResourceVersionObserver unregisters an observer that was previously // registered by calling AddResourceVersionObserver.
[ "RemoveResourceVersionObserver", "unregisters", "an", "observer", "that", "was", "previously", "registered", "by", "calling", "AddResourceVersionObserver", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/set.go#L173-L178
162,415
cilium/cilium
pkg/envoy/xds/set.go
NotifyNewResourceVersionRLocked
func (s *BaseObservableResourceSource) NotifyNewResourceVersionRLocked(typeURL string, version uint64) { for o := range s.observers { o.HandleNewResourceVersion(typeURL, version) } }
go
func (s *BaseObservableResourceSource) NotifyNewResourceVersionRLocked(typeURL string, version uint64) { for o := range s.observers { o.HandleNewResourceVersion(typeURL, version) } }
[ "func", "(", "s", "*", "BaseObservableResourceSource", ")", "NotifyNewResourceVersionRLocked", "(", "typeURL", "string", ",", "version", "uint64", ")", "{", "for", "o", ":=", "range", "s", ".", "observers", "{", "o", ".", "HandleNewResourceVersion", "(", "typeUR...
// NotifyNewResourceVersionRLocked notifies registered observers that a new version of // the resources of the given type is available. // This function MUST be called with locker's lock acquired.
[ "NotifyNewResourceVersionRLocked", "notifies", "registered", "observers", "that", "a", "new", "version", "of", "the", "resources", "of", "the", "given", "type", "is", "available", ".", "This", "function", "MUST", "be", "called", "with", "locker", "s", "lock", "a...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/set.go#L183-L187
162,416
cilium/cilium
api/v1/models/trace_to.go
Validate
func (m *TraceTo) Validate(formats strfmt.Registry) error { var res []error if err := m.validateDports(formats); err != nil { res = append(res, err) } if err := m.validateLabels(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *TraceTo) Validate(formats strfmt.Registry) error { var res []error if err := m.validateDports(formats); err != nil { res = append(res, err) } if err := m.validateLabels(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "TraceTo", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateDports", "(", "formats", ")", ";", "err", "!=", "nil", "...
// Validate validates this trace to
[ "Validate", "validates", "this", "trace", "to" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/trace_to.go#L31-L46
162,417
cilium/cilium
api/v1/client/service/delete_service_id_parameters.go
WithTimeout
func (o *DeleteServiceIDParams) WithTimeout(timeout time.Duration) *DeleteServiceIDParams { o.SetTimeout(timeout) return o }
go
func (o *DeleteServiceIDParams) WithTimeout(timeout time.Duration) *DeleteServiceIDParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "DeleteServiceIDParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "DeleteServiceIDParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the delete service ID params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "delete", "service", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/delete_service_id_parameters.go#L77-L80
162,418
cilium/cilium
api/v1/client/service/delete_service_id_parameters.go
WithContext
func (o *DeleteServiceIDParams) WithContext(ctx context.Context) *DeleteServiceIDParams { o.SetContext(ctx) return o }
go
func (o *DeleteServiceIDParams) WithContext(ctx context.Context) *DeleteServiceIDParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "DeleteServiceIDParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "DeleteServiceIDParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the delete service ID params
[ "WithContext", "adds", "the", "context", "to", "the", "delete", "service", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/delete_service_id_parameters.go#L88-L91
162,419
cilium/cilium
api/v1/client/service/delete_service_id_parameters.go
WithHTTPClient
func (o *DeleteServiceIDParams) WithHTTPClient(client *http.Client) *DeleteServiceIDParams { o.SetHTTPClient(client) return o }
go
func (o *DeleteServiceIDParams) WithHTTPClient(client *http.Client) *DeleteServiceIDParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "DeleteServiceIDParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "DeleteServiceIDParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the delete service ID params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "delete", "service", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/delete_service_id_parameters.go#L99-L102
162,420
cilium/cilium
api/v1/client/service/delete_service_id_parameters.go
WithID
func (o *DeleteServiceIDParams) WithID(id int64) *DeleteServiceIDParams { o.SetID(id) return o }
go
func (o *DeleteServiceIDParams) WithID(id int64) *DeleteServiceIDParams { o.SetID(id) return o }
[ "func", "(", "o", "*", "DeleteServiceIDParams", ")", "WithID", "(", "id", "int64", ")", "*", "DeleteServiceIDParams", "{", "o", ".", "SetID", "(", "id", ")", "\n", "return", "o", "\n", "}" ]
// WithID adds the id to the delete service ID params
[ "WithID", "adds", "the", "id", "to", "the", "delete", "service", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/delete_service_id_parameters.go#L110-L113
162,421
cilium/cilium
pkg/controller/manager.go
UpdateController
func (m *Manager) UpdateController(name string, params ControllerParams) *Controller { start := time.Now() // ensure the callbacks are valid if params.DoFunc == nil { params.DoFunc = func(ctx context.Context) error { return undefinedDoFunc(name) } } if params.StopFunc == nil { params.StopFunc = NoopFunc } m.mutex.Lock() if m.controllers == nil { m.controllers = controllerMap{} } ctrl, exists := m.controllers[name] if exists { m.mutex.Unlock() ctrl.getLogger().Debug("Updating existing controller") ctrl.mutex.Lock() ctrl.updateParamsLocked(params) ctrl.mutex.Unlock() // Notify the goroutine of the params update. select { case ctrl.update <- struct{}{}: default: } ctrl.getLogger().Debug("Controller update time: ", time.Since(start)) } else { ctrl = &Controller{ name: name, uuid: uuid.NewUUID().String(), stop: make(chan struct{}, 0), update: make(chan struct{}, 1), terminated: make(chan struct{}, 0), } ctrl.updateParamsLocked(params) ctrl.getLogger().Debug("Starting new controller") ctrl.ctxDoFunc, ctrl.cancelDoFunc = context.WithCancel(context.Background()) m.controllers[ctrl.name] = ctrl m.mutex.Unlock() globalStatus.mutex.Lock() globalStatus.controllers[ctrl.uuid] = ctrl globalStatus.mutex.Unlock() go ctrl.runController() } return ctrl }
go
func (m *Manager) UpdateController(name string, params ControllerParams) *Controller { start := time.Now() // ensure the callbacks are valid if params.DoFunc == nil { params.DoFunc = func(ctx context.Context) error { return undefinedDoFunc(name) } } if params.StopFunc == nil { params.StopFunc = NoopFunc } m.mutex.Lock() if m.controllers == nil { m.controllers = controllerMap{} } ctrl, exists := m.controllers[name] if exists { m.mutex.Unlock() ctrl.getLogger().Debug("Updating existing controller") ctrl.mutex.Lock() ctrl.updateParamsLocked(params) ctrl.mutex.Unlock() // Notify the goroutine of the params update. select { case ctrl.update <- struct{}{}: default: } ctrl.getLogger().Debug("Controller update time: ", time.Since(start)) } else { ctrl = &Controller{ name: name, uuid: uuid.NewUUID().String(), stop: make(chan struct{}, 0), update: make(chan struct{}, 1), terminated: make(chan struct{}, 0), } ctrl.updateParamsLocked(params) ctrl.getLogger().Debug("Starting new controller") ctrl.ctxDoFunc, ctrl.cancelDoFunc = context.WithCancel(context.Background()) m.controllers[ctrl.name] = ctrl m.mutex.Unlock() globalStatus.mutex.Lock() globalStatus.controllers[ctrl.uuid] = ctrl globalStatus.mutex.Unlock() go ctrl.runController() } return ctrl }
[ "func", "(", "m", "*", "Manager", ")", "UpdateController", "(", "name", "string", ",", "params", "ControllerParams", ")", "*", "Controller", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "// ensure the callbacks are valid", "if", "params", ".", "...
// UpdateController installs or updates a controller in the manager. A // controller is identified by its name. If a controller with the name already // exists, the controller will be shut down and replaced with the provided // controller. Updating a controller will cause the DoFunc to be run // immediately regardless of any previous conditions. It will also cause any // statistics to be reset.
[ "UpdateController", "installs", "or", "updates", "a", "controller", "in", "the", "manager", ".", "A", "controller", "is", "identified", "by", "its", "name", ".", "If", "a", "controller", "with", "the", "name", "already", "exists", "the", "controller", "will", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L58-L116
162,422
cilium/cilium
pkg/controller/manager.go
RemoveController
func (m *Manager) RemoveController(name string) error { _, err := m.removeAndReturnController(name) return err }
go
func (m *Manager) RemoveController(name string) error { _, err := m.removeAndReturnController(name) return err }
[ "func", "(", "m", "*", "Manager", ")", "RemoveController", "(", "name", "string", ")", "error", "{", "_", ",", "err", ":=", "m", ".", "removeAndReturnController", "(", "name", ")", "\n", "return", "err", "\n", "}" ]
// RemoveController stops and removes a controller from the manager. If DoFunc // is currently running, DoFunc is allowed to complete in the background.
[ "RemoveController", "stops", "and", "removes", "a", "controller", "from", "the", "manager", ".", "If", "DoFunc", "is", "currently", "running", "DoFunc", "is", "allowed", "to", "complete", "in", "the", "background", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L160-L163
162,423
cilium/cilium
pkg/controller/manager.go
TerminationChannel
func (m *Manager) TerminationChannel(name string) chan struct{} { if c := m.lookup(name); c != nil { return c.terminated } c := make(chan struct{}, 0) close(c) return c }
go
func (m *Manager) TerminationChannel(name string) chan struct{} { if c := m.lookup(name); c != nil { return c.terminated } c := make(chan struct{}, 0) close(c) return c }
[ "func", "(", "m", "*", "Manager", ")", "TerminationChannel", "(", "name", "string", ")", "chan", "struct", "{", "}", "{", "if", "c", ":=", "m", ".", "lookup", "(", "name", ")", ";", "c", "!=", "nil", "{", "return", "c", ".", "terminated", "\n", "...
// TerminationChannel returns a channel that is closed after the controller has // been terminated
[ "TerminationChannel", "returns", "a", "channel", "that", "is", "closed", "after", "the", "controller", "has", "been", "terminated" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L178-L186
162,424
cilium/cilium
pkg/controller/manager.go
RemoveAllAndWait
func (m *Manager) RemoveAllAndWait() { ctrls := m.removeAll() for _, ctrl := range ctrls { <-ctrl.terminated } }
go
func (m *Manager) RemoveAllAndWait() { ctrls := m.removeAll() for _, ctrl := range ctrls { <-ctrl.terminated } }
[ "func", "(", "m", "*", "Manager", ")", "RemoveAllAndWait", "(", ")", "{", "ctrls", ":=", "m", ".", "removeAll", "(", ")", "\n", "for", "_", ",", "ctrl", ":=", "range", "ctrls", "{", "<-", "ctrl", ".", "terminated", "\n", "}", "\n", "}" ]
// RemoveAllAndWait stops and removes all controllers of the manager and then // waits for all controllers to exit
[ "RemoveAllAndWait", "stops", "and", "removes", "all", "controllers", "of", "the", "manager", "and", "then", "waits", "for", "all", "controllers", "to", "exit" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L213-L218
162,425
cilium/cilium
pkg/controller/manager.go
GetStatusModel
func (m *Manager) GetStatusModel() models.ControllerStatuses { // Create a copy of pointers to current controller so we can unlock the // manager mutex quickly again controllers := controllerMap{} m.mutex.RLock() for key, c := range m.controllers { controllers[key] = c } m.mutex.RUnlock() statuses := models.ControllerStatuses{} for _, c := range controllers { statuses = append(statuses, c.GetStatusModel()) } return statuses }
go
func (m *Manager) GetStatusModel() models.ControllerStatuses { // Create a copy of pointers to current controller so we can unlock the // manager mutex quickly again controllers := controllerMap{} m.mutex.RLock() for key, c := range m.controllers { controllers[key] = c } m.mutex.RUnlock() statuses := models.ControllerStatuses{} for _, c := range controllers { statuses = append(statuses, c.GetStatusModel()) } return statuses }
[ "func", "(", "m", "*", "Manager", ")", "GetStatusModel", "(", ")", "models", ".", "ControllerStatuses", "{", "// Create a copy of pointers to current controller so we can unlock the", "// manager mutex quickly again", "controllers", ":=", "controllerMap", "{", "}", "\n", "m...
// GetStatusModel returns the status of all controllers as models.ControllerStatuses
[ "GetStatusModel", "returns", "the", "status", "of", "all", "controllers", "as", "models", ".", "ControllerStatuses" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L221-L237
162,426
cilium/cilium
pkg/controller/manager.go
FakeManager
func FakeManager(failingControllers int) *Manager { m := &Manager{ controllers: controllerMap{}, } for i := 0; i < failingControllers; i++ { ctrl := &Controller{ name: fmt.Sprintf("controller-%d", i), uuid: fmt.Sprintf("%d", i), stop: make(chan struct{}, 0), update: make(chan struct{}, 1), terminated: make(chan struct{}, 0), lastError: fmt.Errorf("controller failed"), failureCount: 1, consecutiveErrors: 1, } ctrl.ctxDoFunc, ctrl.cancelDoFunc = context.WithCancel(context.Background()) m.controllers[ctrl.name] = ctrl } return m }
go
func FakeManager(failingControllers int) *Manager { m := &Manager{ controllers: controllerMap{}, } for i := 0; i < failingControllers; i++ { ctrl := &Controller{ name: fmt.Sprintf("controller-%d", i), uuid: fmt.Sprintf("%d", i), stop: make(chan struct{}, 0), update: make(chan struct{}, 1), terminated: make(chan struct{}, 0), lastError: fmt.Errorf("controller failed"), failureCount: 1, consecutiveErrors: 1, } ctrl.ctxDoFunc, ctrl.cancelDoFunc = context.WithCancel(context.Background()) m.controllers[ctrl.name] = ctrl } return m }
[ "func", "FakeManager", "(", "failingControllers", "int", ")", "*", "Manager", "{", "m", ":=", "&", "Manager", "{", "controllers", ":", "controllerMap", "{", "}", ",", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "failingControllers", ";", "i", "+...
// FakeManager returns a fake controller manager with the specified number of // failing controllers. The returned manager is identical in any regard except // for internal pointers.
[ "FakeManager", "returns", "a", "fake", "controller", "manager", "with", "the", "specified", "number", "of", "failing", "controllers", ".", "The", "returned", "manager", "is", "identical", "in", "any", "regard", "except", "for", "internal", "pointers", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/manager.go#L242-L264
162,427
cilium/cilium
api/v1/health/client/cilium_health_client.go
New
func New(transport runtime.ClientTransport, formats strfmt.Registry) *CiliumHealth { // ensure nullable parameters have default if formats == nil { formats = strfmt.Default } cli := new(CiliumHealth) cli.Transport = transport cli.Connectivity = connectivity.New(transport, formats) cli.Restapi = restapi.New(transport, formats) return cli }
go
func New(transport runtime.ClientTransport, formats strfmt.Registry) *CiliumHealth { // ensure nullable parameters have default if formats == nil { formats = strfmt.Default } cli := new(CiliumHealth) cli.Transport = transport cli.Connectivity = connectivity.New(transport, formats) cli.Restapi = restapi.New(transport, formats) return cli }
[ "func", "New", "(", "transport", "runtime", ".", "ClientTransport", ",", "formats", "strfmt", ".", "Registry", ")", "*", "CiliumHealth", "{", "// ensure nullable parameters have default", "if", "formats", "==", "nil", "{", "formats", "=", "strfmt", ".", "Default",...
// New creates a new cilium health client
[ "New", "creates", "a", "new", "cilium", "health", "client" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/cilium_health_client.go#L52-L66
162,428
cilium/cilium
operator/api.go
StartServer
func StartServer(addr string, shutdownSignal <-chan struct{}) { log.Infof("Starting apiserver on address %s", addr) http.HandleFunc("/healthz", healthHandler) srv := &http.Server{Addr: addr} go func() { <-shutdownSignal if err := srv.Shutdown(context.Background()); err != nil { log.WithError(err).Error("apiserver shutdown") } }() if err := srv.ListenAndServe(); err != nil { log.WithError(err).Error("apiserver listen") } }
go
func StartServer(addr string, shutdownSignal <-chan struct{}) { log.Infof("Starting apiserver on address %s", addr) http.HandleFunc("/healthz", healthHandler) srv := &http.Server{Addr: addr} go func() { <-shutdownSignal if err := srv.Shutdown(context.Background()); err != nil { log.WithError(err).Error("apiserver shutdown") } }() if err := srv.ListenAndServe(); err != nil { log.WithError(err).Error("apiserver listen") } }
[ "func", "StartServer", "(", "addr", "string", ",", "shutdownSignal", "<-", "chan", "struct", "{", "}", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "addr", ")", "\n\n", "http", ".", "HandleFunc", "(", "\"", "\"", ",", "healthHandler", ")", "\...
// StartServer starts an api server listening on the given address.
[ "StartServer", "starts", "an", "api", "server", "listening", "on", "the", "given", "address", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/operator/api.go#L27-L44
162,429
cilium/cilium
operator/api.go
checkStatus
func checkStatus() error { if client := kvstore.Client(); client == nil { return fmt.Errorf("kvstore client not configured") } else if _, err := client.Status(); err != nil { return err } else if _, err := k8s.Client().Discovery().ServerVersion(); err != nil { return err } return nil }
go
func checkStatus() error { if client := kvstore.Client(); client == nil { return fmt.Errorf("kvstore client not configured") } else if _, err := client.Status(); err != nil { return err } else if _, err := k8s.Client().Discovery().ServerVersion(); err != nil { return err } return nil }
[ "func", "checkStatus", "(", ")", "error", "{", "if", "client", ":=", "kvstore", ".", "Client", "(", ")", ";", "client", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "else", "if", "_", ",", "err", ":=", "clien...
// checkStatus checks the connection status to the kvstore and // k8s apiserver and returns an error if any of them is unhealthy
[ "checkStatus", "checks", "the", "connection", "status", "to", "the", "kvstore", "and", "k8s", "apiserver", "and", "returns", "an", "error", "if", "any", "of", "them", "is", "unhealthy" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/operator/api.go#L63-L74
162,430
cilium/cilium
pkg/client/ipam.go
IPAMAllocate
func (c *Client) IPAMAllocate(family, owner string) (*models.IPAMResponse, error) { params := ipam.NewPostIPAMParams().WithTimeout(api.ClientTimeout) if family != "" { params.SetFamily(&family) } if owner != "" { params.SetOwner(&owner) } resp, err := c.IPAM.PostIPAM(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) IPAMAllocate(family, owner string) (*models.IPAMResponse, error) { params := ipam.NewPostIPAMParams().WithTimeout(api.ClientTimeout) if family != "" { params.SetFamily(&family) } if owner != "" { params.SetOwner(&owner) } resp, err := c.IPAM.PostIPAM(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "IPAMAllocate", "(", "family", ",", "owner", "string", ")", "(", "*", "models", ".", "IPAMResponse", ",", "error", ")", "{", "params", ":=", "ipam", ".", "NewPostIPAMParams", "(", ")", ".", "WithTimeout", "(", "api...
// IPAMAllocate allocates an IP address out of address family specific pool.
[ "IPAMAllocate", "allocates", "an", "IP", "address", "out", "of", "address", "family", "specific", "pool", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/ipam.go#L29-L45
162,431
cilium/cilium
pkg/client/ipam.go
IPAMAllocateIP
func (c *Client) IPAMAllocateIP(ip, owner string) error { params := ipam.NewPostIPAMIPParams().WithIP(ip).WithOwner(&owner).WithTimeout(api.ClientTimeout) _, err := c.IPAM.PostIPAMIP(params) return Hint(err) }
go
func (c *Client) IPAMAllocateIP(ip, owner string) error { params := ipam.NewPostIPAMIPParams().WithIP(ip).WithOwner(&owner).WithTimeout(api.ClientTimeout) _, err := c.IPAM.PostIPAMIP(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "IPAMAllocateIP", "(", "ip", ",", "owner", "string", ")", "error", "{", "params", ":=", "ipam", ".", "NewPostIPAMIPParams", "(", ")", ".", "WithIP", "(", "ip", ")", ".", "WithOwner", "(", "&", "owner", ")", ".", ...
// IPAMAllocateIP tries to allocate a particular IP address.
[ "IPAMAllocateIP", "tries", "to", "allocate", "a", "particular", "IP", "address", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/ipam.go#L48-L52
162,432
cilium/cilium
pkg/client/ipam.go
IPAMReleaseIP
func (c *Client) IPAMReleaseIP(ip string) error { params := ipam.NewDeleteIPAMIPParams().WithIP(ip).WithTimeout(api.ClientTimeout) _, err := c.IPAM.DeleteIPAMIP(params) return Hint(err) }
go
func (c *Client) IPAMReleaseIP(ip string) error { params := ipam.NewDeleteIPAMIPParams().WithIP(ip).WithTimeout(api.ClientTimeout) _, err := c.IPAM.DeleteIPAMIP(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "IPAMReleaseIP", "(", "ip", "string", ")", "error", "{", "params", ":=", "ipam", ".", "NewDeleteIPAMIPParams", "(", ")", ".", "WithIP", "(", "ip", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n...
// IPAMReleaseIP releases a IP address back to the pool.
[ "IPAMReleaseIP", "releases", "a", "IP", "address", "back", "to", "the", "pool", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/ipam.go#L55-L59
162,433
cilium/cilium
pkg/controller/controller.go
GetSuccessCount
func (c *Controller) GetSuccessCount() int { c.mutex.RLock() defer c.mutex.RUnlock() return c.successCount }
go
func (c *Controller) GetSuccessCount() int { c.mutex.RLock() defer c.mutex.RUnlock() return c.successCount }
[ "func", "(", "c", "*", "Controller", ")", "GetSuccessCount", "(", ")", "int", "{", "c", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "successCount", "\n", "}" ]
// GetSuccessCount returns the number of successful controller runs
[ "GetSuccessCount", "returns", "the", "number", "of", "successful", "controller", "runs" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L157-L162
162,434
cilium/cilium
pkg/controller/controller.go
GetFailureCount
func (c *Controller) GetFailureCount() int { c.mutex.RLock() defer c.mutex.RUnlock() return c.failureCount }
go
func (c *Controller) GetFailureCount() int { c.mutex.RLock() defer c.mutex.RUnlock() return c.failureCount }
[ "func", "(", "c", "*", "Controller", ")", "GetFailureCount", "(", ")", "int", "{", "c", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "failureCount", "\n", "}" ]
// GetFailureCount returns the number of failed controller runs
[ "GetFailureCount", "returns", "the", "number", "of", "failed", "controller", "runs" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L165-L170
162,435
cilium/cilium
pkg/controller/controller.go
GetLastError
func (c *Controller) GetLastError() error { c.mutex.RLock() defer c.mutex.RUnlock() return c.lastError }
go
func (c *Controller) GetLastError() error { c.mutex.RLock() defer c.mutex.RUnlock() return c.lastError }
[ "func", "(", "c", "*", "Controller", ")", "GetLastError", "(", ")", "error", "{", "c", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "lastError", "\n", "}" ]
// GetLastError returns the last error returned
[ "GetLastError", "returns", "the", "last", "error", "returned" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L173-L178
162,436
cilium/cilium
pkg/controller/controller.go
GetLastErrorTimestamp
func (c *Controller) GetLastErrorTimestamp() time.Time { c.mutex.RLock() defer c.mutex.RUnlock() return c.lastErrorStamp }
go
func (c *Controller) GetLastErrorTimestamp() time.Time { c.mutex.RLock() defer c.mutex.RUnlock() return c.lastErrorStamp }
[ "func", "(", "c", "*", "Controller", ")", "GetLastErrorTimestamp", "(", ")", "time", ".", "Time", "{", "c", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "lastErrorStamp"...
// GetLastErrorTimestamp returns the last error returned
[ "GetLastErrorTimestamp", "returns", "the", "last", "error", "returned" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L181-L186
162,437
cilium/cilium
pkg/controller/controller.go
updateParamsLocked
func (c *Controller) updateParamsLocked(params ControllerParams) { c.params = params maxInterval := time.Duration(option.Config.MaxControllerInterval) * time.Second if maxInterval > 0 && params.RunInterval > maxInterval { c.getLogger().Infof("Limiting interval to %s", maxInterval) c.params.RunInterval = maxInterval } }
go
func (c *Controller) updateParamsLocked(params ControllerParams) { c.params = params maxInterval := time.Duration(option.Config.MaxControllerInterval) * time.Second if maxInterval > 0 && params.RunInterval > maxInterval { c.getLogger().Infof("Limiting interval to %s", maxInterval) c.params.RunInterval = maxInterval } }
[ "func", "(", "c", "*", "Controller", ")", "updateParamsLocked", "(", "params", "ControllerParams", ")", "{", "c", ".", "params", "=", "params", "\n\n", "maxInterval", ":=", "time", ".", "Duration", "(", "option", ".", "Config", ".", "MaxControllerInterval", ...
// updateParamsLocked sets the specified controller's parameters. // // If the RunInterval exceeds ControllerMaxInterval, it will be capped.
[ "updateParamsLocked", "sets", "the", "specified", "controller", "s", "parameters", ".", "If", "the", "RunInterval", "exceeds", "ControllerMaxInterval", "it", "will", "be", "capped", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L303-L311
162,438
cilium/cilium
pkg/controller/controller.go
getLogger
func (c *Controller) getLogger() *logrus.Entry { return log.WithFields(logrus.Fields{ fieldControllerName: c.name, fieldUUID: c.uuid, }) }
go
func (c *Controller) getLogger() *logrus.Entry { return log.WithFields(logrus.Fields{ fieldControllerName: c.name, fieldUUID: c.uuid, }) }
[ "func", "(", "c", "*", "Controller", ")", "getLogger", "(", ")", "*", "logrus", ".", "Entry", "{", "return", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "fieldControllerName", ":", "c", ".", "name", ",", "fieldUUID", ":", "c", ".", "...
// logger returns a logrus object with controllerName and UUID fields.
[ "logger", "returns", "a", "logrus", "object", "with", "controllerName", "and", "UUID", "fields", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L323-L328
162,439
cilium/cilium
pkg/controller/controller.go
GetStatusModel
func (c *Controller) GetStatusModel() *models.ControllerStatus { c.mutex.RLock() defer c.mutex.RUnlock() status := &models.ControllerStatus{ Name: c.name, UUID: strfmt.UUID(c.uuid), Configuration: &models.ControllerStatusConfiguration{ ErrorRetry: !c.params.NoErrorRetry, ErrorRetryBase: strfmt.Duration(c.params.ErrorRetryBaseDuration), Interval: strfmt.Duration(c.params.RunInterval), }, Status: &models.ControllerStatusStatus{ SuccessCount: int64(c.successCount), LastSuccessTimestamp: strfmt.DateTime(c.lastSuccessStamp), FailureCount: int64(c.failureCount), LastFailureTimestamp: strfmt.DateTime(c.lastErrorStamp), ConsecutiveFailureCount: int64(c.consecutiveErrors), }, } if c.lastError != nil { status.Status.LastFailureMsg = c.lastError.Error() } return status }
go
func (c *Controller) GetStatusModel() *models.ControllerStatus { c.mutex.RLock() defer c.mutex.RUnlock() status := &models.ControllerStatus{ Name: c.name, UUID: strfmt.UUID(c.uuid), Configuration: &models.ControllerStatusConfiguration{ ErrorRetry: !c.params.NoErrorRetry, ErrorRetryBase: strfmt.Duration(c.params.ErrorRetryBaseDuration), Interval: strfmt.Duration(c.params.RunInterval), }, Status: &models.ControllerStatusStatus{ SuccessCount: int64(c.successCount), LastSuccessTimestamp: strfmt.DateTime(c.lastSuccessStamp), FailureCount: int64(c.failureCount), LastFailureTimestamp: strfmt.DateTime(c.lastErrorStamp), ConsecutiveFailureCount: int64(c.consecutiveErrors), }, } if c.lastError != nil { status.Status.LastFailureMsg = c.lastError.Error() } return status }
[ "func", "(", "c", "*", "Controller", ")", "GetStatusModel", "(", ")", "*", "models", ".", "ControllerStatus", "{", "c", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "status", ":=", "&", "...
// GetStatusModel returns a models.ControllerStatus representing the // controller's configuration & status
[ "GetStatusModel", "returns", "a", "models", ".", "ControllerStatus", "representing", "the", "controller", "s", "configuration", "&", "status" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L332-L358
162,440
cilium/cilium
pkg/controller/controller.go
recordError
func (c *Controller) recordError(err error) { c.lastError = err c.lastErrorStamp = time.Now() c.failureCount++ c.consecutiveErrors++ metrics.ControllerRuns.WithLabelValues(failure).Inc() metrics.ControllerRunsDuration.WithLabelValues(failure).Observe(c.lastDuration.Seconds()) }
go
func (c *Controller) recordError(err error) { c.lastError = err c.lastErrorStamp = time.Now() c.failureCount++ c.consecutiveErrors++ metrics.ControllerRuns.WithLabelValues(failure).Inc() metrics.ControllerRunsDuration.WithLabelValues(failure).Observe(c.lastDuration.Seconds()) }
[ "func", "(", "c", "*", "Controller", ")", "recordError", "(", "err", "error", ")", "{", "c", ".", "lastError", "=", "err", "\n", "c", ".", "lastErrorStamp", "=", "time", ".", "Now", "(", ")", "\n", "c", ".", "failureCount", "++", "\n", "c", ".", ...
// recordError updates all statistic collection variables on error // c.mutex must be held.
[ "recordError", "updates", "all", "statistic", "collection", "variables", "on", "error", "c", ".", "mutex", "must", "be", "held", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L362-L369
162,441
cilium/cilium
pkg/controller/controller.go
recordSuccess
func (c *Controller) recordSuccess() { c.lastError = nil c.lastSuccessStamp = time.Now() c.successCount++ c.consecutiveErrors = 0 metrics.ControllerRuns.WithLabelValues(success).Inc() metrics.ControllerRunsDuration.WithLabelValues(success).Observe(c.lastDuration.Seconds()) }
go
func (c *Controller) recordSuccess() { c.lastError = nil c.lastSuccessStamp = time.Now() c.successCount++ c.consecutiveErrors = 0 metrics.ControllerRuns.WithLabelValues(success).Inc() metrics.ControllerRunsDuration.WithLabelValues(success).Observe(c.lastDuration.Seconds()) }
[ "func", "(", "c", "*", "Controller", ")", "recordSuccess", "(", ")", "{", "c", ".", "lastError", "=", "nil", "\n", "c", ".", "lastSuccessStamp", "=", "time", ".", "Now", "(", ")", "\n", "c", ".", "successCount", "++", "\n", "c", ".", "consecutiveErro...
// recordSuccess updates all statistic collection variables on success // c.mutex must be held.
[ "recordSuccess", "updates", "all", "statistic", "collection", "variables", "on", "success", "c", ".", "mutex", "must", "be", "held", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/controller/controller.go#L373-L381
162,442
cilium/cilium
pkg/policy/api/cidr.go
MatchesAll
func (c *CIDR) MatchesAll() bool { for _, wildcard := range CIDRMatchAll { if *c == wildcard { return true } } return false }
go
func (c *CIDR) MatchesAll() bool { for _, wildcard := range CIDRMatchAll { if *c == wildcard { return true } } return false }
[ "func", "(", "c", "*", "CIDR", ")", "MatchesAll", "(", ")", "bool", "{", "for", "_", ",", "wildcard", ":=", "range", "CIDRMatchAll", "{", "if", "*", "c", "==", "wildcard", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", ...
// MatchesAll determines whether the CIDR matches all traffic.
[ "MatchesAll", "determines", "whether", "the", "CIDR", "matches", "all", "traffic", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/cidr.go#L33-L40
162,443
cilium/cilium
pkg/policy/api/cidr.go
GetAsEndpointSelectors
func (s CIDRSlice) GetAsEndpointSelectors() EndpointSelectorSlice { // If multiple CIDRs representing reserved:world are in this CIDRSlice, // we only have to add the EndpointSelector representing reserved:world // once. var hasWorldBeenAdded bool slice := EndpointSelectorSlice{} for _, cidr := range s { if cidr.MatchesAll() && !hasWorldBeenAdded { hasWorldBeenAdded = true slice = append(slice, ReservedEndpointSelectors[labels.IDNameWorld]) } lbl, err := cidrpkg.IPStringToLabel(string(cidr)) if err == nil { slice = append(slice, NewESFromLabels(lbl)) } // TODO: Log the error? } return slice }
go
func (s CIDRSlice) GetAsEndpointSelectors() EndpointSelectorSlice { // If multiple CIDRs representing reserved:world are in this CIDRSlice, // we only have to add the EndpointSelector representing reserved:world // once. var hasWorldBeenAdded bool slice := EndpointSelectorSlice{} for _, cidr := range s { if cidr.MatchesAll() && !hasWorldBeenAdded { hasWorldBeenAdded = true slice = append(slice, ReservedEndpointSelectors[labels.IDNameWorld]) } lbl, err := cidrpkg.IPStringToLabel(string(cidr)) if err == nil { slice = append(slice, NewESFromLabels(lbl)) } // TODO: Log the error? } return slice }
[ "func", "(", "s", "CIDRSlice", ")", "GetAsEndpointSelectors", "(", ")", "EndpointSelectorSlice", "{", "// If multiple CIDRs representing reserved:world are in this CIDRSlice,", "// we only have to add the EndpointSelector representing reserved:world", "// once.", "var", "hasWorldBeenAdde...
// GetAsEndpointSelectors returns the provided CIDR slice as a slice of // endpoint selectors
[ "GetAsEndpointSelectors", "returns", "the", "provided", "CIDR", "slice", "as", "a", "slice", "of", "endpoint", "selectors" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/cidr.go#L71-L90
162,444
cilium/cilium
pkg/policy/api/cidr.go
StringSlice
func (s CIDRSlice) StringSlice() []string { result := make([]string, 0, len(s)) for _, c := range s { result = append(result, string(c)) } return result }
go
func (s CIDRSlice) StringSlice() []string { result := make([]string, 0, len(s)) for _, c := range s { result = append(result, string(c)) } return result }
[ "func", "(", "s", "CIDRSlice", ")", "StringSlice", "(", ")", "[", "]", "string", "{", "result", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "s", ")", ")", "\n", "for", "_", ",", "c", ":=", "range", "s", "{", "result", "=...
// StringSlice returns the CIDR slice as a slice of strings.
[ "StringSlice", "returns", "the", "CIDR", "slice", "as", "a", "slice", "of", "strings", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/cidr.go#L93-L99
162,445
cilium/cilium
pkg/policy/api/cidr.go
ComputeResultantCIDRSet
func ComputeResultantCIDRSet(cidrs CIDRRuleSlice) CIDRSlice { var allResultantAllowedCIDRs CIDRSlice for _, s := range cidrs { _, allowNet, _ := net.ParseCIDR(string(s.Cidr)) var removeSubnets []*net.IPNet for _, t := range s.ExceptCIDRs { _, removeSubnet, _ := net.ParseCIDR(string(t)) removeSubnets = append(removeSubnets, removeSubnet) } resultantAllowedCIDRs, _ := ip.RemoveCIDRs([]*net.IPNet{allowNet}, removeSubnets) for _, u := range resultantAllowedCIDRs { allResultantAllowedCIDRs = append(allResultantAllowedCIDRs, CIDR(u.String())) } } return allResultantAllowedCIDRs }
go
func ComputeResultantCIDRSet(cidrs CIDRRuleSlice) CIDRSlice { var allResultantAllowedCIDRs CIDRSlice for _, s := range cidrs { _, allowNet, _ := net.ParseCIDR(string(s.Cidr)) var removeSubnets []*net.IPNet for _, t := range s.ExceptCIDRs { _, removeSubnet, _ := net.ParseCIDR(string(t)) removeSubnets = append(removeSubnets, removeSubnet) } resultantAllowedCIDRs, _ := ip.RemoveCIDRs([]*net.IPNet{allowNet}, removeSubnets) for _, u := range resultantAllowedCIDRs { allResultantAllowedCIDRs = append(allResultantAllowedCIDRs, CIDR(u.String())) } } return allResultantAllowedCIDRs }
[ "func", "ComputeResultantCIDRSet", "(", "cidrs", "CIDRRuleSlice", ")", "CIDRSlice", "{", "var", "allResultantAllowedCIDRs", "CIDRSlice", "\n", "for", "_", ",", "s", ":=", "range", "cidrs", "{", "_", ",", "allowNet", ",", "_", ":=", "net", ".", "ParseCIDR", "...
// ComputeResultantCIDRSet converts a slice of CIDRRules into a slice of // individual CIDRs. This expands the cidr defined by each CIDRRule, applies // the CIDR exceptions defined in "ExceptCIDRs", and forms a minimal set of // CIDRs that cover all of the CIDRRules. // // Assumes no error checking is necessary as CIDRRule.Sanitize already does this.
[ "ComputeResultantCIDRSet", "converts", "a", "slice", "of", "CIDRRules", "into", "a", "slice", "of", "individual", "CIDRs", ".", "This", "expands", "the", "cidr", "defined", "by", "each", "CIDRRule", "applies", "the", "CIDR", "exceptions", "defined", "in", "Excep...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/cidr.go#L119-L136
162,446
cilium/cilium
api/v1/health/server/restapi/get_healthz.go
NewGetHealthz
func NewGetHealthz(ctx *middleware.Context, handler GetHealthzHandler) *GetHealthz { return &GetHealthz{Context: ctx, Handler: handler} }
go
func NewGetHealthz(ctx *middleware.Context, handler GetHealthzHandler) *GetHealthz { return &GetHealthz{Context: ctx, Handler: handler} }
[ "func", "NewGetHealthz", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetHealthzHandler", ")", "*", "GetHealthz", "{", "return", "&", "GetHealthz", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetHealthz creates a new http.Handler for the get healthz operation
[ "NewGetHealthz", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "healthz", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/restapi/get_healthz.go#L28-L30
162,447
cilium/cilium
plugins/cilium-cni/chaining/api/api.go
Lookup
func Lookup(name string) ChainingPlugin { mutex.RLock() defer mutex.RUnlock() return chainingPlugins[name] }
go
func Lookup(name string) ChainingPlugin { mutex.RLock() defer mutex.RUnlock() return chainingPlugins[name] }
[ "func", "Lookup", "(", "name", "string", ")", "ChainingPlugin", "{", "mutex", ".", "RLock", "(", ")", "\n", "defer", "mutex", ".", "RUnlock", "(", ")", "\n\n", "return", "chainingPlugins", "[", "name", "]", "\n", "}" ]
// Lookup searches for a chaining plugin with a given name and returns it
[ "Lookup", "searches", "for", "a", "chaining", "plugin", "with", "a", "given", "name", "and", "returns", "it" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/plugins/cilium-cni/chaining/api/api.go#L68-L73
162,448
cilium/cilium
pkg/bpf/endpoint.go
NewEndpointKey
func NewEndpointKey(ip net.IP) EndpointKey { result := EndpointKey{} if ip4 := ip.To4(); ip4 != nil { result.Family = EndpointKeyIPv4 copy(result.IP[:], ip4) } else { result.Family = EndpointKeyIPv6 copy(result.IP[:], ip) } result.Key = 0 return result }
go
func NewEndpointKey(ip net.IP) EndpointKey { result := EndpointKey{} if ip4 := ip.To4(); ip4 != nil { result.Family = EndpointKeyIPv4 copy(result.IP[:], ip4) } else { result.Family = EndpointKeyIPv6 copy(result.IP[:], ip) } result.Key = 0 return result }
[ "func", "NewEndpointKey", "(", "ip", "net", ".", "IP", ")", "EndpointKey", "{", "result", ":=", "EndpointKey", "{", "}", "\n\n", "if", "ip4", ":=", "ip", ".", "To4", "(", ")", ";", "ip4", "!=", "nil", "{", "result", ".", "Family", "=", "EndpointKeyIP...
// NewEndpointKey returns an EndpointKey based on the provided IP address. The // address family is automatically detected.
[ "NewEndpointKey", "returns", "an", "EndpointKey", "based", "on", "the", "provided", "IP", "address", ".", "The", "address", "family", "is", "automatically", "detected", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/endpoint.go#L51-L64
162,449
cilium/cilium
pkg/bpf/endpoint.go
ToIP
func (k EndpointKey) ToIP() net.IP { switch k.Family { case EndpointKeyIPv4: return k.IP[:4] case EndpointKeyIPv6: return k.IP[:] } return nil }
go
func (k EndpointKey) ToIP() net.IP { switch k.Family { case EndpointKeyIPv4: return k.IP[:4] case EndpointKeyIPv6: return k.IP[:] } return nil }
[ "func", "(", "k", "EndpointKey", ")", "ToIP", "(", ")", "net", ".", "IP", "{", "switch", "k", ".", "Family", "{", "case", "EndpointKeyIPv4", ":", "return", "k", ".", "IP", "[", ":", "4", "]", "\n", "case", "EndpointKeyIPv6", ":", "return", "k", "."...
// ToIP converts the EndpointKey into a net.IP structure.
[ "ToIP", "converts", "the", "EndpointKey", "into", "a", "net", ".", "IP", "structure", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/endpoint.go#L67-L75
162,450
cilium/cilium
pkg/bpf/endpoint.go
String
func (k EndpointKey) String() string { if ip := k.ToIP(); ip != nil { return fmt.Sprintf("%s:%d", ip.String(), k.Key) } return "nil" }
go
func (k EndpointKey) String() string { if ip := k.ToIP(); ip != nil { return fmt.Sprintf("%s:%d", ip.String(), k.Key) } return "nil" }
[ "func", "(", "k", "EndpointKey", ")", "String", "(", ")", "string", "{", "if", "ip", ":=", "k", ".", "ToIP", "(", ")", ";", "ip", "!=", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ip", ".", "String", "(", ")", ",", "k"...
// String provides a string representation of the EndpointKey.
[ "String", "provides", "a", "string", "representation", "of", "the", "EndpointKey", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/endpoint.go#L78-L83
162,451
cilium/cilium
api/v1/server/restapi/endpoint/patch_endpoint_id.go
NewPatchEndpointID
func NewPatchEndpointID(ctx *middleware.Context, handler PatchEndpointIDHandler) *PatchEndpointID { return &PatchEndpointID{Context: ctx, Handler: handler} }
go
func NewPatchEndpointID(ctx *middleware.Context, handler PatchEndpointIDHandler) *PatchEndpointID { return &PatchEndpointID{Context: ctx, Handler: handler} }
[ "func", "NewPatchEndpointID", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "PatchEndpointIDHandler", ")", "*", "PatchEndpointID", "{", "return", "&", "PatchEndpointID", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}...
// NewPatchEndpointID creates a new http.Handler for the patch endpoint ID operation
[ "NewPatchEndpointID", "creates", "a", "new", "http", ".", "Handler", "for", "the", "patch", "endpoint", "ID", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/patch_endpoint_id.go#L28-L30
162,452
cilium/cilium
cilium-health/launch/launcher.go
Run
func (ch *CiliumHealth) Run() { ch.SetTarget(targetName) ch.SetArgs([]string{"-d"}) // Wait until Cilium API is available for { cli, err := ciliumPkg.NewDefaultClient() if err == nil { if _, err = cli.Daemon.GetHealthz(nil); err == nil { break } } log.WithError(err).Debugf("Cannot establish connection to local cilium instance") time.Sleep(connectRetryInterval) } for { var err error os.Remove(defaults.SockPath) ch.Launcher.Run() ch.client, err = healthPkg.NewDefaultClient() if err != nil { log.WithError(err).Infof("Cannot establish connection to local %s instance", targetName) time.Sleep(connectRetryInterval) continue } for { status := &models.Status{ State: models.StatusStateOk, } if _, err := ch.client.Restapi.GetHello(nil); err != nil { status.Msg = ciliumPkg.Hint(err).Error() status.State = models.StatusStateWarning } ch.setStatus(status) time.Sleep(statusProbeInterval) } } }
go
func (ch *CiliumHealth) Run() { ch.SetTarget(targetName) ch.SetArgs([]string{"-d"}) // Wait until Cilium API is available for { cli, err := ciliumPkg.NewDefaultClient() if err == nil { if _, err = cli.Daemon.GetHealthz(nil); err == nil { break } } log.WithError(err).Debugf("Cannot establish connection to local cilium instance") time.Sleep(connectRetryInterval) } for { var err error os.Remove(defaults.SockPath) ch.Launcher.Run() ch.client, err = healthPkg.NewDefaultClient() if err != nil { log.WithError(err).Infof("Cannot establish connection to local %s instance", targetName) time.Sleep(connectRetryInterval) continue } for { status := &models.Status{ State: models.StatusStateOk, } if _, err := ch.client.Restapi.GetHello(nil); err != nil { status.Msg = ciliumPkg.Hint(err).Error() status.State = models.StatusStateWarning } ch.setStatus(status) time.Sleep(statusProbeInterval) } } }
[ "func", "(", "ch", "*", "CiliumHealth", ")", "Run", "(", ")", "{", "ch", ".", "SetTarget", "(", "targetName", ")", "\n", "ch", ".", "SetArgs", "(", "[", "]", "string", "{", "\"", "\"", "}", ")", "\n\n", "// Wait until Cilium API is available", "for", "...
// Run launches the cilium-health daemon.
[ "Run", "launches", "the", "cilium", "-", "health", "daemon", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium-health/launch/launcher.go#L47-L87
162,453
cilium/cilium
cilium-health/launch/launcher.go
GetStatus
func (ch *CiliumHealth) GetStatus() *models.Status { ch.Mutex.RLock() status := ch.status ch.Mutex.RUnlock() return status }
go
func (ch *CiliumHealth) GetStatus() *models.Status { ch.Mutex.RLock() status := ch.status ch.Mutex.RUnlock() return status }
[ "func", "(", "ch", "*", "CiliumHealth", ")", "GetStatus", "(", ")", "*", "models", ".", "Status", "{", "ch", ".", "Mutex", ".", "RLock", "(", ")", "\n", "status", ":=", "ch", ".", "status", "\n", "ch", ".", "Mutex", ".", "RUnlock", "(", ")", "\n"...
// GetStatus returns the status of the cilium-health daemon.
[ "GetStatus", "returns", "the", "status", "of", "the", "cilium", "-", "health", "daemon", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium-health/launch/launcher.go#L90-L95
162,454
cilium/cilium
cilium-health/launch/launcher.go
setStatus
func (ch *CiliumHealth) setStatus(status *models.Status) { ch.Mutex.Lock() ch.status = status ch.Mutex.Unlock() }
go
func (ch *CiliumHealth) setStatus(status *models.Status) { ch.Mutex.Lock() ch.status = status ch.Mutex.Unlock() }
[ "func", "(", "ch", "*", "CiliumHealth", ")", "setStatus", "(", "status", "*", "models", ".", "Status", ")", "{", "ch", ".", "Mutex", ".", "Lock", "(", ")", "\n", "ch", ".", "status", "=", "status", "\n", "ch", ".", "Mutex", ".", "Unlock", "(", ")...
// setStatus updates the status of the cilium-health daemon.
[ "setStatus", "updates", "the", "status", "of", "the", "cilium", "-", "health", "daemon", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium-health/launch/launcher.go#L98-L102
162,455
cilium/cilium
api/v1/server/restapi/ipam/delete_ip_a_m_ip_parameters.go
bindIP
func (o *DeleteIPAMIPParams) bindIP(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true // Parameter is provided by construction from the route o.IP = raw return nil }
go
func (o *DeleteIPAMIPParams) bindIP(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true // Parameter is provided by construction from the route o.IP = raw return nil }
[ "func", "(", "o", "*", "DeleteIPAMIPParams", ")", "bindIP", "(", "rawData", "[", "]", "string", ",", "hasKey", "bool", ",", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "raw", "string", "\n", "if", "len", "(", "rawData", ")", ">", ...
// bindIP binds and validates parameter IP from path.
[ "bindIP", "binds", "and", "validates", "parameter", "IP", "from", "path", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/delete_ip_a_m_ip_parameters.go#L61-L73
162,456
cilium/cilium
api/v1/server/restapi/policy/delete_fqdn_cache_responses.go
WithPayload
func (o *DeleteFqdnCacheBadRequest) WithPayload(payload models.Error) *DeleteFqdnCacheBadRequest { o.Payload = payload return o }
go
func (o *DeleteFqdnCacheBadRequest) WithPayload(payload models.Error) *DeleteFqdnCacheBadRequest { o.Payload = payload return o }
[ "func", "(", "o", "*", "DeleteFqdnCacheBadRequest", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "DeleteFqdnCacheBadRequest", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the delete fqdn cache bad request response
[ "WithPayload", "adds", "the", "payload", "to", "the", "delete", "fqdn", "cache", "bad", "request", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/delete_fqdn_cache_responses.go#L62-L65
162,457
cilium/cilium
pkg/endpoint/directory.go
DirectoryPath
func (e *Endpoint) DirectoryPath() string { return filepath.Join(".", fmt.Sprintf("%d", e.ID)) }
go
func (e *Endpoint) DirectoryPath() string { return filepath.Join(".", fmt.Sprintf("%d", e.ID)) }
[ "func", "(", "e", "*", "Endpoint", ")", "DirectoryPath", "(", ")", "string", "{", "return", "filepath", ".", "Join", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "ID", ")", ")", "\n", "}" ]
// DirectoryPath returns the directory name for this endpoint bpf program.
[ "DirectoryPath", "returns", "the", "directory", "name", "for", "this", "endpoint", "bpf", "program", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/directory.go#L30-L32
162,458
cilium/cilium
pkg/endpoint/directory.go
StateDirectoryPath
func (e *Endpoint) StateDirectoryPath() string { return filepath.Join(option.Config.StateDir, e.StringID()) }
go
func (e *Endpoint) StateDirectoryPath() string { return filepath.Join(option.Config.StateDir, e.StringID()) }
[ "func", "(", "e", "*", "Endpoint", ")", "StateDirectoryPath", "(", ")", "string", "{", "return", "filepath", ".", "Join", "(", "option", ".", "Config", ".", "StateDir", ",", "e", ".", "StringID", "(", ")", ")", "\n", "}" ]
// StateDirectoryPath returns the directory name for this endpoint bpf program.
[ "StateDirectoryPath", "returns", "the", "directory", "name", "for", "this", "endpoint", "bpf", "program", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/directory.go#L41-L43
162,459
cilium/cilium
pkg/endpoint/directory.go
synchronizeDirectories
func (e *Endpoint) synchronizeDirectories(origDir string, compilationExecuted bool) error { scopedLog := e.getLogger() scopedLog.Debug("synchronizing directories") tmpDir := e.NextDirectoryPath() // Check if an existing endpoint directory exists, e.g. // /var/run/cilium/state/1111 _, err := os.Stat(origDir) switch { // An endpoint directory already exists. We need to back it up before attempting // to move the new directory in its place so we can attempt recovery. case !os.IsNotExist(err): scopedLog.Debug("endpoint directory exists; backing it up") backupDir := e.backupDirectoryPath() // Remove any eventual old backup directory. This may fail if // the directory does not exist. The error is deliberately // ignored. e.removeDirectory(backupDir) // Move the current endpoint directory to a backup location scopedLog.WithFields(logrus.Fields{ "originalDirectory": origDir, "backupDirectory": backupDir, }).Debug("moving current directory to backup location") if err := os.Rename(origDir, backupDir); err != nil { return fmt.Errorf("unable to rename current endpoint directory: %s", err) } // Regarldess of whether the atomic replace succeeds or not, // ensure that the backup directory is removed when the // function returns. defer e.removeDirectory(backupDir) // Make temporary directory the new endpoint directory if err := os.Rename(tmpDir, origDir); err != nil { if err2 := os.Rename(backupDir, origDir); err2 != nil { scopedLog.WithFields(logrus.Fields{ logfields.Path: backupDir, }).Warn("restoring directory for endpoint failed, endpoint " + "is in inconsistent state. Keeping stale directory.") return err2 } return fmt.Errorf("restored original endpoint directory, atomic directory move failed: %s", err) } // If the compilation was skipped then we need to copy the old // bpf objects into the new directory if !compilationExecuted { scopedLog.Debug("compilation was skipped; moving old BPF objects into new directory") err := common.MoveNewFilesTo(backupDir, origDir) if err != nil { log.WithError(err).Debugf("unable to copy old bpf object "+ "files from %s into the new directory %s.", backupDir, origDir) } } // No existing endpoint directory, synchronizing the directory is a // simple move default: // Make temporary directory the new endpoint directory scopedLog.WithFields(logrus.Fields{ "temporaryDirectory": tmpDir, "originalDirectory": origDir, }).Debug("attempting to make temporary directory new directory for endpoint programs") if err := os.Rename(tmpDir, origDir); err != nil { return fmt.Errorf("atomic endpoint directory move failed: %s", err) } } // The build succeeded and is in place, any eventual existing failure // directory can be removed. e.removeDirectory(e.FailedDirectoryPath()) return nil }
go
func (e *Endpoint) synchronizeDirectories(origDir string, compilationExecuted bool) error { scopedLog := e.getLogger() scopedLog.Debug("synchronizing directories") tmpDir := e.NextDirectoryPath() // Check if an existing endpoint directory exists, e.g. // /var/run/cilium/state/1111 _, err := os.Stat(origDir) switch { // An endpoint directory already exists. We need to back it up before attempting // to move the new directory in its place so we can attempt recovery. case !os.IsNotExist(err): scopedLog.Debug("endpoint directory exists; backing it up") backupDir := e.backupDirectoryPath() // Remove any eventual old backup directory. This may fail if // the directory does not exist. The error is deliberately // ignored. e.removeDirectory(backupDir) // Move the current endpoint directory to a backup location scopedLog.WithFields(logrus.Fields{ "originalDirectory": origDir, "backupDirectory": backupDir, }).Debug("moving current directory to backup location") if err := os.Rename(origDir, backupDir); err != nil { return fmt.Errorf("unable to rename current endpoint directory: %s", err) } // Regarldess of whether the atomic replace succeeds or not, // ensure that the backup directory is removed when the // function returns. defer e.removeDirectory(backupDir) // Make temporary directory the new endpoint directory if err := os.Rename(tmpDir, origDir); err != nil { if err2 := os.Rename(backupDir, origDir); err2 != nil { scopedLog.WithFields(logrus.Fields{ logfields.Path: backupDir, }).Warn("restoring directory for endpoint failed, endpoint " + "is in inconsistent state. Keeping stale directory.") return err2 } return fmt.Errorf("restored original endpoint directory, atomic directory move failed: %s", err) } // If the compilation was skipped then we need to copy the old // bpf objects into the new directory if !compilationExecuted { scopedLog.Debug("compilation was skipped; moving old BPF objects into new directory") err := common.MoveNewFilesTo(backupDir, origDir) if err != nil { log.WithError(err).Debugf("unable to copy old bpf object "+ "files from %s into the new directory %s.", backupDir, origDir) } } // No existing endpoint directory, synchronizing the directory is a // simple move default: // Make temporary directory the new endpoint directory scopedLog.WithFields(logrus.Fields{ "temporaryDirectory": tmpDir, "originalDirectory": origDir, }).Debug("attempting to make temporary directory new directory for endpoint programs") if err := os.Rename(tmpDir, origDir); err != nil { return fmt.Errorf("atomic endpoint directory move failed: %s", err) } } // The build succeeded and is in place, any eventual existing failure // directory can be removed. e.removeDirectory(e.FailedDirectoryPath()) return nil }
[ "func", "(", "e", "*", "Endpoint", ")", "synchronizeDirectories", "(", "origDir", "string", ",", "compilationExecuted", "bool", ")", "error", "{", "scopedLog", ":=", "e", ".", "getLogger", "(", ")", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", ...
// synchronizeDirectories moves the files related to endpoint BPF program // compilation to their according directories if compilation of BPF was // necessary for the endpoint. // Returns the original regenerationError if regenerationError was non-nil, // or if any updates to directories for the endpoint's directories fails. // Must be called with endpoint.Mutex held.
[ "synchronizeDirectories", "moves", "the", "files", "related", "to", "endpoint", "BPF", "program", "compilation", "to", "their", "according", "directories", "if", "compilation", "of", "BPF", "was", "necessary", "for", "the", "endpoint", ".", "Returns", "the", "orig...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/directory.go#L61-L139
162,460
cilium/cilium
pkg/node/node.go
String
func (nn Identity) String() string { return path.Join(nn.Cluster, nn.Name) }
go
func (nn Identity) String() string { return path.Join(nn.Cluster, nn.Name) }
[ "func", "(", "nn", "Identity", ")", "String", "(", ")", "string", "{", "return", "path", ".", "Join", "(", "nn", ".", "Cluster", ",", "nn", ".", "Name", ")", "\n", "}" ]
// String returns the string representation on NodeIdentity.
[ "String", "returns", "the", "string", "representation", "on", "NodeIdentity", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L57-L59
162,461
cilium/cilium
pkg/node/node.go
Fullname
func (n *Node) Fullname() string { if n.Cluster != defaults.ClusterName { return path.Join(n.Cluster, n.Name) } return n.Name }
go
func (n *Node) Fullname() string { if n.Cluster != defaults.ClusterName { return path.Join(n.Cluster, n.Name) } return n.Name }
[ "func", "(", "n", "*", "Node", ")", "Fullname", "(", ")", "string", "{", "if", "n", ".", "Cluster", "!=", "defaults", ".", "ClusterName", "{", "return", "path", ".", "Join", "(", "n", ".", "Cluster", ",", "n", ".", "Name", ")", "\n", "}", "\n\n",...
// Fullname returns the node's full name including the cluster name if a // cluster name value other than the default value has been specified
[ "Fullname", "returns", "the", "node", "s", "full", "name", "including", "the", "cluster", "name", "if", "a", "cluster", "name", "value", "other", "than", "the", "default", "value", "has", "been", "specified" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L101-L107
162,462
cilium/cilium
pkg/node/node.go
GetModel
func (n *Node) GetModel() *models.NodeElement { return &models.NodeElement{ Name: n.Fullname(), PrimaryAddress: n.getPrimaryAddress(), SecondaryAddresses: n.getSecondaryAddresses(), HealthEndpointAddress: n.getHealthAddresses(), } }
go
func (n *Node) GetModel() *models.NodeElement { return &models.NodeElement{ Name: n.Fullname(), PrimaryAddress: n.getPrimaryAddress(), SecondaryAddresses: n.getSecondaryAddresses(), HealthEndpointAddress: n.getHealthAddresses(), } }
[ "func", "(", "n", "*", "Node", ")", "GetModel", "(", ")", "*", "models", ".", "NodeElement", "{", "return", "&", "models", ".", "NodeElement", "{", "Name", ":", "n", ".", "Fullname", "(", ")", ",", "PrimaryAddress", ":", "n", ".", "getPrimaryAddress", ...
// GetModel returns the API model representation of a node.
[ "GetModel", "returns", "the", "API", "model", "representation", "of", "a", "node", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L243-L250
162,463
cilium/cilium
pkg/node/node.go
Identity
func (n *Node) Identity() Identity { return Identity{ Name: n.Name, Cluster: n.Cluster, } }
go
func (n *Node) Identity() Identity { return Identity{ Name: n.Name, Cluster: n.Cluster, } }
[ "func", "(", "n", "*", "Node", ")", "Identity", "(", ")", "Identity", "{", "return", "Identity", "{", "Name", ":", "n", ".", "Name", ",", "Cluster", ":", "n", ".", "Cluster", ",", "}", "\n", "}" ]
// Identity returns the identity of the node
[ "Identity", "returns", "the", "identity", "of", "the", "node" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L253-L258
162,464
cilium/cilium
pkg/node/node.go
PublicAttrEquals
func (n *Node) PublicAttrEquals(o *Node) bool { if (n == nil) != (o == nil) { return false } if n.Name == o.Name && n.Cluster == o.Cluster && n.IPv4HealthIP.Equal(o.IPv4HealthIP) && n.IPv6HealthIP.Equal(o.IPv6HealthIP) && n.ClusterID == o.ClusterID && n.Source == o.Source { if len(n.IPAddresses) != len(o.IPAddresses) { return false } for i := range n.IPAddresses { if (n.IPAddresses[i].Type != o.IPAddresses[i].Type) || !n.IPAddresses[i].IP.Equal(o.IPAddresses[i].IP) { return false } } if (n.IPv4AllocCIDR == nil) != (o.IPv4AllocCIDR == nil) { return false } if n.IPv4AllocCIDR.String() != o.IPv4AllocCIDR.String() { return false } if (n.IPv6AllocCIDR == nil) != (o.IPv6AllocCIDR == nil) { return false } if n.IPv6AllocCIDR.String() != o.IPv6AllocCIDR.String() { return false } return true } return false }
go
func (n *Node) PublicAttrEquals(o *Node) bool { if (n == nil) != (o == nil) { return false } if n.Name == o.Name && n.Cluster == o.Cluster && n.IPv4HealthIP.Equal(o.IPv4HealthIP) && n.IPv6HealthIP.Equal(o.IPv6HealthIP) && n.ClusterID == o.ClusterID && n.Source == o.Source { if len(n.IPAddresses) != len(o.IPAddresses) { return false } for i := range n.IPAddresses { if (n.IPAddresses[i].Type != o.IPAddresses[i].Type) || !n.IPAddresses[i].IP.Equal(o.IPAddresses[i].IP) { return false } } if (n.IPv4AllocCIDR == nil) != (o.IPv4AllocCIDR == nil) { return false } if n.IPv4AllocCIDR.String() != o.IPv4AllocCIDR.String() { return false } if (n.IPv6AllocCIDR == nil) != (o.IPv6AllocCIDR == nil) { return false } if n.IPv6AllocCIDR.String() != o.IPv6AllocCIDR.String() { return false } return true } return false }
[ "func", "(", "n", "*", "Node", ")", "PublicAttrEquals", "(", "o", "*", "Node", ")", "bool", "{", "if", "(", "n", "==", "nil", ")", "!=", "(", "o", "==", "nil", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "n", ".", "Name", "==", "o",...
// PublicAttrEquals returns true only if the public attributes of both nodes // are the same otherwise returns false.
[ "PublicAttrEquals", "returns", "true", "only", "if", "the", "public", "attributes", "of", "both", "nodes", "are", "the", "same", "otherwise", "returns", "false", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L268-L309
162,465
cilium/cilium
pkg/node/node.go
Unmarshal
func (n *Node) Unmarshal(data []byte) error { newNode := Node{} if err := json.Unmarshal(data, &newNode); err != nil { return err } *n = newNode return nil }
go
func (n *Node) Unmarshal(data []byte) error { newNode := Node{} if err := json.Unmarshal(data, &newNode); err != nil { return err } *n = newNode return nil }
[ "func", "(", "n", "*", "Node", ")", "Unmarshal", "(", "data", "[", "]", "byte", ")", "error", "{", "newNode", ":=", "Node", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "newNode", ")", ";", "err", "!=", "n...
// Unmarshal parses the JSON byte slice and updates the node receiver
[ "Unmarshal", "parses", "the", "JSON", "byte", "slice", "and", "updates", "the", "node", "receiver" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node.go#L334-L343
162,466
cilium/cilium
pkg/datapath/link/link.go
DeleteByName
func DeleteByName(ifName string) error { iface, err := netlink.LinkByName(ifName) if err != nil { return fmt.Errorf("failed to lookup %q: %v", ifName, err) } if err = netlink.LinkDel(iface); err != nil { return fmt.Errorf("failed to delete %q: %v", ifName, err) } return nil }
go
func DeleteByName(ifName string) error { iface, err := netlink.LinkByName(ifName) if err != nil { return fmt.Errorf("failed to lookup %q: %v", ifName, err) } if err = netlink.LinkDel(iface); err != nil { return fmt.Errorf("failed to delete %q: %v", ifName, err) } return nil }
[ "func", "DeleteByName", "(", "ifName", "string", ")", "error", "{", "iface", ",", "err", ":=", "netlink", ".", "LinkByName", "(", "ifName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ifName", ",",...
// DeleteByName deletes the interface with the name ifName.
[ "DeleteByName", "deletes", "the", "interface", "with", "the", "name", "ifName", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/link/link.go#L24-L35
162,467
cilium/cilium
pkg/datapath/link/link.go
Rename
func Rename(curName, newName string) error { link, err := netlink.LinkByName(curName) if err != nil { return err } return netlink.LinkSetName(link, newName) }
go
func Rename(curName, newName string) error { link, err := netlink.LinkByName(curName) if err != nil { return err } return netlink.LinkSetName(link, newName) }
[ "func", "Rename", "(", "curName", ",", "newName", "string", ")", "error", "{", "link", ",", "err", ":=", "netlink", ".", "LinkByName", "(", "curName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "netlink", ...
// Rename renames a network link
[ "Rename", "renames", "a", "network", "link" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/link/link.go#L38-L45
162,468
cilium/cilium
pkg/byteorder/byteorder.go
reverse
func reverse(b []byte) []byte { size := len(b) c := make([]byte, size) for i, j := size-1, 0; i >= 0; i, j = i-1, j+1 { c[j] = b[i] } return c }
go
func reverse(b []byte) []byte { size := len(b) c := make([]byte, size) for i, j := size-1, 0; i >= 0; i, j = i-1, j+1 { c[j] = b[i] } return c }
[ "func", "reverse", "(", "b", "[", "]", "byte", ")", "[", "]", "byte", "{", "size", ":=", "len", "(", "b", ")", "\n", "c", ":=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n\n", "for", "i", ",", "j", ":=", "size", "-", "1", ",", "0...
// reverse returns a reversed slice of b.
[ "reverse", "returns", "a", "reversed", "slice", "of", "b", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L58-L67
162,469
cilium/cilium
pkg/byteorder/byteorder.go
HostToNetwork
func HostToNetwork(b interface{}) interface{} { switch b.(type) { case uint16: return swap16(b.(uint16)) case uint32: return swap32(b.(uint32)) default: panic(unsupported(b)) } }
go
func HostToNetwork(b interface{}) interface{} { switch b.(type) { case uint16: return swap16(b.(uint16)) case uint32: return swap32(b.(uint32)) default: panic(unsupported(b)) } }
[ "func", "HostToNetwork", "(", "b", "interface", "{", "}", ")", "interface", "{", "}", "{", "switch", "b", ".", "(", "type", ")", "{", "case", "uint16", ":", "return", "swap16", "(", "b", ".", "(", "uint16", ")", ")", "\n", "case", "uint32", ":", ...
// HostToNetwork converts b to the networking byte order.
[ "HostToNetwork", "converts", "b", "to", "the", "networking", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L70-L79
162,470
cilium/cilium
pkg/byteorder/byteorder.go
NetworkToHost
func NetworkToHost(n interface{}) interface{} { switch n.(type) { case uint16: return swap16(n.(uint16)) case uint32: return swap32(n.(uint32)) default: panic(unsupported(n)) } }
go
func NetworkToHost(n interface{}) interface{} { switch n.(type) { case uint16: return swap16(n.(uint16)) case uint32: return swap32(n.(uint32)) default: panic(unsupported(n)) } }
[ "func", "NetworkToHost", "(", "n", "interface", "{", "}", ")", "interface", "{", "}", "{", "switch", "n", ".", "(", "type", ")", "{", "case", "uint16", ":", "return", "swap16", "(", "n", ".", "(", "uint16", ")", ")", "\n", "case", "uint32", ":", ...
// NetworkToHost converts n to host byte order.
[ "NetworkToHost", "converts", "n", "to", "host", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L82-L91
162,471
cilium/cilium
pkg/byteorder/byteorder.go
HostToNetworkSlice
func HostToNetworkSlice(b []byte, t reflect.Kind) interface{} { switch t { case reflect.Uint32: return binary.BigEndian.Uint32(b) case reflect.Uint16: return binary.BigEndian.Uint16(b) default: panic(unsupported(b)) } }
go
func HostToNetworkSlice(b []byte, t reflect.Kind) interface{} { switch t { case reflect.Uint32: return binary.BigEndian.Uint32(b) case reflect.Uint16: return binary.BigEndian.Uint16(b) default: panic(unsupported(b)) } }
[ "func", "HostToNetworkSlice", "(", "b", "[", "]", "byte", ",", "t", "reflect", ".", "Kind", ")", "interface", "{", "}", "{", "switch", "t", "{", "case", "reflect", ".", "Uint32", ":", "return", "binary", ".", "BigEndian", ".", "Uint32", "(", "b", ")"...
// HostToNetworkSlice converts b to the networking byte order.
[ "HostToNetworkSlice", "converts", "b", "to", "the", "networking", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L94-L103
162,472
cilium/cilium
pkg/byteorder/byteorder.go
HostToNetworkPut
func HostToNetworkPut(b []byte, v interface{}) { switch reflect.TypeOf(v).Kind() { case reflect.Uint32: binary.BigEndian.PutUint32(b, v.(uint32)) case reflect.Uint16: binary.BigEndian.PutUint16(b, v.(uint16)) default: panic(unsupported(v)) } }
go
func HostToNetworkPut(b []byte, v interface{}) { switch reflect.TypeOf(v).Kind() { case reflect.Uint32: binary.BigEndian.PutUint32(b, v.(uint32)) case reflect.Uint16: binary.BigEndian.PutUint16(b, v.(uint16)) default: panic(unsupported(v)) } }
[ "func", "HostToNetworkPut", "(", "b", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "{", "switch", "reflect", ".", "TypeOf", "(", "v", ")", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Uint32", ":", "binary", ".", "BigEndian", "."...
// HostToNetworkPut puts v into b with the networking byte order.
[ "HostToNetworkPut", "puts", "v", "into", "b", "with", "the", "networking", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L106-L115
162,473
cilium/cilium
pkg/byteorder/byteorder.go
NetworkToHostPut
func NetworkToHostPut(b []byte, v interface{}) { switch reflect.TypeOf(v).Kind() { case reflect.Uint32: Native.PutUint32(b, v.(uint32)) case reflect.Uint16: Native.PutUint16(b, v.(uint16)) default: panic(unsupported(v)) } }
go
func NetworkToHostPut(b []byte, v interface{}) { switch reflect.TypeOf(v).Kind() { case reflect.Uint32: Native.PutUint32(b, v.(uint32)) case reflect.Uint16: Native.PutUint16(b, v.(uint16)) default: panic(unsupported(v)) } }
[ "func", "NetworkToHostPut", "(", "b", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "{", "switch", "reflect", ".", "TypeOf", "(", "v", ")", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Uint32", ":", "Native", ".", "PutUint32", "("...
// NetworkToHostPut puts v into b with the networking byte order.
[ "NetworkToHostPut", "puts", "v", "into", "b", "with", "the", "networking", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L118-L127
162,474
cilium/cilium
pkg/byteorder/byteorder.go
HostSliceToNetwork
func HostSliceToNetwork(b []byte, t reflect.Kind) interface{} { switch t { case reflect.Uint32: if Native != binary.BigEndian { return binary.BigEndian.Uint32(reverse(b)) } return binary.BigEndian.Uint32(b) case reflect.Uint16: if Native != binary.BigEndian { return binary.BigEndian.Uint16(reverse(b)) } return binary.BigEndian.Uint16(b) default: panic(unsupported(t)) } }
go
func HostSliceToNetwork(b []byte, t reflect.Kind) interface{} { switch t { case reflect.Uint32: if Native != binary.BigEndian { return binary.BigEndian.Uint32(reverse(b)) } return binary.BigEndian.Uint32(b) case reflect.Uint16: if Native != binary.BigEndian { return binary.BigEndian.Uint16(reverse(b)) } return binary.BigEndian.Uint16(b) default: panic(unsupported(t)) } }
[ "func", "HostSliceToNetwork", "(", "b", "[", "]", "byte", ",", "t", "reflect", ".", "Kind", ")", "interface", "{", "}", "{", "switch", "t", "{", "case", "reflect", ".", "Uint32", ":", "if", "Native", "!=", "binary", ".", "BigEndian", "{", "return", "...
// HostSliceToNetwork converts b to the networking byte order.
[ "HostSliceToNetwork", "converts", "b", "to", "the", "networking", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L130-L145
162,475
cilium/cilium
pkg/byteorder/byteorder.go
unsupported
func unsupported(field interface{}) string { return fmt.Sprintf("unsupported type(%v): %v", reflect.TypeOf(field).Kind(), field) }
go
func unsupported(field interface{}) string { return fmt.Sprintf("unsupported type(%v): %v", reflect.TypeOf(field).Kind(), field) }
[ "func", "unsupported", "(", "field", "interface", "{", "}", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "field", ")", ".", "Kind", "(", ")", ",", "field", ")", "\n", "}" ]
// unsupported returns a string to used for debugging unhandled types.
[ "unsupported", "returns", "a", "string", "to", "used", "for", "debugging", "unhandled", "types", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/byteorder/byteorder.go#L148-L150
162,476
cilium/cilium
api/v1/health/models/health_status_response.go
Validate
func (m *HealthStatusResponse) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLocal(formats); err != nil { res = append(res, err) } if err := m.validateNodes(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *HealthStatusResponse) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLocal(formats); err != nil { res = append(res, err) } if err := m.validateNodes(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "HealthStatusResponse", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateLocal", "(", "formats", ")", ";", "err", "!=", ...
// Validate validates this health status response
[ "Validate", "validates", "this", "health", "status", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/health_status_response.go#L32-L47
162,477
cilium/cilium
api/v1/server/restapi/policy/get_policy_responses.go
WithPayload
func (o *GetPolicyOK) WithPayload(payload *models.Policy) *GetPolicyOK { o.Payload = payload return o }
go
func (o *GetPolicyOK) WithPayload(payload *models.Policy) *GetPolicyOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetPolicyOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "Policy", ")", "*", "GetPolicyOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get policy o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "policy", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_policy_responses.go#L38-L41
162,478
cilium/cilium
pkg/k8s/service_cache.go
NewServiceCache
func NewServiceCache() ServiceCache { return ServiceCache{ services: map[ServiceID]*Service{}, endpoints: map[ServiceID]*Endpoints{}, ingresses: map[ServiceID]*Service{}, externalEndpoints: map[ServiceID]externalEndpoints{}, Events: make(chan ServiceEvent, 128), } }
go
func NewServiceCache() ServiceCache { return ServiceCache{ services: map[ServiceID]*Service{}, endpoints: map[ServiceID]*Endpoints{}, ingresses: map[ServiceID]*Service{}, externalEndpoints: map[ServiceID]externalEndpoints{}, Events: make(chan ServiceEvent, 128), } }
[ "func", "NewServiceCache", "(", ")", "ServiceCache", "{", "return", "ServiceCache", "{", "services", ":", "map", "[", "ServiceID", "]", "*", "Service", "{", "}", ",", "endpoints", ":", "map", "[", "ServiceID", "]", "*", "Endpoints", "{", "}", ",", "ingre...
// NewServiceCache returns a new ServiceCache
[ "NewServiceCache", "returns", "a", "new", "ServiceCache" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L98-L106
162,479
cilium/cilium
pkg/k8s/service_cache.go
GetRandomBackendIP
func (s *ServiceCache) GetRandomBackendIP(svcID ServiceID) *loadbalancer.L3n4Addr { s.mutex.RLock() defer s.mutex.RUnlock() svc := s.services[svcID] if svc == nil { return nil } for _, port := range svc.Ports { return loadbalancer.NewL3n4Addr(port.Protocol, svc.FrontendIP, port.Port) } return nil }
go
func (s *ServiceCache) GetRandomBackendIP(svcID ServiceID) *loadbalancer.L3n4Addr { s.mutex.RLock() defer s.mutex.RUnlock() svc := s.services[svcID] if svc == nil { return nil } for _, port := range svc.Ports { return loadbalancer.NewL3n4Addr(port.Protocol, svc.FrontendIP, port.Port) } return nil }
[ "func", "(", "s", "*", "ServiceCache", ")", "GetRandomBackendIP", "(", "svcID", "ServiceID", ")", "*", "loadbalancer", ".", "L3n4Addr", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", ...
// GetRandomBackendIP returns a random L3n4Addr that is backing the given Service ID.
[ "GetRandomBackendIP", "returns", "a", "random", "L3n4Addr", "that", "is", "backing", "the", "given", "Service", "ID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L109-L120
162,480
cilium/cilium
pkg/k8s/service_cache.go
UpdateService
func (s *ServiceCache) UpdateService(k8sSvc *types.Service) ServiceID { svcID, newService := ParseService(k8sSvc) if newService == nil { return svcID } s.mutex.Lock() defer s.mutex.Unlock() if oldService, ok := s.services[svcID]; ok { if oldService.DeepEquals(newService) { return svcID } } s.services[svcID] = newService // Check if the corresponding Endpoints resource is already available endpoints, serviceReady := s.correlateEndpoints(svcID) if serviceReady { s.Events <- ServiceEvent{ Action: UpdateService, ID: svcID, Service: newService, Endpoints: endpoints, } } return svcID }
go
func (s *ServiceCache) UpdateService(k8sSvc *types.Service) ServiceID { svcID, newService := ParseService(k8sSvc) if newService == nil { return svcID } s.mutex.Lock() defer s.mutex.Unlock() if oldService, ok := s.services[svcID]; ok { if oldService.DeepEquals(newService) { return svcID } } s.services[svcID] = newService // Check if the corresponding Endpoints resource is already available endpoints, serviceReady := s.correlateEndpoints(svcID) if serviceReady { s.Events <- ServiceEvent{ Action: UpdateService, ID: svcID, Service: newService, Endpoints: endpoints, } } return svcID }
[ "func", "(", "s", "*", "ServiceCache", ")", "UpdateService", "(", "k8sSvc", "*", "types", ".", "Service", ")", "ServiceID", "{", "svcID", ",", "newService", ":=", "ParseService", "(", "k8sSvc", ")", "\n", "if", "newService", "==", "nil", "{", "return", "...
// UpdateService parses a Kubernetes service and adds or updates it in the // ServiceCache. Returns the ServiceID unless the Kubernetes service could not // be parsed and a bool to indicate whether the service was changed in the // cache or not.
[ "UpdateService", "parses", "a", "Kubernetes", "service", "and", "adds", "or", "updates", "it", "in", "the", "ServiceCache", ".", "Returns", "the", "ServiceID", "unless", "the", "Kubernetes", "service", "could", "not", "be", "parsed", "and", "a", "bool", "to", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L126-L155
162,481
cilium/cilium
pkg/k8s/service_cache.go
DeleteService
func (s *ServiceCache) DeleteService(k8sSvc *types.Service) { svcID := ParseServiceID(k8sSvc) s.mutex.Lock() oldService, serviceOK := s.services[svcID] endpoints, _ := s.correlateEndpoints(svcID) delete(s.services, svcID) s.mutex.Unlock() if serviceOK { s.Events <- ServiceEvent{ Action: DeleteService, ID: svcID, Service: oldService, Endpoints: endpoints, } } }
go
func (s *ServiceCache) DeleteService(k8sSvc *types.Service) { svcID := ParseServiceID(k8sSvc) s.mutex.Lock() oldService, serviceOK := s.services[svcID] endpoints, _ := s.correlateEndpoints(svcID) delete(s.services, svcID) s.mutex.Unlock() if serviceOK { s.Events <- ServiceEvent{ Action: DeleteService, ID: svcID, Service: oldService, Endpoints: endpoints, } } }
[ "func", "(", "s", "*", "ServiceCache", ")", "DeleteService", "(", "k8sSvc", "*", "types", ".", "Service", ")", "{", "svcID", ":=", "ParseServiceID", "(", "k8sSvc", ")", "\n\n", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "oldService", ",", "service...
// DeleteService parses a Kubernetes service and removes it from the // ServiceCache
[ "DeleteService", "parses", "a", "Kubernetes", "service", "and", "removes", "it", "from", "the", "ServiceCache" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L159-L176
162,482
cilium/cilium
pkg/k8s/service_cache.go
UpdateEndpoints
func (s *ServiceCache) UpdateEndpoints(k8sEndpoints *types.Endpoints) (ServiceID, *Endpoints) { svcID, newEndpoints := ParseEndpoints(k8sEndpoints) s.mutex.Lock() defer s.mutex.Unlock() if oldEndpoints, ok := s.endpoints[svcID]; ok { if oldEndpoints.DeepEquals(newEndpoints) { return svcID, newEndpoints } } s.endpoints[svcID] = newEndpoints // Check if the corresponding Endpoints resource is already available service, ok := s.services[svcID] endpoints, serviceReady := s.correlateEndpoints(svcID) if ok && serviceReady { s.Events <- ServiceEvent{ Action: UpdateService, ID: svcID, Service: service, Endpoints: endpoints, } } return svcID, newEndpoints }
go
func (s *ServiceCache) UpdateEndpoints(k8sEndpoints *types.Endpoints) (ServiceID, *Endpoints) { svcID, newEndpoints := ParseEndpoints(k8sEndpoints) s.mutex.Lock() defer s.mutex.Unlock() if oldEndpoints, ok := s.endpoints[svcID]; ok { if oldEndpoints.DeepEquals(newEndpoints) { return svcID, newEndpoints } } s.endpoints[svcID] = newEndpoints // Check if the corresponding Endpoints resource is already available service, ok := s.services[svcID] endpoints, serviceReady := s.correlateEndpoints(svcID) if ok && serviceReady { s.Events <- ServiceEvent{ Action: UpdateService, ID: svcID, Service: service, Endpoints: endpoints, } } return svcID, newEndpoints }
[ "func", "(", "s", "*", "ServiceCache", ")", "UpdateEndpoints", "(", "k8sEndpoints", "*", "types", ".", "Endpoints", ")", "(", "ServiceID", ",", "*", "Endpoints", ")", "{", "svcID", ",", "newEndpoints", ":=", "ParseEndpoints", "(", "k8sEndpoints", ")", "\n\n"...
// UpdateEndpoints parses a Kubernetes endpoints and adds or updates it in the // ServiceCache. Returns the ServiceID unless the Kubernetes endpoints could not // be parsed and a bool to indicate whether the endpoints was changed in the // cache or not.
[ "UpdateEndpoints", "parses", "a", "Kubernetes", "endpoints", "and", "adds", "or", "updates", "it", "in", "the", "ServiceCache", ".", "Returns", "the", "ServiceID", "unless", "the", "Kubernetes", "endpoints", "could", "not", "be", "parsed", "and", "a", "bool", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L182-L209
162,483
cilium/cilium
pkg/k8s/service_cache.go
DeleteEndpoints
func (s *ServiceCache) DeleteEndpoints(k8sEndpoints *types.Endpoints) ServiceID { svcID := ParseEndpointsID(k8sEndpoints) s.mutex.Lock() service, serviceOK := s.services[svcID] delete(s.endpoints, svcID) endpoints, serviceReady := s.correlateEndpoints(svcID) s.mutex.Unlock() if serviceOK { event := ServiceEvent{ Action: DeleteService, ID: svcID, Service: service, Endpoints: endpoints, } if serviceReady { event.Action = UpdateService } s.Events <- event } return svcID }
go
func (s *ServiceCache) DeleteEndpoints(k8sEndpoints *types.Endpoints) ServiceID { svcID := ParseEndpointsID(k8sEndpoints) s.mutex.Lock() service, serviceOK := s.services[svcID] delete(s.endpoints, svcID) endpoints, serviceReady := s.correlateEndpoints(svcID) s.mutex.Unlock() if serviceOK { event := ServiceEvent{ Action: DeleteService, ID: svcID, Service: service, Endpoints: endpoints, } if serviceReady { event.Action = UpdateService } s.Events <- event } return svcID }
[ "func", "(", "s", "*", "ServiceCache", ")", "DeleteEndpoints", "(", "k8sEndpoints", "*", "types", ".", "Endpoints", ")", "ServiceID", "{", "svcID", ":=", "ParseEndpointsID", "(", "k8sEndpoints", ")", "\n\n", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", ...
// DeleteEndpoints parses a Kubernetes endpoints and removes it from the // ServiceCache
[ "DeleteEndpoints", "parses", "a", "Kubernetes", "endpoints", "and", "removes", "it", "from", "the", "ServiceCache" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L213-L238
162,484
cilium/cilium
pkg/k8s/service_cache.go
UpdateIngress
func (s *ServiceCache) UpdateIngress(ingress *types.Ingress, host net.IP) (ServiceID, error) { svcID, newService, err := ParseIngress(ingress, host) if err != nil { return svcID, err } s.mutex.Lock() defer s.mutex.Unlock() if oldService, ok := s.ingresses[svcID]; ok { if oldService.DeepEquals(newService) { return svcID, nil } } s.ingresses[svcID] = newService s.Events <- ServiceEvent{ Action: UpdateIngress, ID: svcID, Service: newService, } return svcID, nil }
go
func (s *ServiceCache) UpdateIngress(ingress *types.Ingress, host net.IP) (ServiceID, error) { svcID, newService, err := ParseIngress(ingress, host) if err != nil { return svcID, err } s.mutex.Lock() defer s.mutex.Unlock() if oldService, ok := s.ingresses[svcID]; ok { if oldService.DeepEquals(newService) { return svcID, nil } } s.ingresses[svcID] = newService s.Events <- ServiceEvent{ Action: UpdateIngress, ID: svcID, Service: newService, } return svcID, nil }
[ "func", "(", "s", "*", "ServiceCache", ")", "UpdateIngress", "(", "ingress", "*", "types", ".", "Ingress", ",", "host", "net", ".", "IP", ")", "(", "ServiceID", ",", "error", ")", "{", "svcID", ",", "newService", ",", "err", ":=", "ParseIngress", "(", ...
// UpdateIngress parses a Kubernetes ingress and adds or updates it in the // ServiceCache.
[ "UpdateIngress", "parses", "a", "Kubernetes", "ingress", "and", "adds", "or", "updates", "it", "in", "the", "ServiceCache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L242-L266
162,485
cilium/cilium
pkg/k8s/service_cache.go
DeleteIngress
func (s *ServiceCache) DeleteIngress(ingress *types.Ingress) { svcID := ParseIngressID(ingress) s.mutex.Lock() oldService, ok := s.ingresses[svcID] endpoints, _ := s.endpoints[svcID] delete(s.ingresses, svcID) s.mutex.Unlock() if ok { s.Events <- ServiceEvent{ Action: DeleteIngress, ID: svcID, Service: oldService, Endpoints: endpoints, } } }
go
func (s *ServiceCache) DeleteIngress(ingress *types.Ingress) { svcID := ParseIngressID(ingress) s.mutex.Lock() oldService, ok := s.ingresses[svcID] endpoints, _ := s.endpoints[svcID] delete(s.ingresses, svcID) s.mutex.Unlock() if ok { s.Events <- ServiceEvent{ Action: DeleteIngress, ID: svcID, Service: oldService, Endpoints: endpoints, } } }
[ "func", "(", "s", "*", "ServiceCache", ")", "DeleteIngress", "(", "ingress", "*", "types", ".", "Ingress", ")", "{", "svcID", ":=", "ParseIngressID", "(", "ingress", ")", "\n\n", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "oldService", ",", "ok", ...
// DeleteIngress parses a Kubernetes ingress and removes it from the // ServiceCache
[ "DeleteIngress", "parses", "a", "Kubernetes", "ingress", "and", "removes", "it", "from", "the", "ServiceCache" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L270-L287
162,486
cilium/cilium
pkg/k8s/service_cache.go
LooseMatch
func (l FrontendList) LooseMatch(frontend loadbalancer.L3n4Addr) (exists bool) { switch frontend.Protocol { case loadbalancer.NONE: for _, protocol := range loadbalancer.AllProtocols { frontend.Protocol = protocol _, exists = l[frontend.StringWithProtocol()] if exists { return } } // If the protocol is set, perform an exact match default: _, exists = l[frontend.StringWithProtocol()] } return }
go
func (l FrontendList) LooseMatch(frontend loadbalancer.L3n4Addr) (exists bool) { switch frontend.Protocol { case loadbalancer.NONE: for _, protocol := range loadbalancer.AllProtocols { frontend.Protocol = protocol _, exists = l[frontend.StringWithProtocol()] if exists { return } } // If the protocol is set, perform an exact match default: _, exists = l[frontend.StringWithProtocol()] } return }
[ "func", "(", "l", "FrontendList", ")", "LooseMatch", "(", "frontend", "loadbalancer", ".", "L3n4Addr", ")", "(", "exists", "bool", ")", "{", "switch", "frontend", ".", "Protocol", "{", "case", "loadbalancer", ".", "NONE", ":", "for", "_", ",", "protocol", ...
// LooseMatch returns true if the provided frontend is found in the // FrontendList. If the frontend has a protocol value set, it only matches a // k8s service with a matching protocol. If no protocol is set, any k8s service // matching frontend IP and port is considered a match, regardless of protocol.
[ "LooseMatch", "returns", "true", "if", "the", "provided", "frontend", "is", "found", "in", "the", "FrontendList", ".", "If", "the", "frontend", "has", "a", "protocol", "value", "set", "it", "only", "matches", "a", "k8s", "service", "with", "a", "matching", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L296-L312
162,487
cilium/cilium
pkg/k8s/service_cache.go
UniqueServiceFrontends
func (s *ServiceCache) UniqueServiceFrontends() FrontendList { uniqueFrontends := FrontendList{} s.mutex.RLock() defer s.mutex.RUnlock() for _, svc := range s.services { for _, p := range svc.Ports { address := loadbalancer.L3n4Addr{ IP: svc.FrontendIP, L4Addr: *p.L4Addr, } uniqueFrontends[address.StringWithProtocol()] = struct{}{} } } return uniqueFrontends }
go
func (s *ServiceCache) UniqueServiceFrontends() FrontendList { uniqueFrontends := FrontendList{} s.mutex.RLock() defer s.mutex.RUnlock() for _, svc := range s.services { for _, p := range svc.Ports { address := loadbalancer.L3n4Addr{ IP: svc.FrontendIP, L4Addr: *p.L4Addr, } uniqueFrontends[address.StringWithProtocol()] = struct{}{} } } return uniqueFrontends }
[ "func", "(", "s", "*", "ServiceCache", ")", "UniqueServiceFrontends", "(", ")", "FrontendList", "{", "uniqueFrontends", ":=", "FrontendList", "{", "}", "\n\n", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "...
// UniqueServiceFrontends returns all services known to the service cache as a // map, indexed by the string representation of a loadbalancer.L3n4Addr
[ "UniqueServiceFrontends", "returns", "all", "services", "known", "to", "the", "service", "cache", "as", "a", "map", "indexed", "by", "the", "string", "representation", "of", "a", "loadbalancer", ".", "L3n4Addr" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L316-L334
162,488
cilium/cilium
pkg/k8s/service_cache.go
DebugStatus
func (s *ServiceCache) DebugStatus() string { s.mutex.RLock() str := spew.Sdump(s) s.mutex.RUnlock() return str }
go
func (s *ServiceCache) DebugStatus() string { s.mutex.RLock() str := spew.Sdump(s) s.mutex.RUnlock() return str }
[ "func", "(", "s", "*", "ServiceCache", ")", "DebugStatus", "(", ")", "string", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "str", ":=", "spew", ".", "Sdump", "(", "s", ")", "\n", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "ret...
// DebugStatus implements debug.StatusObject to provide debug status collection // ability
[ "DebugStatus", "implements", "debug", ".", "StatusObject", "to", "provide", "debug", "status", "collection", "ability" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service_cache.go#L478-L483
162,489
cilium/cilium
api/v1/server/restapi/endpoint/get_endpoint_id_healthz.go
NewGetEndpointIDHealthz
func NewGetEndpointIDHealthz(ctx *middleware.Context, handler GetEndpointIDHealthzHandler) *GetEndpointIDHealthz { return &GetEndpointIDHealthz{Context: ctx, Handler: handler} }
go
func NewGetEndpointIDHealthz(ctx *middleware.Context, handler GetEndpointIDHealthzHandler) *GetEndpointIDHealthz { return &GetEndpointIDHealthz{Context: ctx, Handler: handler} }
[ "func", "NewGetEndpointIDHealthz", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetEndpointIDHealthzHandler", ")", "*", "GetEndpointIDHealthz", "{", "return", "&", "GetEndpointIDHealthz", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler",...
// NewGetEndpointIDHealthz creates a new http.Handler for the get endpoint ID healthz operation
[ "NewGetEndpointIDHealthz", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "endpoint", "ID", "healthz", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_healthz.go#L28-L30
162,490
cilium/cilium
api/v1/health/server/restapi/connectivity/get_status_responses.go
WithPayload
func (o *GetStatusOK) WithPayload(payload *models.HealthStatusResponse) *GetStatusOK { o.Payload = payload return o }
go
func (o *GetStatusOK) WithPayload(payload *models.HealthStatusResponse) *GetStatusOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetStatusOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "HealthStatusResponse", ")", "*", "GetStatusOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get status o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "status", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/restapi/connectivity/get_status_responses.go#L38-L41
162,491
cilium/cilium
pkg/bpf/prog_linux.go
GetProgNextID
func GetProgNextID(current uint32) (uint32, error) { attr := attrProg{ progID: current, } duration := spanstat.Start() ret, _, err := unix.Syscall(unix.SYS_BPF, BPF_PROG_GET_NEXT_ID, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) metricSyscallDuration.WithLabelValues(metricOpProgGetNextID, metrics.Errno2Outcome(err)).Observe(duration.End(err == 0).Total().Seconds()) if ret != 0 || err != 0 { return 0, fmt.Errorf("Unable to get next id: %v", err) } return attr.nextID, nil }
go
func GetProgNextID(current uint32) (uint32, error) { attr := attrProg{ progID: current, } duration := spanstat.Start() ret, _, err := unix.Syscall(unix.SYS_BPF, BPF_PROG_GET_NEXT_ID, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) metricSyscallDuration.WithLabelValues(metricOpProgGetNextID, metrics.Errno2Outcome(err)).Observe(duration.End(err == 0).Total().Seconds()) if ret != 0 || err != 0 { return 0, fmt.Errorf("Unable to get next id: %v", err) } return attr.nextID, nil }
[ "func", "GetProgNextID", "(", "current", "uint32", ")", "(", "uint32", ",", "error", ")", "{", "attr", ":=", "attrProg", "{", "progID", ":", "current", ",", "}", "\n\n", "duration", ":=", "spanstat", ".", "Start", "(", ")", "\n", "ret", ",", "_", ","...
// GetProgNextID takes a current program ID and returns the next program ID.
[ "GetProgNextID", "takes", "a", "current", "program", "ID", "and", "returns", "the", "next", "program", "ID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/prog_linux.go#L70-L83
162,492
cilium/cilium
pkg/bpf/prog_linux.go
GetProgFDByID
func GetProgFDByID(id uint32) (int, error) { attr := attrProg{ progID: uint32(uintptr(id)), } fd, _, err := unix.Syscall(unix.SYS_BPF, BPF_PROG_GET_FD_BY_ID, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) if fd < 0 || err != 0 { return int(fd), fmt.Errorf("Unable to get fd for program id %d: %v", id, err) } return int(fd), nil }
go
func GetProgFDByID(id uint32) (int, error) { attr := attrProg{ progID: uint32(uintptr(id)), } fd, _, err := unix.Syscall(unix.SYS_BPF, BPF_PROG_GET_FD_BY_ID, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) if fd < 0 || err != 0 { return int(fd), fmt.Errorf("Unable to get fd for program id %d: %v", id, err) } return int(fd), nil }
[ "func", "GetProgFDByID", "(", "id", "uint32", ")", "(", "int", ",", "error", ")", "{", "attr", ":=", "attrProg", "{", "progID", ":", "uint32", "(", "uintptr", "(", "id", ")", ")", ",", "}", "\n\n", "fd", ",", "_", ",", "err", ":=", "unix", ".", ...
// GetProgFDByID returns the file descriptor for the program id.
[ "GetProgFDByID", "returns", "the", "file", "descriptor", "for", "the", "program", "id", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/prog_linux.go#L86-L97
162,493
cilium/cilium
pkg/bpf/prog_linux.go
GetProgInfoByFD
func GetProgInfoByFD(fd int) (ProgInfo, error) { info := ProgInfo{} attrInfo := attrObjInfo{ bpfFD: uint32(fd), infoLen: uint32(unsafe.Sizeof(info)), info: uint64(uintptr(unsafe.Pointer(&info))), } // This struct must be in sync with union bpf_attr's anonymous struct attr := struct { info attrObjInfo }{ info: attrInfo, } duration := spanstat.Start() ret, _, err := unix.Syscall(unix.SYS_BPF, BPF_OBJ_GET_INFO_BY_FD, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) metricSyscallDuration.WithLabelValues(metricOpObjGetInfoByFD, metrics.Errno2Outcome(err)).Observe(duration.End(err == 0).Total().Seconds()) if ret != 0 || err != 0 { return ProgInfo{}, fmt.Errorf("Unable to get object info: %v", err) } return info, nil }
go
func GetProgInfoByFD(fd int) (ProgInfo, error) { info := ProgInfo{} attrInfo := attrObjInfo{ bpfFD: uint32(fd), infoLen: uint32(unsafe.Sizeof(info)), info: uint64(uintptr(unsafe.Pointer(&info))), } // This struct must be in sync with union bpf_attr's anonymous struct attr := struct { info attrObjInfo }{ info: attrInfo, } duration := spanstat.Start() ret, _, err := unix.Syscall(unix.SYS_BPF, BPF_OBJ_GET_INFO_BY_FD, uintptr(unsafe.Pointer(&attr)), unsafe.Sizeof(attr)) metricSyscallDuration.WithLabelValues(metricOpObjGetInfoByFD, metrics.Errno2Outcome(err)).Observe(duration.End(err == 0).Total().Seconds()) if ret != 0 || err != 0 { return ProgInfo{}, fmt.Errorf("Unable to get object info: %v", err) } return info, nil }
[ "func", "GetProgInfoByFD", "(", "fd", "int", ")", "(", "ProgInfo", ",", "error", ")", "{", "info", ":=", "ProgInfo", "{", "}", "\n", "attrInfo", ":=", "attrObjInfo", "{", "bpfFD", ":", "uint32", "(", "fd", ")", ",", "infoLen", ":", "uint32", "(", "un...
// GetProgInfoByFD gets the bpf program info from its file descriptor.
[ "GetProgInfoByFD", "gets", "the", "bpf", "program", "info", "from", "its", "file", "descriptor", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/prog_linux.go#L100-L122
162,494
cilium/cilium
api/v1/server/restapi/endpoint/get_endpoint.go
NewGetEndpoint
func NewGetEndpoint(ctx *middleware.Context, handler GetEndpointHandler) *GetEndpoint { return &GetEndpoint{Context: ctx, Handler: handler} }
go
func NewGetEndpoint(ctx *middleware.Context, handler GetEndpointHandler) *GetEndpoint { return &GetEndpoint{Context: ctx, Handler: handler} }
[ "func", "NewGetEndpoint", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetEndpointHandler", ")", "*", "GetEndpoint", "{", "return", "&", "GetEndpoint", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetEndpoint creates a new http.Handler for the get endpoint operation
[ "NewGetEndpoint", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "endpoint", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint.go#L28-L30
162,495
cilium/cilium
pkg/cidr/diff.go
DiffCIDRLists
func DiffCIDRLists(old, new []*CIDR) (add, remove []*CIDR) { add = listMissingIPNets(createIPNetMap(old), new) remove = listMissingIPNets(createIPNetMap(new), old) return }
go
func DiffCIDRLists(old, new []*CIDR) (add, remove []*CIDR) { add = listMissingIPNets(createIPNetMap(old), new) remove = listMissingIPNets(createIPNetMap(new), old) return }
[ "func", "DiffCIDRLists", "(", "old", ",", "new", "[", "]", "*", "CIDR", ")", "(", "add", ",", "remove", "[", "]", "*", "CIDR", ")", "{", "add", "=", "listMissingIPNets", "(", "createIPNetMap", "(", "old", ")", ",", "new", ")", "\n", "remove", "=", ...
// DiffCIDRLists compares an old and new list of CIDRs and returns the list of // removed and added CIDRs
[ "DiffCIDRLists", "compares", "an", "old", "and", "new", "list", "of", "CIDRs", "and", "returns", "the", "list", "of", "removed", "and", "added", "CIDRs" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/cidr/diff.go#L40-L44
162,496
cilium/cilium
pkg/envoy/xds/ack.go
NewAckingResourceMutatorWrapper
func NewAckingResourceMutatorWrapper(mutator ResourceMutator, nodeToID NodeToIDFunc) *AckingResourceMutatorWrapper { return &AckingResourceMutatorWrapper{ mutator: mutator, nodeToID: nodeToID, pendingCompletions: make(map[*completion.Completion]*pendingCompletion), } }
go
func NewAckingResourceMutatorWrapper(mutator ResourceMutator, nodeToID NodeToIDFunc) *AckingResourceMutatorWrapper { return &AckingResourceMutatorWrapper{ mutator: mutator, nodeToID: nodeToID, pendingCompletions: make(map[*completion.Completion]*pendingCompletion), } }
[ "func", "NewAckingResourceMutatorWrapper", "(", "mutator", "ResourceMutator", ",", "nodeToID", "NodeToIDFunc", ")", "*", "AckingResourceMutatorWrapper", "{", "return", "&", "AckingResourceMutatorWrapper", "{", "mutator", ":", "mutator", ",", "nodeToID", ":", "nodeToID", ...
// NewAckingResourceMutatorWrapper creates a new AckingResourceMutatorWrapper // to wrap the given ResourceMutator. The given NodeToIDFunc is used to extract // a string identifier from an Envoy Node identifier.
[ "NewAckingResourceMutatorWrapper", "creates", "a", "new", "AckingResourceMutatorWrapper", "to", "wrap", "the", "given", "ResourceMutator", ".", "The", "given", "NodeToIDFunc", "is", "used", "to", "extract", "a", "string", "identifier", "from", "an", "Envoy", "Node", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/ack.go#L118-L124
162,497
cilium/cilium
pkg/envoy/xds/ack.go
HandleResourceVersionAck
func (m *AckingResourceMutatorWrapper) HandleResourceVersionAck(ackVersion uint64, nackVersion uint64, node *envoy_api_v2_core.Node, resourceNames []string, typeURL string, detail string) { ackLog := log.WithFields(logrus.Fields{ logfields.XDSVersionInfo: ackVersion, logfields.XDSNonce: nackVersion, logfields.XDSClientNode: node, logfields.XDSTypeURL: typeURL, }) nodeID, err := m.nodeToID(node) if err != nil { // Ignore ACKs from unknown or misconfigured nodes which have invalid // node identifiers. ackLog.WithError(err).Warning("invalid ID in Node identifier; ignoring ACK") return } m.locker.Lock() defer m.locker.Unlock() remainingCompletions := make(map[*completion.Completion]*pendingCompletion, len(m.pendingCompletions)) for comp, pending := range m.pendingCompletions { if comp.Err() != nil { // Completion was canceled or timed out. // Remove from pending list. ackLog.Debugf("completion context was canceled: %v", pending) continue } if pending.typeURL == typeURL { if pending.version <= nackVersion { // Get the set of resource names we are still waiting for the node // to ACK. remainingResourceNames, found := pending.remainingNodesResources[nodeID] if found { for _, name := range resourceNames { delete(remainingResourceNames, name) } if len(remainingResourceNames) == 0 { delete(pending.remainingNodesResources, nodeID) } if len(pending.remainingNodesResources) == 0 { // Completed. Notify and remove from pending list. if pending.version <= ackVersion { ackLog.Debugf("completing ACK: %v", pending) comp.Complete(nil) } else { ackLog.Debugf("completing NACK: %v", pending) comp.Complete(&ProxyError{Err: ErrNackReceived, Detail: detail}) } continue } } } } // Completion didn't match or is still waiting for some ACKs. Keep it // in the pending list. remainingCompletions[comp] = pending } m.pendingCompletions = remainingCompletions }
go
func (m *AckingResourceMutatorWrapper) HandleResourceVersionAck(ackVersion uint64, nackVersion uint64, node *envoy_api_v2_core.Node, resourceNames []string, typeURL string, detail string) { ackLog := log.WithFields(logrus.Fields{ logfields.XDSVersionInfo: ackVersion, logfields.XDSNonce: nackVersion, logfields.XDSClientNode: node, logfields.XDSTypeURL: typeURL, }) nodeID, err := m.nodeToID(node) if err != nil { // Ignore ACKs from unknown or misconfigured nodes which have invalid // node identifiers. ackLog.WithError(err).Warning("invalid ID in Node identifier; ignoring ACK") return } m.locker.Lock() defer m.locker.Unlock() remainingCompletions := make(map[*completion.Completion]*pendingCompletion, len(m.pendingCompletions)) for comp, pending := range m.pendingCompletions { if comp.Err() != nil { // Completion was canceled or timed out. // Remove from pending list. ackLog.Debugf("completion context was canceled: %v", pending) continue } if pending.typeURL == typeURL { if pending.version <= nackVersion { // Get the set of resource names we are still waiting for the node // to ACK. remainingResourceNames, found := pending.remainingNodesResources[nodeID] if found { for _, name := range resourceNames { delete(remainingResourceNames, name) } if len(remainingResourceNames) == 0 { delete(pending.remainingNodesResources, nodeID) } if len(pending.remainingNodesResources) == 0 { // Completed. Notify and remove from pending list. if pending.version <= ackVersion { ackLog.Debugf("completing ACK: %v", pending) comp.Complete(nil) } else { ackLog.Debugf("completing NACK: %v", pending) comp.Complete(&ProxyError{Err: ErrNackReceived, Detail: detail}) } continue } } } } // Completion didn't match or is still waiting for some ACKs. Keep it // in the pending list. remainingCompletions[comp] = pending } m.pendingCompletions = remainingCompletions }
[ "func", "(", "m", "*", "AckingResourceMutatorWrapper", ")", "HandleResourceVersionAck", "(", "ackVersion", "uint64", ",", "nackVersion", "uint64", ",", "node", "*", "envoy_api_v2_core", ".", "Node", ",", "resourceNames", "[", "]", "string", ",", "typeURL", "string...
// 'ackVersion' is the last version that was acked. 'nackVersion', if greater than 'nackVersion', is the last version that was NACKed.
[ "ackVersion", "is", "the", "last", "version", "that", "was", "acked", ".", "nackVersion", "if", "greater", "than", "nackVersion", "is", "the", "last", "version", "that", "was", "NACKed", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/ack.go#L220-L282
162,498
cilium/cilium
pkg/elf/symbols.go
sort
func (c symbolSlice) sort() symbolSlice { sort.Slice(c, func(i, j int) bool { return c[i].offset < c[j].offset }) return c }
go
func (c symbolSlice) sort() symbolSlice { sort.Slice(c, func(i, j int) bool { return c[i].offset < c[j].offset }) return c }
[ "func", "(", "c", "symbolSlice", ")", "sort", "(", ")", "symbolSlice", "{", "sort", ".", "Slice", "(", "c", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "c", "[", "i", "]", ".", "offset", "<", "c", "[", "j", "]", ".", ...
// sort a slice of symbols by offset.
[ "sort", "a", "slice", "of", "symbols", "by", "offset", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/elf/symbols.go#L92-L95
162,499
cilium/cilium
pkg/api/apipanic.go
ServeHTTP
func (h *APIPanicHandler) ServeHTTP(wr http.ResponseWriter, req *http.Request) { defer func() { if r := recover(); r != nil { fields := logrus.Fields{ "panic_message": r, "url": req.URL.String(), "method": req.Method, "client": req.RemoteAddr, } log.WithFields(fields).Warn("Cilium API handler panicked") if logging.DefaultLogger.IsLevelEnabled(logrus.DebugLevel) { os.Stdout.Write(debug.Stack()) } wr.WriteHeader(http.StatusInternalServerError) if _, err := wr.Write([]byte("Internal error occurred, check Cilium logs for details.")); err != nil { log.WithError(err).Debug("Failed to write API response") } } }() h.Next.ServeHTTP(wr, req) }
go
func (h *APIPanicHandler) ServeHTTP(wr http.ResponseWriter, req *http.Request) { defer func() { if r := recover(); r != nil { fields := logrus.Fields{ "panic_message": r, "url": req.URL.String(), "method": req.Method, "client": req.RemoteAddr, } log.WithFields(fields).Warn("Cilium API handler panicked") if logging.DefaultLogger.IsLevelEnabled(logrus.DebugLevel) { os.Stdout.Write(debug.Stack()) } wr.WriteHeader(http.StatusInternalServerError) if _, err := wr.Write([]byte("Internal error occurred, check Cilium logs for details.")); err != nil { log.WithError(err).Debug("Failed to write API response") } } }() h.Next.ServeHTTP(wr, req) }
[ "func", "(", "h", "*", "APIPanicHandler", ")", "ServeHTTP", "(", "wr", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "defer", "func", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", ...
// ServeHTTP implements the http.Handler interface. // It recovers from panics of all next handlers and logs them
[ "ServeHTTP", "implements", "the", "http", ".", "Handler", "interface", ".", "It", "recovers", "from", "panics", "of", "all", "next", "handlers", "and", "logs", "them" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/api/apipanic.go#L34-L54