[v4,07/13] isar-bootstrap: Connect to gpg-agent before adding keys

Message ID ac64398b61e0f3b9b2ead782f4045c612fbae4ac.1602079290.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series Complete backlog: SDK, assorting fixed and cleanups | expand

Commit Message

Jan Kiszka Oct. 7, 2020, 5:01 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

We have recurring issues in CI with the gpg-agent not being ready when
trying to use apt-key:

gpg: can't connect to the agent: IPC connect call failed

Work around this by connecting upfront to the agent, retrying that in a
bounded loop.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Jan Kiszka Nov. 20, 2020, 9:41 p.m. UTC | #1
On 07.10.20 16:01, [ext] Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> We have recurring issues in CI with the gpg-agent not being ready when
> trying to use apt-key:
> 
> gpg: can't connect to the agent: IPC connect call failed
> 
> Work around this by connecting upfront to the agent, retrying that in a
> bounded loop.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
> index fbfe669d..1c5dba74 100644
> --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
> +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
> @@ -303,10 +303,13 @@ isar_bootstrap() {
>                               "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar.conf"
>              find ${APT_KEYS_DIR}/ -type f | while read keyfile
>              do
> -                kfn="$(basename $keyfile)"
> +                export kfn="$(basename $keyfile)"
>                  cp $keyfile "${ROOTFSDIR}/tmp/$kfn"
> -                chroot "${ROOTFSDIR}" /usr/bin/apt-key \
> -                   --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn"
> +                chroot "${ROOTFSDIR}" sh -c '
> +                    for i in $(seq 10); do
> +                        /usr/bin/apt-key --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn" && break
> +                        sleep 1
> +                    done'
>                  rm "${ROOTFSDIR}/tmp/$kfn"
>              done
>  
> 

No more gpg-related CI failures since this has been applied to our
layers. You said you have an even better version, but that wasn't even
shared so far.

Jan
Jan Kiszka Dec. 13, 2020, 9:03 p.m. UTC | #2
On 21.11.20 08:41, [ext] Jan Kiszka wrote:
> On 07.10.20 16:01, [ext] Jan Kiszka wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> We have recurring issues in CI with the gpg-agent not being ready when
>> trying to use apt-key:
>>
>> gpg: can't connect to the agent: IPC connect call failed
>>
>> Work around this by connecting upfront to the agent, retrying that in a
>> bounded loop.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 9 ++++++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
>> index fbfe669d..1c5dba74 100644
>> --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
>> +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
>> @@ -303,10 +303,13 @@ isar_bootstrap() {
>>                               "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar.conf"
>>              find ${APT_KEYS_DIR}/ -type f | while read keyfile
>>              do
>> -                kfn="$(basename $keyfile)"
>> +                export kfn="$(basename $keyfile)"
>>                  cp $keyfile "${ROOTFSDIR}/tmp/$kfn"
>> -                chroot "${ROOTFSDIR}" /usr/bin/apt-key \
>> -                   --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn"
>> +                chroot "${ROOTFSDIR}" sh -c '
>> +                    for i in $(seq 10); do
>> +                        /usr/bin/apt-key --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn" && break
>> +                        sleep 1
>> +                    done'
>>                  rm "${ROOTFSDIR}/tmp/$kfn"
>>              done
>>  
>>
> 
> No more gpg-related CI failures since this has been applied to our
> layers. You said you have an even better version, but that wasn't even
> shared so far.
> 

Yet another ping on this.

Jan
Baurzhan Ismagulov Dec. 16, 2020, 1:36 a.m. UTC | #3
On Sat, Nov 21, 2020 at 08:41:57AM +0100, Jan Kiszka wrote:
> No more gpg-related CI failures since this has been applied to our
> layers. You said you have an even better version, but that wasn't even
> shared so far.

I haven't seen this after migrating to a faster server, sorry for the delay.
I'll share the dirty version and send v2 after cleaning up.

With kind regards,
Baurzhan.

Patch

diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index fbfe669d..1c5dba74 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -303,10 +303,13 @@  isar_bootstrap() {
                              "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar.conf"
             find ${APT_KEYS_DIR}/ -type f | while read keyfile
             do
-                kfn="$(basename $keyfile)"
+                export kfn="$(basename $keyfile)"
                 cp $keyfile "${ROOTFSDIR}/tmp/$kfn"
-                chroot "${ROOTFSDIR}" /usr/bin/apt-key \
-                   --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn"
+                chroot "${ROOTFSDIR}" sh -c '
+                    for i in $(seq 10); do
+                        /usr/bin/apt-key --keyring ${THIRD_PARTY_APT_KEYRING} add "/tmp/$kfn" && break
+                        sleep 1
+                    done'
                 rm "${ROOTFSDIR}/tmp/$kfn"
             done