python / python/cpython

3.15.0b2 test_shutil failure on FreeBSD in a "poudriere jail" mounted atop ZFS file system

Aperta
#150,984 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

OS-freebsd tests type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:

Greetings,

building Python 3.15.0b2 (beta 2) on FreeBSD in a poudriere jail mounted atop a ZFS file system, where poudriere is the tool that FreeBSD uses for package building, and a jail is a stricter companion of a chroot, we get this make test failure in test_shutil. Note that the OSError 45 (aka EOPNOTSUPP) relates to the test_tempfile failure reported in gh-150982, #150982.

It is not clear to me why a jail or how poudriere mounts the underlying filesystem would NOT support UF_OPAQUE because outside poudriere (albeit on a different minor version of the operating system), I don't get OSError [Errno 45] exceptions on the same test.

As suggested in #150982, I am wondering whether it would be useful to map this particular errno (EOPNOTSUPP) to a NotImplementedError exception and handle that.

This is the test with offending lines marked with python comments in three (3) places,
followed by the unittest output.

    def test_move_dir_permission_denied(self):
        # bpo-42782: shutil.move should not create destination directories
        # if the source directory cannot be removed.
        try:
            os.mkdir(TESTFN_SRC)
            os.lchflags(TESTFN_SRC, stat.SF_IMMUTABLE)

            # Testing on an empty immutable directory
            # TESTFN_DST should not exist if shutil.move failed
            self.assertRaises(PermissionError, shutil.move, TESTFN_SRC, TESTFN_DST)
            self.assertFalse(TESTFN_DST in os.listdir())

            # Create a file and keep the directory immutable
            os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)   # <-- offender #1
            os_helper.create_empty_file(os.path.join(TESTFN_SRC, 'child'))
            os.lchflags(TESTFN_SRC, stat.SF_IMMUTABLE)

            # Testing on a non-empty immutable directory
            # TESTFN_DST should not exist if shutil.move failed
            self.assertRaises(PermissionError, shutil.move, TESTFN_SRC, TESTFN_DST)
            self.assertFalse(TESTFN_DST in os.listdir())
        finally:
            if os.path.exists(TESTFN_SRC):
                os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)   # <-- offender #2
                os_helper.rmtree(TESTFN_SRC)
            if os.path.exists(TESTFN_DST):
                os.lchflags(TESTFN_DST, stat.UF_OPAQUE)   # <-- not reached, but would be offender #3.
                os_helper.rmtree(TESTFN_DST)
ERROR: test_move_dir_permission_denied (test.test_shutil.TestMove.test_move_dir_permission_denied)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_shutil.py", line 3051, in test_move_dir_permission_denied
    os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 45] Operation not supported: '@test_22085_tmpæ_SRC'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_shutil.py", line 3061, in test_move_dir_permission_denied
    os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 45] Operation not supported: '@test_22085_tmpæ_SRC'

----------------------------------------------------------------------
Ran 225 tests in 1.029s

FAILED (errors=1, skipped=69)
Warning -- files was modified by test_shutil
Warning --   Before: []
Warning --   After:  ['@test_22085_tmpæ_SRC/'] 
CPython versions tested on:

3.15

Operating systems tested on:

Other

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con test/test_shutil.py e TestMove.test_move_dir_permission_denied, quindi riproduci il problema nel jail poudriere di FreeBSD segnalato su ZFS. Analizza gli errori EOPNOTSUPP di os.lchflags con UF_OPAQUE, inclusa la pulizia, e conferma che il test venga completato senza lasciare file temporanei.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
operating-systems, testing-qa
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.