diff --git a/docs/crio.8.md b/docs/crio.8.md index 7983168dc9d..95551a4bf79 100644 --- a/docs/crio.8.md +++ b/docs/crio.8.md @@ -337,7 +337,7 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...] **--seccomp-use-default-when-empty**: Use the default seccomp profile when an empty one is specified -**--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 fcedfba38dd..11557b62b57 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 35728887843..3177586e028 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 ec031167df3..bb71d7604ad 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 c8b3a5d3f62..3d0797902c6 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -760,15 +760,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.