@@ -47,7 +47,10 @@ const (
4747 configMapMaxSize = 1048570 // 1MB for etcd limit. Over this, you get an error.
4848)
4949
50- func getConfigMapName (prefix , nodeName string ) string {
50+ func getConfigMapName (prefix string , nodeName string , migrationMode bool ) string {
51+ if migrationMode {
52+ return prefix + "-migration"
53+ }
5154 return prefix + "-" + nodeName
5255}
5356
@@ -176,7 +179,7 @@ func newLogConfigMap(owner *unstructured.Unstructured, configMapName, contentkey
176179 }
177180}
178181
179- func newInformationalConfigMap (owner * unstructured.Unstructured , configMapName string , node string , annotations map [string ]string ) * corev1.ConfigMap {
182+ func newInformationalConfigMap (owner * unstructured.Unstructured , configMapName string , node string , annotations map [string ]string , labels map [ string ] string ) * corev1.ConfigMap {
180183 return & corev1.ConfigMap {
181184 TypeMeta : metav1.TypeMeta {
182185 APIVersion : "v1" ,
@@ -193,21 +196,38 @@ func newInformationalConfigMap(owner *unstructured.Unstructured, configMapName s
193196 UID : owner .GetUID (),
194197 },
195198 },
196- Labels : map [string ]string {
197- common .IntegrityOwnerLabelKey : owner .GetName (),
198- common .IntegrityLogLabelKey : "" ,
199- common .IntegrityConfigMapNodeLabelKey : node ,
200- },
199+ Labels : labels ,
201200 },
202201 }
203202}
204203
204+ func getLogCollectorConfigMapLabels (owner * unstructured.Unstructured , node string , migrationMode bool ) map [string ]string {
205+ if migrationMode {
206+ return map [string ]string {
207+ common .IntegrityOwnerLabelKey : owner .GetName (),
208+ common .IntegrityMigrationLabelKey : "" ,
209+ }
210+ } else {
211+ return map [string ]string {
212+ common .IntegrityOwnerLabelKey : owner .GetName (),
213+ common .IntegrityLogLabelKey : "" ,
214+ common .IntegrityConfigMapNodeLabelKey : node ,
215+ }
216+ }
217+ }
218+
205219// reportOK creates a blank configMap with no error annotation. This is treated by the controller as an OK signal.
206220func reportOK (ctx context.Context , conf * daemonConfig , rt * daemonRuntime ) error {
207221 DBG ("creating temporary configMap '%s' to report a successful scan result" , conf .LogCollectorConfigMapName )
208222 return backoff .Retry (func () error {
209223 fi := rt .GetFileIntegrityInstance ()
210- confMap := newInformationalConfigMap (fi , conf .LogCollectorConfigMapName , conf .LogCollectorNode , nil )
224+ // check if we are on migration mode if so we need to create a configmap with the migration annotation
225+ annotations := map [string ]string {}
226+ if conf .RunMigrationCheck {
227+ annotations [common .AideConfigAutoMigrationFailedAnnotationKey ] = "false"
228+ }
229+ labels := getLogCollectorConfigMapLabels (fi , conf .LogCollectorNode , conf .RunMigrationCheck )
230+ confMap := newInformationalConfigMap (fi , conf .LogCollectorConfigMapName , conf .LogCollectorNode , annotations , labels )
211231 _ , err := rt .clientset .CoreV1 ().ConfigMaps (conf .Namespace ).Create (ctx , confMap , metav1.CreateOptions {})
212232 return err
213233 }, backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ))
@@ -218,9 +238,11 @@ func reportError(ctx context.Context, msg string, conf *daemonConfig, rt *daemon
218238 return backoff .Retry (func () error {
219239 fi := rt .GetFileIntegrityInstance ()
220240 annotations := map [string ]string {
221- common .IntegrityLogErrorAnnotationKey : msg ,
241+ common .IntegrityLogErrorAnnotationKey : msg ,
242+ common .AideConfigAutoMigrationFailedAnnotationKey : "true" ,
222243 }
223- confMap := newInformationalConfigMap (fi , conf .LogCollectorConfigMapName , conf .LogCollectorNode , annotations )
244+ labels := getLogCollectorConfigMapLabels (fi , conf .LogCollectorNode , conf .RunMigrationCheck )
245+ confMap := newInformationalConfigMap (fi , conf .LogCollectorConfigMapName , conf .LogCollectorNode , annotations , labels )
224246 _ , err := rt .clientset .CoreV1 ().ConfigMaps (conf .Namespace ).Create (ctx , confMap , metav1.CreateOptions {})
225247 return err
226248 }, backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ))
0 commit comments