MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / SyncState

Method SyncState

internal/state/manager.go:77–111  ·  view source on GitHub ↗
(ctx context.Context, customResource interface{}, infoCatalog InfoCatalog)

Source from the content-addressed store, hash-verified

75}
76
77func (m *stateManager) SyncState(ctx context.Context, customResource interface{}, infoCatalog InfoCatalog) Results {
78 logger := log.FromContext(ctx)
79 logger.V(consts.LogLevelInfo).Info("Syncing system state")
80
81 managerResult := Results{
82 Status: SyncStateNotReady,
83 }
84 statesReady := true
85
86 for _, state := range m.states {
87 logger.V(consts.LogLevelInfo).Info("Sync State", "Name", state.Name(), "Description", state.Description())
88 stateCtx := log.IntoContext(ctx, logger.WithName("state").WithName(state.Name()))
89 ss, err := state.Sync(stateCtx, customResource, infoCatalog)
90 result := Result{StateName: state.Name(), Status: ss, ErrInfo: err}
91 managerResult.StatesStatus = append(managerResult.StatesStatus, result)
92
93 if result.Status == SyncStateNotReady || result.Status == SyncStateError {
94 statesReady = false
95 }
96
97 if result.ErrInfo != nil {
98 logger.V(consts.LogLevelWarning).Error(result.ErrInfo, "Error while syncing state")
99 }
100 }
101
102 if statesReady {
103 // Done Syncing CR
104 managerResult.Status = SyncStateReady
105 logger.V(consts.LogLevelInfo).Info("Sync Done for custom resource")
106 } else {
107 logger.V(consts.LogLevelInfo).Info("Sync not Done for custom resource")
108 }
109
110 return managerResult
111}
112
113func newStates(crdKind string, namespace string, k8sClient client.Client, scheme *runtime.Scheme) ([]State, error) {
114 switch crdKind {

Callers

nothing calls this directly

Calls 5

WithNameMethod · 0.80
ErrorMethod · 0.80
NameMethod · 0.65
DescriptionMethod · 0.65
SyncMethod · 0.65

Tested by

no test coverage detected