diff --git a/docs/crio.8.md b/docs/crio.8.md index 2f705715939..3b54151f756 100644 --- a/docs/crio.8.md +++ b/docs/crio.8.md @@ -331,7 +331,7 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...] **--seccomp-use-default-when-empty**="": Use the default seccomp profile when an empty one is specified (default: false) -**--selinux**: Enable selinux support (default: false) +**--selinux**: Enable selinux support (default: true) **--separate-pull-cgroup**="": [EXPERIMENTAL] Pull in new cgroup (default: "") diff --git a/docs/crio.conf.5.md b/docs/crio.conf.5.md index c342e915c1e..c2bab5cea0a 100644 --- a/docs/crio.conf.5.md +++ b/docs/crio.conf.5.md @@ -49,7 +49,7 @@ CRI-O reads its storage defaults from the containers-storage.conf(5) file locate It is used to check if crio wipe should wipe containers, which should always happen on a node reboot -**version_file_persist**="/var/lib/crio/version" +**version_file_persist**="" Location for CRI-O to lay down the persistent version file. It is used to check if crio wipe should wipe images, which should only happen when CRI-O has been upgraded diff --git a/internal/version/version.go b/internal/version/version.go index 50071154ca7..f7a3c663c35 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -1,9 +1,7 @@ package version import ( - "bufio" "fmt" - "io/ioutil" "os" "path/filepath" "reflect" @@ -56,14 +54,12 @@ func ShouldCrioWipe(versionFileName string) (bool, error) { // shouldCrioWipe is an internal function for testing purposes func shouldCrioWipe(versionFileName, versionString string) (bool, error) { - f, err := os.Open(versionFileName) - if err != nil { - return true, errors.Errorf("version file %s not found: %v", versionFileName, err) + if versionFileName == "" { + return false, nil } - r := bufio.NewReader(f) - versionBytes, err := ioutil.ReadAll(r) + versionBytes, err := os.ReadFile(versionFileName) if err != nil { - return true, errors.Errorf("reading version file %s failed: %v", versionFileName, err) + return true, errors.Errorf("version file %s not found: %v", versionFileName, err) } // parse the version that was laid down by a previous invocation of crio @@ -99,6 +95,9 @@ func LogVersion() { // writeVersionFile is an internal function for testing purposes func writeVersionFile(file, gitCommit, version string) error { + if file == "" { + return nil + } current, err := parseVersionConstant(version, gitCommit) // Sanity check-this should never happen if err != nil { diff --git a/internal/version/version_test.go b/internal/version/version_test.go index 0d8f62478b5..51166a63107 100644 --- a/internal/version/version_test.go +++ b/internal/version/version_test.go @@ -74,10 +74,10 @@ var _ = t.Describe("Version", func() { _, err = ioutil.ReadFile(filename) Expect(err).To(BeNil()) }) - It("should fail to upgrade with unspecified version", func() { + It("should not wipe with empty version file", func() { upgrade, err := shouldCrioWipe("", tempVersion) - Expect(upgrade).To(BeTrue()) - Expect(err).ToNot(BeNil()) + Expect(upgrade).To(BeFalse()) + Expect(err).To(BeNil()) }) It("should fail to upgrade with empty version file", func() { tempFileName := tempFileName diff --git a/pkg/config/config.go b/pkg/config/config.go index 626d39ef4f5..64e025ac0a5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -717,15 +717,14 @@ func DefaultConfig() (*Config, error) { DockerRegistryUserAgent: useragent.Get(), }, RootConfig: RootConfig{ - Root: storeOpts.GraphRoot, - RunRoot: storeOpts.RunRoot, - Storage: storeOpts.GraphDriverName, - StorageOptions: storeOpts.GraphDriverOptions, - LogDir: "/var/log/crio/pods", - VersionFile: CrioVersionPathTmp, - VersionFilePersist: CrioVersionPathPersist, - CleanShutdownFile: CrioCleanShutdownFile, - InternalWipe: true, + Root: storeOpts.GraphRoot, + RunRoot: storeOpts.RunRoot, + Storage: storeOpts.GraphDriverName, + StorageOptions: storeOpts.GraphDriverOptions, + LogDir: "/var/log/crio/pods", + VersionFile: CrioVersionPathTmp, + CleanShutdownFile: CrioCleanShutdownFile, + InternalWipe: true, }, APIConfig: APIConfig{ Listen: CrioSocketPath, diff --git a/pkg/config/config_unix.go b/pkg/config/config_unix.go index 4c72673e78c..156098504fd 100644 --- a/pkg/config/config_unix.go +++ b/pkg/config/config_unix.go @@ -23,10 +23,6 @@ const ( // used to check if we should wipe containers CrioVersionPathTmp = "/var/run/crio/version" - // CrioVersionPathPersist is where the CRI-O version file is located - // used to check whether we've upgraded, and thus need to remove images - CrioVersionPathPersist = "/var/lib/crio/version" - // CrioCleanShutdownFile is the location CRI-O will lay down the clean shutdown file // that checks whether we've had time to sync before shutting down. // If not, crio wipe will clear the storage directory.