Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Allow list for io.openshift labels (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwindasr committed Oct 12, 2022
1 parent 169b65d commit 5d29bb5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
22 changes: 14 additions & 8 deletions doozerlib/dblib.py
Expand Up @@ -327,12 +327,18 @@ def handle_missing_columns(self, payload, table_name):
for column in missing_columns:
missing_column = column[0]
column_type = column[1][0]
cursor.execute(f"alter table {table_name} add column `{missing_column}` {column_type}")
self._table_column_cache[table_name][missing_column] = True

self.runtime.logger.info("Added new column [{}] of identified type [{}] to table [{}] "
"of database [{}].".format(missing_column, column_type,
table_name, self.db))
try:
cursor.execute(f"alter table {table_name} add column `{missing_column}` {column_type}")
self._table_column_cache[table_name][missing_column] = True

self.runtime.logger.info("Added new column [{}] of identified type [{}] to table [{}] "
"of database [{}].".format(missing_column, column_type,
table_name, self.db))
except Exception as e:
self.runtime.logger.warning("Could not add new column [{}] of identified type [{}] to table [{}] "
"of database [{}]. Error: {}".format(missing_column, column_type,
table_name, self.db, e))
del payload[missing_column] # delete the column from the payload

cursor.close()

Expand Down Expand Up @@ -489,8 +495,8 @@ def __exit__(self, *args):
else:
attr_payload[self.db.rename_to_valid_column(k)] = v
self.db.create_payload_entry(attr_payload, self.table, self.dry_run)
except:
pass
except Exception as e:
self.runtime.logger.error(f"Payload insert into database failed: {e}")

self._tl.record = self.previous_record

Expand Down
13 changes: 10 additions & 3 deletions doozerlib/distgit.py
Expand Up @@ -1173,9 +1173,16 @@ def update_build_db(self, success_flag, task_id=None, scratch=False):

Record.set('label.version', dfp.labels.get('version', ''))
Record.set('label.release', dfp.labels.get('release', ''))
for k, v in dfp.labels.items():
if k.startswith('io.openshift.'):
Record.set(f'label.{k}', dfp.labels[k])

# Ignore io.openshift labels other than the ones specified below
for label in [
'io.openshift.build.source-location',
'io.openshift.build.commit.id',
'io.openshift.build.commit.url',
'io.openshift.release.operator',
'io.openshift.build.versions']:
if label in dfp.labels:
Record.set(f'label.{label}', dfp.labels[label])

for k, v in dfp.envs.items():
if k.startswith('KUBE_') or k.startswith('OS_'):
Expand Down

0 comments on commit 5d29bb5

Please sign in to comment.