From 1a946e5961385717c5aea4ab71de3bf7fe6bb6bd Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Mon, 11 Jul 2022 12:45:40 -0400 Subject: [PATCH 01/11] MGMT-10209: Pass in icsp file to be used for 'oc adm release extract' Pass in an ICSP file via an environment variable to be used when running the oc command to extract the installer. Note that the ImageContentSources are also in the generated install-config https://github.com/openshift/assisted-service/blob/master/internal/installcfg/installcfg.go#L113. This PR allows the ICSP to be passed in, in the API format that the oc command expects. --- internal/ignition/ignition.go | 6 +++-- internal/ignition/ignition_test.go | 20 ++++++++--------- internal/installercache/installercache.go | 4 ++-- internal/oc/release.go | 27 ++++++++++++++--------- internal/oc/release_test.go | 12 +++++----- pkg/generator/generator.go | 3 ++- 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 78b2fd93e259..3b6a545ea087 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -420,6 +420,7 @@ type installerGenerator struct { providerRegistry registry.ProviderRegistry installerReleaseImageOverride string clusterTLSCertOverrideDir string + icspFile string } // IgnitionConfig contains the attributes required to build the discovery ignition file @@ -452,7 +453,7 @@ func NewBuilder(log logrus.FieldLogger, staticNetworkConfig staticnetworkconfig. // NewGenerator returns a generator that can generate ignition files func NewGenerator(workDir string, installerDir string, cluster *common.Cluster, releaseImage string, releaseImageMirror string, serviceCACert, installInvoker string, s3Client s3wrapper.API, log logrus.FieldLogger, operatorsApi operators.API, - providerRegistry registry.ProviderRegistry, installerReleaseImageOverride, clusterTLSCertOverrideDir string) Generator { + providerRegistry registry.ProviderRegistry, installerReleaseImageOverride, clusterTLSCertOverrideDir string, icspFile string) Generator { return &installerGenerator{ cluster: cluster, log: log, @@ -468,6 +469,7 @@ func NewGenerator(workDir string, installerDir string, cluster *common.Cluster, providerRegistry: providerRegistry, installerReleaseImageOverride: installerReleaseImageOverride, clusterTLSCertOverrideDir: clusterTLSCertOverrideDir, + icspFile: icspFile, } } @@ -487,7 +489,7 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, } installerPath, err := installercache.Get(g.installerReleaseImageOverride, g.releaseImageMirror, g.installerDir, - g.cluster.PullSecret, platformType, log) + g.cluster.PullSecret, platformType, g.icspFile, log) if err != nil { return errors.Wrap(err, "failed to get installer path") } diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index 3eed4a5066c4..007dbcaaf522 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -123,7 +123,7 @@ var _ = Describe("Bootstrap Ignition Update", func() { }, } g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", mockS3Client, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err = g.updateBootstrap(context.Background(), examplePath) @@ -266,7 +266,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 Describe("update ignitions", func() { It("with ca cert file", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", caCertPath, "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.updateIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -289,7 +289,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with no ca cert file", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.updateIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -308,7 +308,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with service ips", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.UpdateEtcHosts("10.10.10.1,10.10.10.2") Expect(err).NotTo(HaveOccurred()) @@ -331,7 +331,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with no service ips", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.UpdateEtcHosts("") Expect(err).NotTo(HaveOccurred()) @@ -361,7 +361,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 Context("DHCP generation", func() { It("Definitions only", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) g.encodedDhcpFileContents = "data:,abc" err := g.updateIgnitions() @@ -380,7 +380,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("Definitions+leases", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) g.encodedDhcpFileContents = "data:,abc" cluster.ApiVipLease = "api" @@ -503,7 +503,7 @@ var _ = Describe("createHostIgnitions", func() { } g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.createHostIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -549,7 +549,7 @@ var _ = Describe("createHostIgnitions", func() { }} g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) err := g.createHostIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -1423,7 +1423,7 @@ var _ = Describe("Import Cluster TLS Certs for ephemeral installer", func() { It("copies the tls cert files", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", certDir).(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", certDir, "").(*installerGenerator) err := g.importClusterTLSCerts(context.Background()) Expect(err).NotTo(HaveOccurred()) diff --git a/internal/installercache/installercache.go b/internal/installercache/installercache.go index bf6b94c943f6..fd6b6fb90fbe 100644 --- a/internal/installercache/installercache.go +++ b/internal/installercache/installercache.go @@ -39,7 +39,7 @@ func (i *installers) Get(releaseID string) *release { // Get returns the path to an openshift-baremetal-install binary extracted from // the referenced release image. Tries the mirror release image first if it's set. It is safe for concurrent use. A cache of // binaries is maintained to reduce re-downloading of the same release. -func Get(releaseID, releaseIDMirror, cacheDir, pullSecret string, platformType models.PlatformType, log logrus.FieldLogger) (string, error) { +func Get(releaseID, releaseIDMirror, cacheDir, pullSecret string, platformType models.PlatformType, icspFile string, log logrus.FieldLogger) (string, error) { r := cache.Get(releaseID) r.Lock() defer r.Unlock() @@ -49,7 +49,7 @@ func Get(releaseID, releaseIDMirror, cacheDir, pullSecret string, platformType m //cache miss if r.path == "" { path, err = oc.NewRelease(&executer.CommonExecuter{}, oc.Config{ - MaxTries: oc.DefaultTries, RetryDelay: oc.DefaltRetryDelay}).Extract(log, releaseID, releaseIDMirror, cacheDir, pullSecret, platformType) + MaxTries: oc.DefaultTries, RetryDelay: oc.DefaltRetryDelay}).Extract(log, releaseID, releaseIDMirror, cacheDir, pullSecret, platformType, icspFile) if err != nil { return "", err } diff --git a/internal/oc/release.go b/internal/oc/release.go index 8c5a6f5b339f..deeec5ecdf88 100644 --- a/internal/oc/release.go +++ b/internal/oc/release.go @@ -40,7 +40,7 @@ type Release interface { GetOpenshiftVersion(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, pullSecret string) (string, error) GetMajorMinorVersion(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, pullSecret string) (string, error) GetReleaseArchitecture(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, pullSecret string) (string, error) - Extract(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, cacheDir string, pullSecret string, platformType models.PlatformType) (string, error) + Extract(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, cacheDir string, pullSecret string, platformType models.PlatformType, icspFile string) (string, error) } type imageValue struct { @@ -61,10 +61,11 @@ func NewRelease(executer executer.Executer, config Config) Release { } const ( - templateGetImage = "oc adm release info --image-for=%s --insecure=%t %s" - templateGetVersion = "oc adm release info -o template --template '{{.metadata.version}}' --insecure=%t %s" - templateExtract = "oc adm release extract --command=%s --to=%s --insecure=%t %s" - templateImageInfo = "oc image info --output json %s" + templateGetImage = "oc adm release info --image-for=%s --insecure=%t %s" + templateGetVersion = "oc adm release info -o template --template '{{.metadata.version}}' --insecure=%t %s" + templateExtract = "oc adm release extract --command=%s --to=%s --insecure=%t %s" + templateExtractWithIcsp = "oc adm release extract --command=%s --to=%s --insecure=%t --icsp-file=%s %s" + templateImageInfo = "oc image info --output json %s" ) // GetMCOImage gets mcoImage url from the releaseImageMirror if provided. @@ -228,7 +229,7 @@ func (r *release) getOpenshiftVersionFromRelease(log logrus.FieldLogger, release // Extract openshift-baremetal-install binary from releaseImageMirror if provided. // Else extract from the source releaseImage -func (r *release) Extract(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, cacheDir string, pullSecret string, platformType models.PlatformType) (string, error) { +func (r *release) Extract(log logrus.FieldLogger, releaseImage string, releaseImageMirror string, cacheDir string, pullSecret string, platformType models.PlatformType, icspFile string) (string, error) { var path string var err error if releaseImage == "" && releaseImageMirror == "" { @@ -236,13 +237,13 @@ func (r *release) Extract(log logrus.FieldLogger, releaseImage string, releaseIm } if releaseImageMirror != "" { //TODO: Get mirror registry certificate from install-config - path, err = r.extractFromRelease(log, releaseImageMirror, cacheDir, pullSecret, true, platformType) + path, err = r.extractFromRelease(log, releaseImageMirror, cacheDir, pullSecret, true, platformType, icspFile) if err != nil { log.WithError(err).Errorf("failed to extract openshift-baremetal-install from mirror release image %s", releaseImageMirror) return "", err } } else { - path, err = r.extractFromRelease(log, releaseImage, cacheDir, pullSecret, false, platformType) + path, err = r.extractFromRelease(log, releaseImage, cacheDir, pullSecret, false, platformType, icspFile) if err != nil { log.WithError(err).Errorf("failed to extract openshift-baremetal-install from release image %s", releaseImageMirror) return "", err @@ -253,7 +254,7 @@ func (r *release) Extract(log logrus.FieldLogger, releaseImage string, releaseIm // extractFromRelease returns the path to an openshift-baremetal-install binary extracted from // the referenced release image. -func (r *release) extractFromRelease(log logrus.FieldLogger, releaseImage, cacheDir, pullSecret string, insecure bool, platformType models.PlatformType) (string, error) { +func (r *release) extractFromRelease(log logrus.FieldLogger, releaseImage, cacheDir, pullSecret string, insecure bool, platformType models.PlatformType, icspFile string) (string, error) { // Using platform type as an indication for which openshift install binary to use // (e.g. as non-x86_64 clusters should use the openshift-install binary). var binary string @@ -270,7 +271,13 @@ func (r *release) extractFromRelease(log logrus.FieldLogger, releaseImage, cache return "", err } - cmd := fmt.Sprintf(templateExtract, binary, workdir, insecure, releaseImage) + var cmd string + if icspFile == "" { + cmd = fmt.Sprintf(templateExtract, binary, workdir, insecure, releaseImage) + } else { + cmd = fmt.Sprintf(templateExtractWithIcsp, binary, workdir, insecure, icspFile, releaseImage) + } + _, err = retry.Do(r.config.MaxTries, r.config.RetryDelay, execute, log, r.executer, pullSecret, cmd) if err != nil { return "", err diff --git a/internal/oc/release_test.go b/internal/oc/release_test.go index 670275938610..8130ca6ece0e 100644 --- a/internal/oc/release_test.go +++ b/internal/oc/release_test.go @@ -284,7 +284,7 @@ var _ = Describe("oc", func() { args := splitStringToInterfacesArray(command) mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "", 0).Times(1) - path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal) + path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal, "") filePath := filepath.Join(cacheDir+"/"+releaseImage, baremetalInstallBinary) Expect(path).To(Equal(filePath)) Expect(err).ShouldNot(HaveOccurred()) @@ -296,14 +296,14 @@ var _ = Describe("oc", func() { args := splitStringToInterfacesArray(command) mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "", 0).Times(1) - path, err := oc.Extract(log, releaseImage, releaseImageMirror, cacheDir, pullSecret, models.PlatformTypeBaremetal) + path, err := oc.Extract(log, releaseImage, releaseImageMirror, cacheDir, pullSecret, models.PlatformTypeBaremetal, "") filePath := filepath.Join(cacheDir+"/"+releaseImageMirror, baremetalInstallBinary) Expect(path).To(Equal(filePath)) Expect(err).ShouldNot(HaveOccurred()) }) It("extract baremetal-install with no release image or mirror", func() { - path, err := oc.Extract(log, "", "", cacheDir, pullSecret, models.PlatformTypeBaremetal) + path, err := oc.Extract(log, "", "", cacheDir, pullSecret, models.PlatformTypeBaremetal, "") Expect(path).Should(BeEmpty()) Expect(err).Should(HaveOccurred()) }) @@ -314,7 +314,7 @@ var _ = Describe("oc", func() { mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "Failed to extract the installer", 1).Times(1) mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "", 0).Times(1) - path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal) + path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal, "") filePath := filepath.Join(cacheDir+"/"+releaseImage, baremetalInstallBinary) Expect(path).To(Equal(filePath)) Expect(err).ShouldNot(HaveOccurred()) @@ -326,7 +326,7 @@ var _ = Describe("oc", func() { args := splitStringToInterfacesArray(command) mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "Failed to extract the installer", 1).Times(5) - path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal) + path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeBaremetal, "") Expect(path).To(Equal("")) Expect(err).Should(HaveOccurred()) }) @@ -337,7 +337,7 @@ var _ = Describe("oc", func() { args := splitStringToInterfacesArray(command) mockExecuter.EXPECT().Execute(args[0], args[1:]...).Return("", "", 0).Times(1) - path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeNone) + path, err := oc.Extract(log, releaseImage, "", cacheDir, pullSecret, models.PlatformTypeNone, "") filePath := filepath.Join(cacheDir+"/"+releaseImage, installBinary) Expect(path).To(Equal(filePath)) Expect(err).ShouldNot(HaveOccurred()) diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 446eb1459391..06df2440fde3 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -32,6 +32,7 @@ type Config struct { ReleaseImageMirror string DummyIgnition bool `envconfig:"DUMMY_IGNITION"` InstallInvoker string `envconfig:"INSTALL_INVOKER" default:"assisted-installer"` + IcspFile string `envconfig:"ICSP_FILE" default:""` } type installGenerator struct { @@ -98,7 +99,7 @@ func (k *installGenerator) GenerateInstallConfig(ctx context.Context, cluster co generator = ignition.NewDummyGenerator(clusterWorkDir, &cluster, k.s3Client, log) } else { generator = ignition.NewGenerator(clusterWorkDir, installerCacheDir, &cluster, releaseImage, k.Config.ReleaseImageMirror, - k.Config.ServiceCACertPath, k.Config.InstallInvoker, k.s3Client, log, k.operatorsApi, k.providerRegistry, installerReleaseImageOverride, k.clusterTLSCertOverrideDir) + k.Config.ServiceCACertPath, k.Config.InstallInvoker, k.s3Client, log, k.operatorsApi, k.providerRegistry, installerReleaseImageOverride, k.clusterTLSCertOverrideDir, k.Config.IcspFile) } err = generator.Generate(ctx, cfg, k.getClusterPlatformType(cluster)) if err != nil { From 51cc08a09200df62297a2f76119a862c3e719f5b Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Mon, 11 Jul 2022 17:48:52 -0400 Subject: [PATCH 02/11] generate mockRelease --- internal/oc/mock_release.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/oc/mock_release.go b/internal/oc/mock_release.go index fb02b5132cb4..d0a68b78f222 100644 --- a/internal/oc/mock_release.go +++ b/internal/oc/mock_release.go @@ -36,18 +36,18 @@ func (m *MockRelease) EXPECT() *MockReleaseMockRecorder { } // Extract mocks base method. -func (m *MockRelease) Extract(log logrus.FieldLogger, releaseImage, releaseImageMirror, cacheDir, pullSecret string, platformType models.PlatformType) (string, error) { +func (m *MockRelease) Extract(log logrus.FieldLogger, releaseImage, releaseImageMirror, cacheDir, pullSecret string, platformType models.PlatformType, icspFile string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Extract", log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType) + ret := m.ctrl.Call(m, "Extract", log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType, icspFile) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // Extract indicates an expected call of Extract. -func (mr *MockReleaseMockRecorder) Extract(log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType interface{}) *gomock.Call { +func (mr *MockReleaseMockRecorder) Extract(log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType, icspFile interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockRelease)(nil).Extract), log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockRelease)(nil).Extract), log, releaseImage, releaseImageMirror, cacheDir, pullSecret, platformType, icspFile) } // GetIronicAgentImage mocks base method. From 0edb8f21a03e90d046878dfb41b9c147a305ffd4 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Wed, 13 Jul 2022 12:49:02 -0400 Subject: [PATCH 03/11] Get the ImageContentSources for icsp file from install-config --- internal/ignition/ignition.go | 81 ++++- internal/ignition/ignition_test.go | 20 +- pkg/generator/generator.go | 3 +- ...rator_01_imagecontentsourcepolicy.crd.yaml | 88 +++++ .../openshift/api/operator/v1alpha1/doc.go | 6 + .../api/operator/v1alpha1/register.go | 41 +++ .../openshift/api/operator/v1alpha1/types.go | 180 +++++++++ .../types_image_content_source_policy.go | 67 ++++ .../v1alpha1/zz_generated.deepcopy.go | 344 ++++++++++++++++++ .../zz_generated.swagger_doc_generated.go | 174 +++++++++ vendor/modules.txt | 1 + 11 files changed, 989 insertions(+), 16 deletions(-) create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/0000_10_config-operator_01_imagecontentsourcepolicy.crd.yaml create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/doc.go create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/register.go create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/types.go create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/types_image_content_source_policy.go create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.swagger_doc_generated.go diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 3b6a545ea087..807b20ab68a9 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -27,10 +27,12 @@ import ( "github.com/coreos/vcontext/report" "github.com/go-openapi/swag" bmh_v1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" + operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1" clusterPkg "github.com/openshift/assisted-service/internal/cluster" "github.com/openshift/assisted-service/internal/common" "github.com/openshift/assisted-service/internal/constants" "github.com/openshift/assisted-service/internal/host/hostutil" + "github.com/openshift/assisted-service/internal/installcfg" "github.com/openshift/assisted-service/internal/installercache" "github.com/openshift/assisted-service/internal/manifests" "github.com/openshift/assisted-service/internal/network" @@ -420,7 +422,6 @@ type installerGenerator struct { providerRegistry registry.ProviderRegistry installerReleaseImageOverride string clusterTLSCertOverrideDir string - icspFile string } // IgnitionConfig contains the attributes required to build the discovery ignition file @@ -453,7 +454,7 @@ func NewBuilder(log logrus.FieldLogger, staticNetworkConfig staticnetworkconfig. // NewGenerator returns a generator that can generate ignition files func NewGenerator(workDir string, installerDir string, cluster *common.Cluster, releaseImage string, releaseImageMirror string, serviceCACert, installInvoker string, s3Client s3wrapper.API, log logrus.FieldLogger, operatorsApi operators.API, - providerRegistry registry.ProviderRegistry, installerReleaseImageOverride, clusterTLSCertOverrideDir string, icspFile string) Generator { + providerRegistry registry.ProviderRegistry, installerReleaseImageOverride, clusterTLSCertOverrideDir string) Generator { return &installerGenerator{ cluster: cluster, log: log, @@ -469,7 +470,6 @@ func NewGenerator(workDir string, installerDir string, cluster *common.Cluster, providerRegistry: providerRegistry, installerReleaseImageOverride: installerReleaseImageOverride, clusterTLSCertOverrideDir: clusterTLSCertOverrideDir, - icspFile: icspFile, } } @@ -481,6 +481,7 @@ func (g *installerGenerator) UploadToS3(ctx context.Context) error { // Generate generates ignition files and applies modifications. func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, platformType models.PlatformType) error { + var icspFile string log := logutil.FromContext(ctx, g.log) // In case we don't want to override image for extracting installer use release one @@ -488,8 +489,16 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, g.installerReleaseImageOverride = g.releaseImage } + // If ImageContentSources are defined, store in a file for the 'oc' command + defer removeIcspFile(icspFile) + + icspFile, err := getIcspFileFromInstallConfig(installConfig) + if err != nil { + return errors.Wrap(err, "failed to create file with ImageContentSources") + } + installerPath, err := installercache.Get(g.installerReleaseImageOverride, g.releaseImageMirror, g.installerDir, - g.cluster.PullSecret, platformType, g.icspFile, log) + g.cluster.PullSecret, platformType, icspFile, log) if err != nil { return errors.Wrap(err, "failed to get installer path") } @@ -1711,3 +1720,67 @@ func proxySettingsForIgnition(httpProxy, httpsProxy, noProxy string) (string, er } return buf.String(), nil } + +func getIcspFileFromInstallConfig(cfg []byte) (string, error) { + contents, err := getIcsp(cfg) + if err != nil { + return "", err + } + if contents == nil { + return "", nil + } + + icspFile, err := ioutil.TempFile("", "icsp-file") + if err != nil { + return "", err + } + if _, err := icspFile.Write(contents); err != nil { + os.Remove(icspFile.Name()) + return "", err + } + icspFile.Close() + + return icspFile.Name(), nil +} + +func getIcsp(cfg []byte) ([]byte, error) { + + var installCfg installcfg.InstallerConfigBaremetal + if err := yaml.Unmarshal(cfg, &installCfg); err != nil { + return nil, err + } + + if len(installCfg.ImageContentSources) == 0 { + // No ImageContentSources were defined + return nil, nil + } + + icsp := operatorv1alpha1.ImageContentSourcePolicy{ + TypeMeta: metav1.TypeMeta{ + APIVersion: operatorv1alpha1.SchemeGroupVersion.String(), + Kind: "ImageContentSourcePolicy", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "image-policy", + // not namespaced + }, + } + + icsp.Spec.RepositoryDigestMirrors = make([]operatorv1alpha1.RepositoryDigestMirrors, len(installCfg.ImageContentSources)) + for i, imageSource := range installCfg.ImageContentSources { + icsp.Spec.RepositoryDigestMirrors[i] = operatorv1alpha1.RepositoryDigestMirrors{Source: imageSource.Source, Mirrors: imageSource.Mirrors} + + } + + contents, err := yaml.Marshal(icsp) + if err != nil { + return nil, err + } + return contents, nil +} + +func removeIcspFile(filename string) { + if filename != "" { + os.Remove(filename) + } +} diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index 007dbcaaf522..3eed4a5066c4 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -123,7 +123,7 @@ var _ = Describe("Bootstrap Ignition Update", func() { }, } g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", mockS3Client, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err = g.updateBootstrap(context.Background(), examplePath) @@ -266,7 +266,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 Describe("update ignitions", func() { It("with ca cert file", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", caCertPath, "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.updateIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -289,7 +289,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with no ca cert file", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.updateIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -308,7 +308,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with service ips", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.UpdateEtcHosts("10.10.10.1,10.10.10.2") Expect(err).NotTo(HaveOccurred()) @@ -331,7 +331,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("with no service ips", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.UpdateEtcHosts("") Expect(err).NotTo(HaveOccurred()) @@ -361,7 +361,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 Context("DHCP generation", func() { It("Definitions only", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) g.encodedDhcpFileContents = "data:,abc" err := g.updateIgnitions() @@ -380,7 +380,7 @@ SV4bRR9i0uf+xQ/oYRvugQ25Q7EahO5hJIWRf4aULbk36Zpw3++v2KFnF26zqwB6 }) It("Definitions+leases", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) g.encodedDhcpFileContents = "data:,abc" cluster.ApiVipLease = "api" @@ -503,7 +503,7 @@ var _ = Describe("createHostIgnitions", func() { } g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.createHostIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -549,7 +549,7 @@ var _ = Describe("createHostIgnitions", func() { }} g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "", "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) err := g.createHostIgnitions() Expect(err).NotTo(HaveOccurred()) @@ -1423,7 +1423,7 @@ var _ = Describe("Import Cluster TLS Certs for ephemeral installer", func() { It("copies the tls cert files", func() { g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", certDir, "").(*installerGenerator) + mockOperatorManager, mockProviderRegistry, "", certDir).(*installerGenerator) err := g.importClusterTLSCerts(context.Background()) Expect(err).NotTo(HaveOccurred()) diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 06df2440fde3..446eb1459391 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -32,7 +32,6 @@ type Config struct { ReleaseImageMirror string DummyIgnition bool `envconfig:"DUMMY_IGNITION"` InstallInvoker string `envconfig:"INSTALL_INVOKER" default:"assisted-installer"` - IcspFile string `envconfig:"ICSP_FILE" default:""` } type installGenerator struct { @@ -99,7 +98,7 @@ func (k *installGenerator) GenerateInstallConfig(ctx context.Context, cluster co generator = ignition.NewDummyGenerator(clusterWorkDir, &cluster, k.s3Client, log) } else { generator = ignition.NewGenerator(clusterWorkDir, installerCacheDir, &cluster, releaseImage, k.Config.ReleaseImageMirror, - k.Config.ServiceCACertPath, k.Config.InstallInvoker, k.s3Client, log, k.operatorsApi, k.providerRegistry, installerReleaseImageOverride, k.clusterTLSCertOverrideDir, k.Config.IcspFile) + k.Config.ServiceCACertPath, k.Config.InstallInvoker, k.s3Client, log, k.operatorsApi, k.providerRegistry, installerReleaseImageOverride, k.clusterTLSCertOverrideDir) } err = generator.Generate(ctx, cfg, k.getClusterPlatformType(cluster)) if err != nil { diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/0000_10_config-operator_01_imagecontentsourcepolicy.crd.yaml b/vendor/github.com/openshift/api/operator/v1alpha1/0000_10_config-operator_01_imagecontentsourcepolicy.crd.yaml new file mode 100644 index 000000000000..b28b0415c9a5 --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/0000_10_config-operator_01_imagecontentsourcepolicy.crd.yaml @@ -0,0 +1,88 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: imagecontentsourcepolicies.operator.openshift.io +spec: + group: operator.openshift.io + scope: Cluster + preserveUnknownFields: false + names: + kind: ImageContentSourcePolicy + singular: imagecontentsourcepolicy + plural: imagecontentsourcepolicies + listKind: ImageContentSourcePolicyList + versions: + - name: v1alpha1 + served: true + storage: true + subresources: + status: {} + "validation": + "openAPIV3Schema": + description: ImageContentSourcePolicy holds cluster-wide information about how + to handle registry mirror rules. When multiple policies are defined, the outcome + of the behavior is defined on each field. + type: object + required: + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec holds user settable values for configuration + type: object + properties: + repositoryDigestMirrors: + description: "repositoryDigestMirrors allows images referenced by image + digests in pods to be pulled from alternative mirrored repository + locations. The image pull specification provided to the pod will be + compared to the source locations described in RepositoryDigestMirrors + and the image may be pulled down from any of the mirrors in the list + instead of the specified repository allowing administrators to choose + a potentially faster mirror. Only image pull specifications that have + an image disgest will have this behavior applied to them - tags will + continue to be pulled from the specified repository in the pull spec. + \n Each “source” repository is treated independently; configurations + for different “source” repositories don’t interact. \n When multiple + policies are defined for the same “source” repository, the sets of + defined mirrors will be merged together, preserving the relative order + of the mirrors, if possible. For example, if policy A has mirrors + `a, b, c` and policy B has mirrors `c, d, e`, the mirrors will be + used in the order `a, b, c, d, e`. If the orders of mirror entries + conflict (e.g. `a, b` vs. `b, a`) the configuration is not rejected + but the resulting order is unspecified." + type: array + items: + description: 'RepositoryDigestMirrors holds cluster-wide information + about how to handle mirros in the registries config. Note: the mirrors + only work when pulling the images that are referenced by their digests.' + type: object + required: + - source + properties: + mirrors: + description: mirrors is one or more repositories that may also + contain the same images. The order of mirrors in this list is + treated as the user's desired priority, while source is by default + considered lower priority than all mirrors. Other cluster configuration, + including (but not limited to) other repositoryDigestMirrors + objects, may impact the exact order mirrors are contacted in, + or some mirrors may be contacted in parallel, so this should + be considered a preference rather than a guarantee of ordering. + type: array + items: + type: string + source: + description: source is the repository that users refer to, e.g. + in image pull specifications. + type: string diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/doc.go b/vendor/github.com/openshift/api/operator/v1alpha1/doc.go new file mode 100644 index 000000000000..9d18719532c7 --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/doc.go @@ -0,0 +1,6 @@ +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +groupName=operator.openshift.io +package v1alpha1 diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/register.go b/vendor/github.com/openshift/api/operator/v1alpha1/register.go new file mode 100644 index 000000000000..3c731f61871f --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/register.go @@ -0,0 +1,41 @@ +package v1alpha1 + +import ( + configv1 "github.com/openshift/api/config/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "operator.openshift.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +func addKnownTypes(scheme *runtime.Scheme) error { + metav1.AddToGroupVersion(scheme, GroupVersion) + + scheme.AddKnownTypes(GroupVersion, + &GenericOperatorConfig{}, + &ImageContentSourcePolicy{}, + &ImageContentSourcePolicyList{}, + ) + + return nil +} diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/types.go b/vendor/github.com/openshift/api/operator/v1alpha1/types.go new file mode 100644 index 000000000000..8f2e5be2435f --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/types.go @@ -0,0 +1,180 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + configv1 "github.com/openshift/api/config/v1" +) + +type ManagementState string + +const ( + // Managed means that the operator is actively managing its resources and trying to keep the component active + Managed ManagementState = "Managed" + // Unmanaged means that the operator is not taking any action related to the component + Unmanaged ManagementState = "Unmanaged" + // Removed means that the operator is actively managing its resources and trying to remove all traces of the component + Removed ManagementState = "Removed" +) + +// OperatorSpec contains common fields for an operator to need. It is intended to be anonymous included +// inside of the Spec struct for you particular operator. +type OperatorSpec struct { + // managementState indicates whether and how the operator should manage the component + ManagementState ManagementState `json:"managementState"` + + // imagePullSpec is the image to use for the component. + ImagePullSpec string `json:"imagePullSpec"` + + // imagePullPolicy specifies the image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, + // or IfNotPresent otherwise. + ImagePullPolicy string `json:"imagePullPolicy"` + + // version is the desired state in major.minor.micro-patch. Usually patch is ignored. + Version string `json:"version"` + + // logging contains glog parameters for the component pods. It's always a command line arg for the moment + Logging LoggingConfig `json:"logging,omitempty"` +} + +// LoggingConfig holds information about configuring logging +type LoggingConfig struct { + // level is passed to glog. + Level int64 `json:"level"` + + // vmodule is passed to glog. + Vmodule string `json:"vmodule"` +} + +type ConditionStatus string + +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" + + // these conditions match the conditions for the ClusterOperator type. + OperatorStatusTypeAvailable = "Available" + OperatorStatusTypeProgressing = "Progressing" + OperatorStatusTypeFailing = "Failing" + + OperatorStatusTypeMigrating = "Migrating" + // TODO this is going to be removed + OperatorStatusTypeSyncSuccessful = "SyncSuccessful" +) + +// OperatorCondition is just the standard condition fields. +type OperatorCondition struct { + Type string `json:"type"` + Status ConditionStatus `json:"status"` + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + Reason string `json:"reason,omitempty"` + Message string `json:"message,omitempty"` +} + +// VersionAvailability gives information about the synchronization and operational status of a particular version of the component +type VersionAvailability struct { + // version is the level this availability applies to + Version string `json:"version"` + // updatedReplicas indicates how many replicas are at the desired state + UpdatedReplicas int32 `json:"updatedReplicas"` + // readyReplicas indicates how many replicas are ready and at the desired state + ReadyReplicas int32 `json:"readyReplicas"` + // errors indicates what failures are associated with the operator trying to manage this version + Errors []string `json:"errors"` + // generations allows an operator to track what the generation of "important" resources was the last time we updated them + Generations []GenerationHistory `json:"generations"` +} + +// GenerationHistory keeps track of the generation for a given resource so that decisions about forced updated can be made. +type GenerationHistory struct { + // group is the group of the thing you're tracking + Group string `json:"group"` + // resource is the resource type of the thing you're tracking + Resource string `json:"resource"` + // namespace is where the thing you're tracking is + Namespace string `json:"namespace"` + // name is the name of the thing you're tracking + Name string `json:"name"` + // lastGeneration is the last generation of the workload controller involved + LastGeneration int64 `json:"lastGeneration"` +} + +// OperatorStatus contains common fields for an operator to need. It is intended to be anonymous included +// inside of the Status struct for you particular operator. +type OperatorStatus struct { + // observedGeneration is the last generation change you've dealt with + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // conditions is a list of conditions and their status + Conditions []OperatorCondition `json:"conditions,omitempty"` + + // state indicates what the operator has observed to be its current operational status. + State ManagementState `json:"state,omitempty"` + // taskSummary is a high level summary of what the controller is currently attempting to do. It is high-level, human-readable + // and not guaranteed in any way. (I needed this for debugging and realized it made a great summary). + TaskSummary string `json:"taskSummary,omitempty"` + + // currentVersionAvailability is availability information for the current version. If it is unmanged or removed, this doesn't exist. + CurrentAvailability *VersionAvailability `json:"currentVersionAvailability,omitempty"` + // targetVersionAvailability is availability information for the target version if we are migrating + TargetAvailability *VersionAvailability `json:"targetVersionAvailability,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GenericOperatorConfig provides information to configure an operator +type GenericOperatorConfig struct { + metav1.TypeMeta `json:",inline"` + + // ServingInfo is the HTTP serving information for the controller's endpoints + ServingInfo configv1.HTTPServingInfo `json:"servingInfo,omitempty"` + + // leaderElection provides information to elect a leader. Only override this if you have a specific need + LeaderElection configv1.LeaderElection `json:"leaderElection,omitempty"` + + // authentication allows configuration of authentication for the endpoints + Authentication DelegatedAuthentication `json:"authentication,omitempty"` + // authorization allows configuration of authentication for the endpoints + Authorization DelegatedAuthorization `json:"authorization,omitempty"` +} + +// DelegatedAuthentication allows authentication to be disabled. +type DelegatedAuthentication struct { + // disabled indicates that authentication should be disabled. By default it will use delegated authentication. + Disabled bool `json:"disabled,omitempty"` +} + +// DelegatedAuthorization allows authorization to be disabled. +type DelegatedAuthorization struct { + // disabled indicates that authorization should be disabled. By default it will use delegated authorization. + Disabled bool `json:"disabled,omitempty"` +} + +// StaticPodOperatorStatus is status for controllers that manage static pods. There are different needs because individual +// node status must be tracked. +type StaticPodOperatorStatus struct { + OperatorStatus `json:",inline"` + + // latestAvailableDeploymentGeneration is the deploymentID of the most recent deployment + LatestAvailableDeploymentGeneration int32 `json:"latestAvailableDeploymentGeneration"` + + // nodeStatuses track the deployment values and errors across individual nodes + NodeStatuses []NodeStatus `json:"nodeStatuses"` +} + +// NodeStatus provides information about the current state of a particular node managed by this operator. +type NodeStatus struct { + // nodeName is the name of the node + NodeName string `json:"nodeName"` + + // currentDeploymentGeneration is the generation of the most recently successful deployment + CurrentDeploymentGeneration int32 `json:"currentDeploymentGeneration"` + // targetDeploymentGeneration is the generation of the deployment we're trying to apply + TargetDeploymentGeneration int32 `json:"targetDeploymentGeneration"` + // lastFailedDeploymentGeneration is the generation of the deployment we tried and failed to deploy. + LastFailedDeploymentGeneration int32 `json:"lastFailedDeploymentGeneration"` + + // lastFailedDeploymentGenerationErrors is a list of the errors during the failed deployment referenced in lastFailedDeploymentGeneration + LastFailedDeploymentErrors []string `json:"lastFailedDeploymentErrors"` +} diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/types_image_content_source_policy.go b/vendor/github.com/openshift/api/operator/v1alpha1/types_image_content_source_policy.go new file mode 100644 index 000000000000..49f8b9522261 --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/types_image_content_source_policy.go @@ -0,0 +1,67 @@ +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImageContentSourcePolicy holds cluster-wide information about how to handle registry mirror rules. +// When multiple policies are defined, the outcome of the behavior is defined on each field. +type ImageContentSourcePolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec holds user settable values for configuration + // +kubebuilder:validation:Required + // +required + Spec ImageContentSourcePolicySpec `json:"spec"` +} + +// ImageContentSourcePolicySpec is the specification of the ImageContentSourcePolicy CRD. +type ImageContentSourcePolicySpec struct { + // repositoryDigestMirrors allows images referenced by image digests in pods to be + // pulled from alternative mirrored repository locations. The image pull specification + // provided to the pod will be compared to the source locations described in RepositoryDigestMirrors + // and the image may be pulled down from any of the mirrors in the list instead of the + // specified repository allowing administrators to choose a potentially faster mirror. + // Only image pull specifications that have an image disgest will have this behavior applied + // to them - tags will continue to be pulled from the specified repository in the pull spec. + // + // Each “source” repository is treated independently; configurations for different “source” + // repositories don’t interact. + // + // When multiple policies are defined for the same “source” repository, the sets of defined + // mirrors will be merged together, preserving the relative order of the mirrors, if possible. + // For example, if policy A has mirrors `a, b, c` and policy B has mirrors `c, d, e`, the + // mirrors will be used in the order `a, b, c, d, e`. If the orders of mirror entries conflict + // (e.g. `a, b` vs. `b, a`) the configuration is not rejected but the resulting order is unspecified. + // +optional + RepositoryDigestMirrors []RepositoryDigestMirrors `json:"repositoryDigestMirrors"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImageContentSourcePolicyList lists the items in the ImageContentSourcePolicy CRD. +type ImageContentSourcePolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ImageContentSourcePolicy `json:"items"` +} + +// RepositoryDigestMirrors holds cluster-wide information about how to handle mirros in the registries config. +// Note: the mirrors only work when pulling the images that are referenced by their digests. +type RepositoryDigestMirrors struct { + // source is the repository that users refer to, e.g. in image pull specifications. + // +required + Source string `json:"source"` + // mirrors is one or more repositories that may also contain the same images. + // The order of mirrors in this list is treated as the user's desired priority, while source + // is by default considered lower priority than all mirrors. Other cluster configuration, + // including (but not limited to) other repositoryDigestMirrors objects, + // may impact the exact order mirrors are contacted in, or some mirrors may be contacted + // in parallel, so this should be considered a preference rather than a guarantee of ordering. + // +optional + Mirrors []string `json:"mirrors"` +} diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000000..79f75bd0beaf --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,344 @@ +// +build !ignore_autogenerated + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DelegatedAuthentication) DeepCopyInto(out *DelegatedAuthentication) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DelegatedAuthentication. +func (in *DelegatedAuthentication) DeepCopy() *DelegatedAuthentication { + if in == nil { + return nil + } + out := new(DelegatedAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DelegatedAuthorization) DeepCopyInto(out *DelegatedAuthorization) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DelegatedAuthorization. +func (in *DelegatedAuthorization) DeepCopy() *DelegatedAuthorization { + if in == nil { + return nil + } + out := new(DelegatedAuthorization) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenerationHistory) DeepCopyInto(out *GenerationHistory) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenerationHistory. +func (in *GenerationHistory) DeepCopy() *GenerationHistory { + if in == nil { + return nil + } + out := new(GenerationHistory) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenericOperatorConfig) DeepCopyInto(out *GenericOperatorConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ServingInfo.DeepCopyInto(&out.ServingInfo) + out.LeaderElection = in.LeaderElection + out.Authentication = in.Authentication + out.Authorization = in.Authorization + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericOperatorConfig. +func (in *GenericOperatorConfig) DeepCopy() *GenericOperatorConfig { + if in == nil { + return nil + } + out := new(GenericOperatorConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GenericOperatorConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageContentSourcePolicy) DeepCopyInto(out *ImageContentSourcePolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageContentSourcePolicy. +func (in *ImageContentSourcePolicy) DeepCopy() *ImageContentSourcePolicy { + if in == nil { + return nil + } + out := new(ImageContentSourcePolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImageContentSourcePolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageContentSourcePolicyList) DeepCopyInto(out *ImageContentSourcePolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ImageContentSourcePolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageContentSourcePolicyList. +func (in *ImageContentSourcePolicyList) DeepCopy() *ImageContentSourcePolicyList { + if in == nil { + return nil + } + out := new(ImageContentSourcePolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImageContentSourcePolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageContentSourcePolicySpec) DeepCopyInto(out *ImageContentSourcePolicySpec) { + *out = *in + if in.RepositoryDigestMirrors != nil { + in, out := &in.RepositoryDigestMirrors, &out.RepositoryDigestMirrors + *out = make([]RepositoryDigestMirrors, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageContentSourcePolicySpec. +func (in *ImageContentSourcePolicySpec) DeepCopy() *ImageContentSourcePolicySpec { + if in == nil { + return nil + } + out := new(ImageContentSourcePolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoggingConfig) DeepCopyInto(out *LoggingConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingConfig. +func (in *LoggingConfig) DeepCopy() *LoggingConfig { + if in == nil { + return nil + } + out := new(LoggingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatus) DeepCopyInto(out *NodeStatus) { + *out = *in + if in.LastFailedDeploymentErrors != nil { + in, out := &in.LastFailedDeploymentErrors, &out.LastFailedDeploymentErrors + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatus. +func (in *NodeStatus) DeepCopy() *NodeStatus { + if in == nil { + return nil + } + out := new(NodeStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorCondition) DeepCopyInto(out *OperatorCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorCondition. +func (in *OperatorCondition) DeepCopy() *OperatorCondition { + if in == nil { + return nil + } + out := new(OperatorCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorSpec) DeepCopyInto(out *OperatorSpec) { + *out = *in + out.Logging = in.Logging + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorSpec. +func (in *OperatorSpec) DeepCopy() *OperatorSpec { + if in == nil { + return nil + } + out := new(OperatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorStatus) DeepCopyInto(out *OperatorStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]OperatorCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CurrentAvailability != nil { + in, out := &in.CurrentAvailability, &out.CurrentAvailability + *out = new(VersionAvailability) + (*in).DeepCopyInto(*out) + } + if in.TargetAvailability != nil { + in, out := &in.TargetAvailability, &out.TargetAvailability + *out = new(VersionAvailability) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatus. +func (in *OperatorStatus) DeepCopy() *OperatorStatus { + if in == nil { + return nil + } + out := new(OperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepositoryDigestMirrors) DeepCopyInto(out *RepositoryDigestMirrors) { + *out = *in + if in.Mirrors != nil { + in, out := &in.Mirrors, &out.Mirrors + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepositoryDigestMirrors. +func (in *RepositoryDigestMirrors) DeepCopy() *RepositoryDigestMirrors { + if in == nil { + return nil + } + out := new(RepositoryDigestMirrors) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StaticPodOperatorStatus) DeepCopyInto(out *StaticPodOperatorStatus) { + *out = *in + in.OperatorStatus.DeepCopyInto(&out.OperatorStatus) + if in.NodeStatuses != nil { + in, out := &in.NodeStatuses, &out.NodeStatuses + *out = make([]NodeStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticPodOperatorStatus. +func (in *StaticPodOperatorStatus) DeepCopy() *StaticPodOperatorStatus { + if in == nil { + return nil + } + out := new(StaticPodOperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VersionAvailability) DeepCopyInto(out *VersionAvailability) { + *out = *in + if in.Errors != nil { + in, out := &in.Errors, &out.Errors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Generations != nil { + in, out := &in.Generations, &out.Generations + *out = make([]GenerationHistory, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionAvailability. +func (in *VersionAvailability) DeepCopy() *VersionAvailability { + if in == nil { + return nil + } + out := new(VersionAvailability) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.swagger_doc_generated.go b/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.swagger_doc_generated.go new file mode 100644 index 000000000000..5a32df8389fa --- /dev/null +++ b/vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.swagger_doc_generated.go @@ -0,0 +1,174 @@ +package v1alpha1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_DelegatedAuthentication = map[string]string{ + "": "DelegatedAuthentication allows authentication to be disabled.", + "disabled": "disabled indicates that authentication should be disabled. By default it will use delegated authentication.", +} + +func (DelegatedAuthentication) SwaggerDoc() map[string]string { + return map_DelegatedAuthentication +} + +var map_DelegatedAuthorization = map[string]string{ + "": "DelegatedAuthorization allows authorization to be disabled.", + "disabled": "disabled indicates that authorization should be disabled. By default it will use delegated authorization.", +} + +func (DelegatedAuthorization) SwaggerDoc() map[string]string { + return map_DelegatedAuthorization +} + +var map_GenerationHistory = map[string]string{ + "": "GenerationHistory keeps track of the generation for a given resource so that decisions about forced updated can be made.", + "group": "group is the group of the thing you're tracking", + "resource": "resource is the resource type of the thing you're tracking", + "namespace": "namespace is where the thing you're tracking is", + "name": "name is the name of the thing you're tracking", + "lastGeneration": "lastGeneration is the last generation of the workload controller involved", +} + +func (GenerationHistory) SwaggerDoc() map[string]string { + return map_GenerationHistory +} + +var map_GenericOperatorConfig = map[string]string{ + "": "GenericOperatorConfig provides information to configure an operator", + "servingInfo": "ServingInfo is the HTTP serving information for the controller's endpoints", + "leaderElection": "leaderElection provides information to elect a leader. Only override this if you have a specific need", + "authentication": "authentication allows configuration of authentication for the endpoints", + "authorization": "authorization allows configuration of authentication for the endpoints", +} + +func (GenericOperatorConfig) SwaggerDoc() map[string]string { + return map_GenericOperatorConfig +} + +var map_LoggingConfig = map[string]string{ + "": "LoggingConfig holds information about configuring logging", + "level": "level is passed to glog.", + "vmodule": "vmodule is passed to glog.", +} + +func (LoggingConfig) SwaggerDoc() map[string]string { + return map_LoggingConfig +} + +var map_NodeStatus = map[string]string{ + "": "NodeStatus provides information about the current state of a particular node managed by this operator.", + "nodeName": "nodeName is the name of the node", + "currentDeploymentGeneration": "currentDeploymentGeneration is the generation of the most recently successful deployment", + "targetDeploymentGeneration": "targetDeploymentGeneration is the generation of the deployment we're trying to apply", + "lastFailedDeploymentGeneration": "lastFailedDeploymentGeneration is the generation of the deployment we tried and failed to deploy.", + "lastFailedDeploymentErrors": "lastFailedDeploymentGenerationErrors is a list of the errors during the failed deployment referenced in lastFailedDeploymentGeneration", +} + +func (NodeStatus) SwaggerDoc() map[string]string { + return map_NodeStatus +} + +var map_OperatorCondition = map[string]string{ + "": "OperatorCondition is just the standard condition fields.", +} + +func (OperatorCondition) SwaggerDoc() map[string]string { + return map_OperatorCondition +} + +var map_OperatorSpec = map[string]string{ + "": "OperatorSpec contains common fields for an operator to need. It is intended to be anonymous included inside of the Spec struct for you particular operator.", + "managementState": "managementState indicates whether and how the operator should manage the component", + "imagePullSpec": "imagePullSpec is the image to use for the component.", + "imagePullPolicy": "imagePullPolicy specifies the image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.", + "version": "version is the desired state in major.minor.micro-patch. Usually patch is ignored.", + "logging": "logging contains glog parameters for the component pods. It's always a command line arg for the moment", +} + +func (OperatorSpec) SwaggerDoc() map[string]string { + return map_OperatorSpec +} + +var map_OperatorStatus = map[string]string{ + "": "OperatorStatus contains common fields for an operator to need. It is intended to be anonymous included inside of the Status struct for you particular operator.", + "observedGeneration": "observedGeneration is the last generation change you've dealt with", + "conditions": "conditions is a list of conditions and their status", + "state": "state indicates what the operator has observed to be its current operational status.", + "taskSummary": "taskSummary is a high level summary of what the controller is currently attempting to do. It is high-level, human-readable and not guaranteed in any way. (I needed this for debugging and realized it made a great summary).", + "currentVersionAvailability": "currentVersionAvailability is availability information for the current version. If it is unmanged or removed, this doesn't exist.", + "targetVersionAvailability": "targetVersionAvailability is availability information for the target version if we are migrating", +} + +func (OperatorStatus) SwaggerDoc() map[string]string { + return map_OperatorStatus +} + +var map_StaticPodOperatorStatus = map[string]string{ + "": "StaticPodOperatorStatus is status for controllers that manage static pods. There are different needs because individual node status must be tracked.", + "latestAvailableDeploymentGeneration": "latestAvailableDeploymentGeneration is the deploymentID of the most recent deployment", + "nodeStatuses": "nodeStatuses track the deployment values and errors across individual nodes", +} + +func (StaticPodOperatorStatus) SwaggerDoc() map[string]string { + return map_StaticPodOperatorStatus +} + +var map_VersionAvailability = map[string]string{ + "": "VersionAvailability gives information about the synchronization and operational status of a particular version of the component", + "version": "version is the level this availability applies to", + "updatedReplicas": "updatedReplicas indicates how many replicas are at the desired state", + "readyReplicas": "readyReplicas indicates how many replicas are ready and at the desired state", + "errors": "errors indicates what failures are associated with the operator trying to manage this version", + "generations": "generations allows an operator to track what the generation of \"important\" resources was the last time we updated them", +} + +func (VersionAvailability) SwaggerDoc() map[string]string { + return map_VersionAvailability +} + +var map_ImageContentSourcePolicy = map[string]string{ + "": "ImageContentSourcePolicy holds cluster-wide information about how to handle registry mirror rules. When multiple policies are defined, the outcome of the behavior is defined on each field.", + "spec": "spec holds user settable values for configuration", +} + +func (ImageContentSourcePolicy) SwaggerDoc() map[string]string { + return map_ImageContentSourcePolicy +} + +var map_ImageContentSourcePolicyList = map[string]string{ + "": "ImageContentSourcePolicyList lists the items in the ImageContentSourcePolicy CRD.", +} + +func (ImageContentSourcePolicyList) SwaggerDoc() map[string]string { + return map_ImageContentSourcePolicyList +} + +var map_ImageContentSourcePolicySpec = map[string]string{ + "": "ImageContentSourcePolicySpec is the specification of the ImageContentSourcePolicy CRD.", + "repositoryDigestMirrors": "repositoryDigestMirrors allows images referenced by image digests in pods to be pulled from alternative mirrored repository locations. The image pull specification provided to the pod will be compared to the source locations described in RepositoryDigestMirrors and the image may be pulled down from any of the mirrors in the list instead of the specified repository allowing administrators to choose a potentially faster mirror. Only image pull specifications that have an image disgest will have this behavior applied to them - tags will continue to be pulled from the specified repository in the pull spec.\n\nEach “source” repository is treated independently; configurations for different “source” repositories don’t interact.\n\nWhen multiple policies are defined for the same “source” repository, the sets of defined mirrors will be merged together, preserving the relative order of the mirrors, if possible. For example, if policy A has mirrors `a, b, c` and policy B has mirrors `c, d, e`, the mirrors will be used in the order `a, b, c, d, e`. If the orders of mirror entries conflict (e.g. `a, b` vs. `b, a`) the configuration is not rejected but the resulting order is unspecified.", +} + +func (ImageContentSourcePolicySpec) SwaggerDoc() map[string]string { + return map_ImageContentSourcePolicySpec +} + +var map_RepositoryDigestMirrors = map[string]string{ + "": "RepositoryDigestMirrors holds cluster-wide information about how to handle mirros in the registries config. Note: the mirrors only work when pulling the images that are referenced by their digests.", + "source": "source is the repository that users refer to, e.g. in image pull specifications.", + "mirrors": "mirrors is one or more repositories that may also contain the same images. The order of mirrors in this list is treated as the user's desired priority, while source is by default considered lower priority than all mirrors. Other cluster configuration, including (but not limited to) other repositoryDigestMirrors objects, may impact the exact order mirrors are contacted in, or some mirrors may be contacted in parallel, so this should be considered a preference rather than a guarantee of ordering.", +} + +func (RepositoryDigestMirrors) SwaggerDoc() map[string]string { + return map_RepositoryDigestMirrors +} + +// AUTO-GENERATED FUNCTIONS END HERE diff --git a/vendor/modules.txt b/vendor/modules.txt index 1a7dce1f994a..0025bed41cd5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -569,6 +569,7 @@ github.com/openshift-online/ocm-sdk-go/servicelogs/v1 ## explicit github.com/openshift/api/config/v1 github.com/openshift/api/operator/v1 +github.com/openshift/api/operator/v1alpha1 github.com/openshift/api/route/v1 # github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8 ## explicit; go 1.16 From c901f43273bf6227b13667c09cbcd9d6e35e902a Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Wed, 13 Jul 2022 14:00:02 -0400 Subject: [PATCH 04/11] Fixes for defer --- internal/ignition/ignition.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 807b20ab68a9..7a4d78c0bbbd 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -490,12 +490,11 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, } // If ImageContentSources are defined, store in a file for the 'oc' command - defer removeIcspFile(icspFile) - icspFile, err := getIcspFileFromInstallConfig(installConfig) if err != nil { return errors.Wrap(err, "failed to create file with ImageContentSources") } + defer removeIcspFile(icspFile) installerPath, err := installercache.Get(g.installerReleaseImageOverride, g.releaseImageMirror, g.installerDir, g.cluster.PullSecret, platformType, icspFile, log) @@ -1735,6 +1734,7 @@ func getIcspFileFromInstallConfig(cfg []byte) (string, error) { return "", err } if _, err := icspFile.Write(contents); err != nil { + icspFile.Close() os.Remove(icspFile.Name()) return "", err } From 85be80f634f0aec0ba5ebc801b8f7703afc5f3d2 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 11:28:23 -0400 Subject: [PATCH 05/11] added logging and unit tests --- internal/ignition/ignition.go | 11 ++++- internal/ignition/ignition_test.go | 69 ++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 7a4d78c0bbbd..6ba7c6391d0b 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -53,6 +53,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sjson "k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/client-go/kubernetes/scheme" + k8syaml "sigs.k8s.io/yaml" ) const ( @@ -1726,6 +1727,7 @@ func getIcspFileFromInstallConfig(cfg []byte) (string, error) { return "", err } if contents == nil { + log.Infof("No ImageContentsSources in install-config to build ICSP file") return "", nil } @@ -1733,6 +1735,7 @@ func getIcspFileFromInstallConfig(cfg []byte) (string, error) { if err != nil { return "", err } + log.Infof("Building ICSP file from install-config with contents %s", contents) if _, err := icspFile.Write(contents); err != nil { icspFile.Close() os.Remove(icspFile.Name()) @@ -1772,10 +1775,16 @@ func getIcsp(cfg []byte) ([]byte, error) { } - contents, err := yaml.Marshal(icsp) + // Convert to json first so json tags are handled + jsonData, err := json.Marshal(&icsp) if err != nil { return nil, err } + contents, err := k8syaml.JSONToYAML(jsonData) + if err != nil { + return nil, err + } + return contents, nil } diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index 3eed4a5066c4..b40442d4a238 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "github.com/openshift/assisted-service/internal/common" "github.com/openshift/assisted-service/internal/host/hostutil" + "github.com/openshift/assisted-service/internal/installcfg" "github.com/openshift/assisted-service/internal/operators" "github.com/openshift/assisted-service/internal/provider/registry" "github.com/openshift/assisted-service/models" @@ -31,6 +32,7 @@ import ( "github.com/openshift/assisted-service/pkg/s3wrapper" "github.com/openshift/assisted-service/pkg/staticnetworkconfig" "github.com/sirupsen/logrus" + "gopkg.in/yaml.v2" ) var ( @@ -1435,3 +1437,70 @@ var _ = Describe("Import Cluster TLS Certs for ephemeral installer", func() { } }) }) + +var _ = Describe("ICSP file for oc extract", func() { + + It("valid icsp contents", func() { + var cfg installcfg.InstallerConfigBaremetal + expected := "apiVersion: operator.openshift.io/v1alpha1\nkind: ImageContentSourcePolicy\nmetadata:\n creationTimestamp: null\n name: image-policy\nspec:\n repositoryDigestMirrors:\n - mirrors:\n - mirrorhost1.example.org:5000/localimages\n - mirrorhost2.example.org:5000/localimages\n source: registry.ci.org\n - mirrors:\n - mirrorhost1.example.org:5000/localimages\n - mirrorhost2.example.org:5000/localimages\n source: quay.io\n" + + imageContentSourceList := make([]installcfg.ImageContentSource, 2) + imageContentSourceList[0] = installcfg.ImageContentSource{ + Source: "registry.ci.org", + Mirrors: []string{"mirrorhost1.example.org:5000/localimages", "mirrorhost2.example.org:5000/localimages"}, + } + imageContentSourceList[1] = installcfg.ImageContentSource{ + Source: "quay.io", + Mirrors: []string{"mirrorhost1.example.org:5000/localimages", "mirrorhost2.example.org:5000/localimages"}, + } + cfg.ImageContentSources = imageContentSourceList + data, err := yaml.Marshal(&cfg) + Expect(err).ShouldNot(HaveOccurred()) + contents, err := getIcsp(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(string(contents)).Should(Equal(expected)) + }) + + It("no image source contents defined", func() { + var cfg installcfg.InstallerConfigBaremetal + expected := "" + + data, err := yaml.Marshal(&cfg) + Expect(err).ShouldNot(HaveOccurred()) + contents, err := getIcsp(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(string(contents)).Should(Equal(expected)) + }) + + It("valid file created and readable", func() { + var cfg installcfg.InstallerConfigBaremetal + expected := "apiVersion: operator.openshift.io/v1alpha1\nkind: ImageContentSourcePolicy\nmetadata:\n creationTimestamp: null\n name: image-policy\nspec:\n repositoryDigestMirrors:\n - mirrors:\n - mirrorhost1.example.org:5000/localimages\n - mirrorhost2.example.org:5000/localimages\n source: registry.ci.org\n" + + imageContentSourceList := make([]installcfg.ImageContentSource, 1) + imageContentSourceList[0] = installcfg.ImageContentSource{ + Source: "registry.ci.org", + Mirrors: []string{"mirrorhost1.example.org:5000/localimages", "mirrorhost2.example.org:5000/localimages"}, + } + cfg.ImageContentSources = imageContentSourceList + data, err := yaml.Marshal(&cfg) + Expect(err).ShouldNot(HaveOccurred()) + icspFile, err := getIcspFileFromInstallConfig(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(string(icspFile)).Should(BeARegularFile()) + + contents, err := ioutil.ReadFile(icspFile) + Expect(err).ShouldNot(HaveOccurred()) + Expect(string(contents)).Should(Equal(expected)) + }) + + It("filename is empty string", func() { + var cfg installcfg.InstallerConfigBaremetal + expected := "" + + data, err := yaml.Marshal(&cfg) + Expect(err).ShouldNot(HaveOccurred()) + icspFile, err := getIcspFileFromInstallConfig(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(string(icspFile)).Should(Equal(expected)) + }) +}) From 13a418cff78cbfcac383571f1a8674a0510ed254 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 12:54:30 -0400 Subject: [PATCH 06/11] fixes for logging --- internal/ignition/ignition.go | 8 ++++---- internal/ignition/ignition_test.go | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 6ba7c6391d0b..dce361d8dee0 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -491,7 +491,7 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, } // If ImageContentSources are defined, store in a file for the 'oc' command - icspFile, err := getIcspFileFromInstallConfig(installConfig) + icspFile, err := g.getIcspFileFromInstallConfig(installConfig) if err != nil { return errors.Wrap(err, "failed to create file with ImageContentSources") } @@ -1721,13 +1721,13 @@ func proxySettingsForIgnition(httpProxy, httpsProxy, noProxy string) (string, er return buf.String(), nil } -func getIcspFileFromInstallConfig(cfg []byte) (string, error) { +func (g *installerGenerator) getIcspFileFromInstallConfig(cfg []byte) (string, error) { contents, err := getIcsp(cfg) if err != nil { return "", err } if contents == nil { - log.Infof("No ImageContentsSources in install-config to build ICSP file") + g.log.Infof("No ImageContentsSources in install-config to build ICSP file") return "", nil } @@ -1735,7 +1735,7 @@ func getIcspFileFromInstallConfig(cfg []byte) (string, error) { if err != nil { return "", err } - log.Infof("Building ICSP file from install-config with contents %s", contents) + g.log.Infof("Building ICSP file from install-config with contents %s", contents) if _, err := icspFile.Write(contents); err != nil { icspFile.Close() os.Remove(icspFile.Name()) diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index b40442d4a238..49bb22e29280 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -1475,6 +1475,8 @@ var _ = Describe("ICSP file for oc extract", func() { It("valid file created and readable", func() { var cfg installcfg.InstallerConfigBaremetal expected := "apiVersion: operator.openshift.io/v1alpha1\nkind: ImageContentSourcePolicy\nmetadata:\n creationTimestamp: null\n name: image-policy\nspec:\n repositoryDigestMirrors:\n - mirrors:\n - mirrorhost1.example.org:5000/localimages\n - mirrorhost2.example.org:5000/localimages\n source: registry.ci.org\n" + g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) imageContentSourceList := make([]installcfg.ImageContentSource, 1) imageContentSourceList[0] = installcfg.ImageContentSource{ @@ -1484,7 +1486,7 @@ var _ = Describe("ICSP file for oc extract", func() { cfg.ImageContentSources = imageContentSourceList data, err := yaml.Marshal(&cfg) Expect(err).ShouldNot(HaveOccurred()) - icspFile, err := getIcspFileFromInstallConfig(data) + icspFile, err := g.getIcspFileFromInstallConfig(data) Expect(err).ShouldNot(HaveOccurred()) Expect(string(icspFile)).Should(BeARegularFile()) @@ -1496,10 +1498,12 @@ var _ = Describe("ICSP file for oc extract", func() { It("filename is empty string", func() { var cfg installcfg.InstallerConfigBaremetal expected := "" + g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, + mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) data, err := yaml.Marshal(&cfg) Expect(err).ShouldNot(HaveOccurred()) - icspFile, err := getIcspFileFromInstallConfig(data) + icspFile, err := g.getIcspFileFromInstallConfig(data) Expect(err).ShouldNot(HaveOccurred()) Expect(string(icspFile)).Should(Equal(expected)) }) From 7f25cd497c6425c76ab8824e78e0b4261b738e37 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 13:00:46 -0400 Subject: [PATCH 07/11] fixes for logging --- internal/ignition/ignition.go | 8 ++++---- internal/ignition/ignition_test.go | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index dce361d8dee0..9ff76ce8f348 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -491,7 +491,7 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, } // If ImageContentSources are defined, store in a file for the 'oc' command - icspFile, err := g.getIcspFileFromInstallConfig(installConfig) + icspFile, err := getIcspFileFromInstallConfig(installConfig, g.log) if err != nil { return errors.Wrap(err, "failed to create file with ImageContentSources") } @@ -1721,13 +1721,13 @@ func proxySettingsForIgnition(httpProxy, httpsProxy, noProxy string) (string, er return buf.String(), nil } -func (g *installerGenerator) getIcspFileFromInstallConfig(cfg []byte) (string, error) { +func getIcspFileFromInstallConfig(cfg []byte, log logrus.FieldLogger) (string, error) { contents, err := getIcsp(cfg) if err != nil { return "", err } if contents == nil { - g.log.Infof("No ImageContentsSources in install-config to build ICSP file") + log.Infof("No ImageContentSources in install-config to build ICSP file") return "", nil } @@ -1735,7 +1735,7 @@ func (g *installerGenerator) getIcspFileFromInstallConfig(cfg []byte) (string, e if err != nil { return "", err } - g.log.Infof("Building ICSP file from install-config with contents %s", contents) + log.Infof("Building ICSP file from install-config with contents %s", contents) if _, err := icspFile.Write(contents); err != nil { icspFile.Close() os.Remove(icspFile.Name()) diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index 49bb22e29280..da4427eaf608 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -1475,8 +1475,6 @@ var _ = Describe("ICSP file for oc extract", func() { It("valid file created and readable", func() { var cfg installcfg.InstallerConfigBaremetal expected := "apiVersion: operator.openshift.io/v1alpha1\nkind: ImageContentSourcePolicy\nmetadata:\n creationTimestamp: null\n name: image-policy\nspec:\n repositoryDigestMirrors:\n - mirrors:\n - mirrorhost1.example.org:5000/localimages\n - mirrorhost2.example.org:5000/localimages\n source: registry.ci.org\n" - g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) imageContentSourceList := make([]installcfg.ImageContentSource, 1) imageContentSourceList[0] = installcfg.ImageContentSource{ @@ -1486,7 +1484,7 @@ var _ = Describe("ICSP file for oc extract", func() { cfg.ImageContentSources = imageContentSourceList data, err := yaml.Marshal(&cfg) Expect(err).ShouldNot(HaveOccurred()) - icspFile, err := g.getIcspFileFromInstallConfig(data) + icspFile, err := getIcspFileFromInstallConfig(data, log) Expect(err).ShouldNot(HaveOccurred()) Expect(string(icspFile)).Should(BeARegularFile()) @@ -1498,12 +1496,10 @@ var _ = Describe("ICSP file for oc extract", func() { It("filename is empty string", func() { var cfg installcfg.InstallerConfigBaremetal expected := "" - g := NewGenerator(workDir, installerCacheDir, cluster, "", "", "", "", nil, log, - mockOperatorManager, mockProviderRegistry, "", "").(*installerGenerator) data, err := yaml.Marshal(&cfg) Expect(err).ShouldNot(HaveOccurred()) - icspFile, err := g.getIcspFileFromInstallConfig(data) + icspFile, err := getIcspFileFromInstallConfig(data, log) Expect(err).ShouldNot(HaveOccurred()) Expect(string(icspFile)).Should(Equal(expected)) }) From b8316b086169774309cc9e9791c4625ff044eea8 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 13:07:37 -0400 Subject: [PATCH 08/11] fixes for logging --- internal/ignition/ignition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ignition/ignition.go b/internal/ignition/ignition.go index 9ff76ce8f348..1eca09ea490e 100644 --- a/internal/ignition/ignition.go +++ b/internal/ignition/ignition.go @@ -491,7 +491,7 @@ func (g *installerGenerator) Generate(ctx context.Context, installConfig []byte, } // If ImageContentSources are defined, store in a file for the 'oc' command - icspFile, err := getIcspFileFromInstallConfig(installConfig, g.log) + icspFile, err := getIcspFileFromInstallConfig(installConfig, log) if err != nil { return errors.Wrap(err, "failed to create file with ImageContentSources") } From 63574c40ac61b583ed5117efe201d197e4b36032 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 13:39:06 -0400 Subject: [PATCH 09/11] fixes for logging --- internal/ignition/ignition_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ignition/ignition_test.go b/internal/ignition/ignition_test.go index da4427eaf608..4bc645880afd 100644 --- a/internal/ignition/ignition_test.go +++ b/internal/ignition/ignition_test.go @@ -1486,7 +1486,7 @@ var _ = Describe("ICSP file for oc extract", func() { Expect(err).ShouldNot(HaveOccurred()) icspFile, err := getIcspFileFromInstallConfig(data, log) Expect(err).ShouldNot(HaveOccurred()) - Expect(string(icspFile)).Should(BeARegularFile()) + Expect(icspFile).Should(BeARegularFile()) contents, err := ioutil.ReadFile(icspFile) Expect(err).ShouldNot(HaveOccurred()) @@ -1501,6 +1501,6 @@ var _ = Describe("ICSP file for oc extract", func() { Expect(err).ShouldNot(HaveOccurred()) icspFile, err := getIcspFileFromInstallConfig(data, log) Expect(err).ShouldNot(HaveOccurred()) - Expect(string(icspFile)).Should(Equal(expected)) + Expect(icspFile).Should(Equal(expected)) }) }) From 75173186c16c6181905c723b6cf317e6ec15e8c8 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 13:55:05 -0400 Subject: [PATCH 10/11] revert PR 3700 and get latest oc image --- Dockerfile.assisted-service | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile.assisted-service b/Dockerfile.assisted-service index bdf79fdb0ba9..08d8adb29383 100644 --- a/Dockerfile.assisted-service +++ b/Dockerfile.assisted-service @@ -30,8 +30,6 @@ RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service- RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-admission cmd/webadmission/main.go RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/agent-installer-client cmd/agentbasedinstaller/client/main.go -FROM quay.io/ocpmetal/oc-image:bug-1823143-multi-arch-ai-bug-2069976 as oc-image - # Create final image FROM quay.io/centos/centos:stream8 @@ -43,8 +41,9 @@ ARG WORK_DIR=/data RUN mkdir $WORK_DIR && chmod 775 $WORK_DIR -#TODO: Use official oc client once it has ICSP support https://bugzilla.redhat.com/show_bug.cgi?id=1823143 -COPY --from=oc-image /oc /usr/local/bin/ +# downstream this can be installed as an RPM +ARG OC_URL=https://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/4.12.0-0.nightly-2022-07-02-041854/openshift-client-linux.tar.gz +RUN curl --retry 5 -s $OC_URL | tar -xzC /usr/local/bin/ oc COPY --from=builder /build/assisted-service /assisted-service COPY --from=builder /build/assisted-service-operator /assisted-service-operator From db2599be519561cb6eaeba2ef2a4ab385fac1580 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 14 Jul 2022 13:58:26 -0400 Subject: [PATCH 11/11] revert PR 3700 and get latest oc image --- Dockerfile.assisted-service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.assisted-service b/Dockerfile.assisted-service index 08d8adb29383..c37ca0c4120e 100644 --- a/Dockerfile.assisted-service +++ b/Dockerfile.assisted-service @@ -42,7 +42,7 @@ ARG WORK_DIR=/data RUN mkdir $WORK_DIR && chmod 775 $WORK_DIR # downstream this can be installed as an RPM -ARG OC_URL=https://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/4.12.0-0.nightly-2022-07-02-041854/openshift-client-linux.tar.gz +ARG OC_URL=https://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/4.12.0-0.nightly-2022-07-11-054352/openshift-client-linux.tar.gz RUN curl --retry 5 -s $OC_URL | tar -xzC /usr/local/bin/ oc COPY --from=builder /build/assisted-service /assisted-service