github.com/fafucoder/cilium@v1.6.11/pkg/endpoint/regeneration/regeneration_context.go (about)

     1  // Copyright 2016-2019 Authors of Cilium
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package regeneration
    16  
    17  import (
    18  	"context"
    19  )
    20  
    21  // DatapathRegenerationLevel determines what is expected of the datapath when
    22  // a regeneration event is processed.
    23  type DatapathRegenerationLevel int
    24  
    25  const (
    26  	// RegenerateWithoutDatapath indicates that datapath rebuild or reload
    27  	// is not required to implement this regeneration.
    28  	RegenerateWithoutDatapath DatapathRegenerationLevel = iota
    29  	// RegenerateWithDatapathLoad indicates that the datapath must be
    30  	// reloaded but not recompiled to implement this regeneration.
    31  	RegenerateWithDatapathLoad
    32  	// RegenerateWithDatapathRewrite indicates that the datapath must be
    33  	// recompiled and reloaded to implement this regeneration.
    34  	RegenerateWithDatapathRewrite
    35  	// RegenerateWithDatapathRebuild indicates that the datapath must be
    36  	// fully recompiled and reloaded without using any cached templates.
    37  	RegenerateWithDatapathRebuild
    38  )
    39  
    40  // String converts a DatapathRegenerationLevel into a human-readable string.
    41  func (r DatapathRegenerationLevel) String() string {
    42  	switch r {
    43  	case RegenerateWithoutDatapath:
    44  		return "no-rebuild"
    45  	case RegenerateWithDatapathLoad:
    46  		return "reload"
    47  	case RegenerateWithDatapathRewrite:
    48  		return "rewrite+load"
    49  	case RegenerateWithDatapathRebuild:
    50  		return "compile+load"
    51  	default:
    52  		break
    53  	}
    54  	return "BUG: Unknown DatapathRegenerationLevel"
    55  }
    56  
    57  // ExternalRegenerationMetadata contains any information about a regeneration that
    58  // the endpoint subsystem should be made aware of for a given endpoint.
    59  type ExternalRegenerationMetadata struct {
    60  	// Reason provides context to source for the regeneration, which is
    61  	// used to generate useful log messages.
    62  	Reason string
    63  
    64  	// RegenerationLevel forces datapath regeneration according to the
    65  	// levels defined in the DatapathRegenerationLevel description.
    66  	RegenerationLevel DatapathRegenerationLevel
    67  
    68  	ParentContext context.Context
    69  }